File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 1414# and the SHA-1 the user is trying to push. If the update script exits non-zero, only that
1515# reference is rejected; other references can still be updated.
1616
17- refname=$1
18- oldrev=$2
19- newrev=$3
17+ refname=$1 # name of ref that is being updated
18+ oldrev=$2 # old object name that ref pointed to before
19+ newrev=$3 # new object name that ref should point to
2020echo " Enforcing policies for revision ${refname} :"
2121
2222# -------------------------------
3030
3131# Check if a zero sha, then either a new branch is pushed or an empty repo is being pushed
3232if [ " ${oldrev} " == " 0000000000000000000000000000000000000000" ]; then
33- # List everything reachable from newrev but not any heads
34- span=` git rev-list $( git for-each-ref --format=' %(refname)' refs/heads/* | sed ' s/^/\^/' ) ${newrev} `
33+ # List heads, add a ^ to negate in the following 'git rev-list' command
34+ heads=$( git for-each-ref --format=' %(refname)' refs/heads/* | sed ' s/^/\^/' )
35+ # List everything reachable from ${newref} but not from any heads
36+ span=$( git rev-list ${newrev} ${heads} )
3537else
36- span=` git rev-list ${oldrev} ..${newrev} `
38+ # branch labels are updated after hook ran successfully, so get all new commits, but none that are reachable from any branches
39+ # specify that we don’t want any commits that are reachable from any of the known branch labels
40+ span=$( git rev-list ${oldrev} ..${newrev} --not --branches=' *' )
3741fi
3842
3943# ------------------------------------
You can’t perform that action at this time.
0 commit comments