web-monetization-projects
web-monetization-projects copied to clipboard
Pre push hook is broken when git not on PATH
➜ coil-extension git:(nd-update-safari-with-ios-support-2021-07-02) ✗ gpsup
Pre-push Hook: Checking branch name
parent_pid: 27901
parent_pid: ps -ocommand= -p 27901
ps: option requires an argument -- p
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
[-g grp[,grp...]] [-u [uid,uid...]]
[-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
ps [-L]
^C
Requires git to be on $PATH
("Fixed" in my case by a brew install)
Need to fix loop to find git in process tree:
until [[ "$push_command" == git* ]]; do
Must handle /Some/long/path/to/git
Is there a particular reason why we are protecting branches with a pre-push script rather than just using github's branch protection feature?
For others running into this issue, I had two git installations:
/usr/bin/git/opt/homebrew/bin/git
The first installation was failing on this pre-push script. Upon switching to use the second installation, the pre-push script passed.
I had a look at this again and this section you commented out is all just debugging variables really. It was a script I adapted from some online source
The script basically will do 2 things: This script will block anybody who tries to push to a certain branch (in my case I don't want anybody -including myself- to push directly to master and develop branch). They need to work in their own branch and then create a pull request. This script will block anybody who tries to push to a branch that is different from their current active branch. For example you are in branch fix/someissue but then you mistakenly type git push origin master.
"Why use this over protected branches" Good question. I can't think of anything at present
Although I have dim memories of discussing this with @traviscrist. It may have been something to do with the way our PR merge permissions are configured and some Github inflexibility (which may or may not exist any more)
@sublimator I can't recall why we settled on it being this way. I think it may have been since it worked with your local dev flow better. Could we run this in CI and then just setup branch protection?