Skip to content

Commit 39c07d2

Browse files
authored
Merge pull request #37 from jozefrebjak/docker-support
2 parents 0a6f3f1 + 5328050 commit 39c07d2

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Most of the time the simple script is what you will want, but `patch` takes a fe
5353
to alter the behavior of the patch process. Arguments that take a "commit-ish" can use anything
5454
Git recognizes (branch, hash, tag, reference, revision, etc).
5555

56+
To ensure patches work correctly in a Docker container, you may need to set the `user.email` and `user.name` values manually using the `-e` and `-n` flags respectively. This is necessary because Docker containers are often not preconfigured for Git.
57+
5658
#### Help (-h)
5759

5860
Displays the latest command help:
@@ -66,6 +68,8 @@ Options:
6668
-h Help. Show this help message and exit
6769
-c commit-ish Alternate version to consider "current" (rarely needed).
6870
-v commit-ish Version to use for patching. Defaults to the latest.
71+
-e Git global user.email.
72+
-n Git global user.name.
6973
```
7074

7175
#### Version (-v <commit-ish>)

src/patch

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Options:
2020
-h Help. Show this help message and exit
2121
-c commit-ish Alternate version to consider "current" (rarely needed).
2222
-v commit-ish Version to use for patching. Defaults to the latest.
23+
-e Git global user.email.
24+
-n Git global user.name.
2325
2426
Examples:
2527
Patch the current installed repo up to the latest available.
@@ -35,7 +37,7 @@ EOT
3537
CURRENT_VERSION=""
3638
TARGET_VERSION=""
3739

38-
while getopts "hv:c:" OPT; do
40+
while getopts "hv:c:e:n:" OPT; do
3941
case ${OPT} in
4042
h) ## -h help
4143
show_help
@@ -47,6 +49,12 @@ while getopts "hv:c:" OPT; do
4749
v) ## -c <target version>
4850
TARGET_VERSION=${OPTARG}
4951
;;
52+
e) ## -e <git user.email>
53+
GIT_USER_EMAIL=${OPTARG}
54+
;;
55+
n) ## -n <git user.name>
56+
GIT_USER_NAME=${OPTARG}
57+
;;
5058
esac
5159
done
5260

@@ -77,6 +85,12 @@ try()
7785
git --version
7886
try $? "Git must be installed."
7987

88+
# When using patches in a Docker container, it is necessary to set the user.email and user.name values manually
89+
if [[ -n "$GIT_USER_EMAIL" && -n "$GIT_USER_NAME" ]]; then
90+
git config --global user.email "$GIT_USER_EMAIL";
91+
git config --global user.name "$GIT_USER_NAME";
92+
fi
93+
8094
composer --version
8195
try $? "Composer must be installed."
8296

0 commit comments

Comments
 (0)