File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,8 +51,12 @@ function apply-github-patch {
5151 fi
5252 fi
5353
54+ _git_with_credentials () {
55+ git -c user.name=" apply-github-patch" -c user.email=" noreply@example.com" " $@ "
56+ }
57+
5458 # Approach #1: Try a simple patch application with 'git am'
55- git am --keep-cr " $patch_file " && return 0
59+ _git_with_credentials am --keep-cr " $patch_file " && return 0
5660 git am --abort || true # wokeignore:rule=abort/terminate
5761
5862 # Approach #2: Try a three-way merge after fetching the parent commit. It can handle
@@ -63,13 +67,13 @@ function apply-github-patch {
6367 fetch_url=" https://x-access-token:${GITHUB_TOKEN} @github.com/$1 .git"
6468 fi
6569 git fetch --no-tags --quiet --depth=2 " $fetch_url " " $2 " || true
66- git am --3way --keep-cr " $patch_file " && return 0
70+ _git_with_credentials am --3way --keep-cr " $patch_file " && return 0
6771 git am --abort || true # wokeignore:rule=abort/terminate
6872
6973 # Approach #3: Fall back to GNU 'patch'
7074 patch -p1 < " $patch_file " || return 1
7175 git add -A
72- git -c user.name= " apply-github-patch " -c user.email= " noreply@example.com " commit -m " Applied patch $2 from $1 ."
76+ _git_with_credentials commit -m " Applied patch $2 from $1 ."
7377 return 0
7478}
7579
You can’t perform that action at this time.
0 commit comments