summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorPatrick Rohr <prohr@google.com>2023-04-06 09:42:27 -0700
committerPatrick Rohr <prohr@google.com>2023-04-06 09:42:27 -0700
commite9fa01f75ef4a61ddbc20f86b806e6e7ec640c31 (patch)
tree8d79c611f367a430931b835147bc0576ab3c682b /android
parent84df5e21757b9aa3f37ee2156c20abff676ba160 (diff)
downloadcronet-e9fa01f75ef4a61ddbc20f86b806e6e7ec640c31.tar.gz
cronet import: clean up post-commit hook
Per comments in aosp/2523899. Test: git commit Change-Id: Ic3d772f15c445d400d259a20b421d01e5ed0cef3
Diffstat (limited to 'android')
-rwxr-xr-xandroid/tools/githooks/post-commit6
1 files changed, 3 insertions, 3 deletions
diff --git a/android/tools/githooks/post-commit b/android/tools/githooks/post-commit
index bf3e18f6b..8bdf606af 100755
--- a/android/tools/githooks/post-commit
+++ b/android/tools/githooks/post-commit
@@ -31,7 +31,7 @@ fi
# expected.
# TODO: find a better solution. One option is to parse `git status` output and
# grep for the "rebase in progress" string.
-if [ -d "$(git rev-parse --git-dir)/rebase-merge" ]; then
+if [[ -d "$(git rev-parse --git-dir)/rebase-merge" ]]; then
# interactive rebase in progress.
echo "WARNING! .patch files are not updated during interactive rebase"
exit 0
@@ -45,11 +45,11 @@ chmod -x .git/hooks/post-commit
trap "chmod +x .git/hooks/post-commit" EXIT
# Remove any existing .patch files from the commit
-git reset HEAD~1 -- "${PATCHES_DIR}/*.patch"
+git reset HEAD~ -- "${PATCHES_DIR}/*.patch"
git -c "advice.ignoredHook=false" commit --amend --no-edit
# Create patch (which only reflects changes to .gn and .gni files).
-number_of_patches=$(git ls-tree -r HEAD~1 -- "${PATCHES_DIR}" | wc -l)
+number_of_patches=$(git ls-tree -r HEAD~ -- "${PATCHES_DIR}" | wc -l)
patch_name=$(git format-patch -1 -N --start-number "${number_of_patches}" -o "${PATCHES_DIR}" HEAD -- "*.gn" "*.gni")
git add "${patch_name}"
git -c "advice.ignoredHook=false" commit --amend --no-edit