Skip to content

Commit 9fa4d90

Browse files
committed
Fix pre-push.hook validation bug
We utilize ./scripts/pre-push.hook to do the checking when trying to do `git push`. One of the stages is to check a speicific commit hash number for validation of the repository. It tries to get the hash number of commit 3ed1723, using a filter to get the value of `commit` whose git log message matches the pattern specified in line 15 of `/scripts/pre-push.hook`. However when merging the commit into the master branch, it generated a new commit which is 390ade9, so the value of `commit` in line 15 of `/scripts/pre-push.hook` will be incorrect. That's why we modify a small part of the command in line 15 from `-n 1` to `--skip 1`, so we can neglect the merging commit and get the actual commit hash number we want. Fix #151
1 parent 390ade9 commit 9fa4d90

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/pre-push.hook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ NC='\033[0m' # No Color
1212
# Author: Jim Huang <[email protected]>
1313
# Date: Tue Feb 20 03:59:49 2024 +0800
1414
# Bump copyright year
15-
commit=$(git rev-list -n 1 --grep '^Bump copyright' 1aca5b98471765db50c91e03298e49bf7c08cdbc...HEAD)
15+
commit=$(git rev-list --skip 1 --grep '^Bump copyright' 1aca5b98471765db50c91e03298e49bf7c08cdbc...HEAD)
1616
if [ x"$commit" != x"3ed17237af5b1ead6c394df5099bc2bc1f8392df" ] ; then
1717
echo -e "${RED}ERROR${NC}: This repository is insane."
1818
echo -e "Make sure you did fork from https://github.com/sysprog21/lab0-c recently."

0 commit comments

Comments
 (0)