You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@mcollina I have a few custom git commands that are in essense using the same commands as the OP + some additional checking and configuration, I plan to open a PR later this week to see what people thinks. (If we point them to git-* bin targets of package.json, those will automatically appear as git commands).
Here is a preview. I plan to make another one that handles the single-commit case so there will only be one command needed for the simplest cases. This allows user configure their upstream remote names and is aware of the branch that they are on.
I actually played a bit around and my script and it got a bit more sophisticated. Note - I use xclip to copy the message into the clipboard. UPDATE: Using multiple commits will now amend all commit messages properly.
#!/bin/bashset -x
set -e
if [ $1!="verify" ]
then# Get the patch
curl -L https://github.com/nodejs/node/pull/$1.patch | git am -3 --whitespace=fix
# Run linter
make lint
# Check for more than one commit
COMMITS=$(git rev-list --count master...origin/master)# Get metadata and add it to the commit message
METADATA=$(get-metadata $1 -f)if [ $COMMITS!="1" ]
then
git rebase -i --autostash origin/master
# Run linter again
make lint
fi# Update commits left
COMMITS=$(git rev-list --count master...origin/master)
NL=$'\n\n'# If there one commit add the commit message, else add the commit message for# each commit by using `--exec` with `git commit --amend`if [ $COMMITS="1" ]
then
git commit --amend -m "$(git show -s --format=%B)$NL$METADATA"elseecho -e "$NL$METADATA"> tmp_metadata.txt
git rebase --autostash --quiet \
--exec "git show -s --format=%B > tmp_message.txt" \
--exec "cat tmp_metadata.txt >> tmp_message.txt" \
--exec "git commit --amend -F tmp_message.txt" \
--exec "rm tmp_message.txt"
rm tmp_metadata.txt
fielse
COMMITS=$(git rev-list --count master...origin/master)fi# Validate all commit messages
git rev-list master...origin/master | xargs core-validate-commit
git log --format=%B -n $COMMITS# Copy the message for the PR to the clipboardif [ $COMMITS!="1" ] && [ $COMMITS!="2" ]
thenecho"Landed in $(git rev-parse origin/master) .. $(git rev-parse HEAD)"| xclip -sel clip
else
COMMIT_IDS=$(git log --format="%H" -n $COMMITS --reverse)echo"Landed in ${COMMIT_IDS//$'\n'/, }"| xclip -sel clip
fi
@cPhost I just thought I might share it as it does a few more things and if someone wants to use, they can. I am probably going to improve that a bit further from time to time.
The current version of my script does quite a lot automated already. It will e.g. rebase nicely and stuff like that. In the end it copies a message for the users in the clipboard in a nice way as well.
Activity
joyeecheung commentedon Nov 8, 2017
@mcollina I have a few custom git commands that are in essense using the same commands as the OP + some additional checking and configuration, I plan to open a PR later this week to see what people thinks. (If we point them to
git-*bin targets ofpackage.json, those will automatically appear as git commands).Here is a preview. I plan to make another one that handles the single-commit case so there will only be one command needed for the simplest cases. This allows user configure their upstream remote names and is aware of the branch that they are on.
(posted the wrong image earlier..)
Tiriel commentedon Nov 10, 2017
Ref: #98
BridgeAR commentedon Dec 12, 2017
As I also use a very similar bash script at the moment - to handle multiple commits at a time I also added a conditional rebase
BridgeAR commentedon Dec 12, 2017
I actually played a bit around and my script and it got a bit more sophisticated.
Note - I usexclipto copy the message into the clipboard.UPDATE: Using multiple commits will now amend all commit messages properly.
priyank-p commentedon Dec 12, 2017
Hey @BridgeAR
xclipfor copying data is a great idea but the problem is bash pr is till Work in Progress.BridgeAR commentedon Dec 12, 2017
@cPhost I just thought I might share it as it does a few more things and if someone wants to use, they can. I am probably going to improve that a bit further from time to time.
BridgeAR commentedon Jan 12, 2018
The current version of my script does quite a lot automated already. It will e.g. rebase nicely and stuff like that. In the end it copies a message for the users in the clipboard in a nice way as well.
BridgeAR commentedon Jan 12, 2018
Note: I have a "weird" setup so most people would have to switch
origin/mastertoupstream/master.joyeecheung commentedon Jan 17, 2018
I guess this is fixed now that
git-node-landhas landed.