web-monetization-projects icon indicating copy to clipboard operation
web-monetization-projects copied to clipboard

Pre push hook is broken when git not on PATH

Open sublimator opened this issue 4 years ago • 5 comments

➜  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

sublimator avatar Jul 02 '21 08:07 sublimator

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

sublimator avatar Jul 02 '21 08:07 sublimator

Is there a particular reason why we are protecting branches with a pre-push script rather than just using github's branch protection feature?

bboynton97 avatar Jan 11 '22 18:01 bboynton97

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.

bboynton97 avatar Jan 11 '22 19:01 bboynton97

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 avatar Jan 12 '22 01:01 sublimator

@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?

traviscrist avatar Jan 13 '22 20:01 traviscrist