Closed kpedro88 closed 7 years ago
A new Pull Request was created by @kpedro88 (Kevin Pedro) for branch master.
@cmsbuild, @smuzaffar, @iahmad-khan, @davidlange6 can you please review it and eventually sign? Thanks. You can sign-off by replying to this message having '+1' in the first line of your reply. You can reject by replying to this message having '-1' in the first line of your reply.
external issue cms-sw/cmsdist#2955
@kpedro88 some time ago I wrote an attempt to automatically backport a PR from one branch to another:
#! /bin/bash -e
OAUTH_TOKEN="869cfb0477e0cae72fb233be5e1f02bd97905bad"
REMOTE="git@github.com:cms-sw/cmssw.git"
PR=$1
# backport onto the given branch, or the current HEAD
if [ "$2" ] ; then
BRANCH="$2"
else
BRANCH=`git rev-parse --abbrev-ref HEAD`
fi
# remove any stale backport-attempt branch
git branch -D backport-attempt >& /dev/null || true
# identify what branch the original PR was meant for
MASTER=`curl -s -S -H "Authorization: token $OAUTH_TOKEN" "https://api.github.com/repos/cms-sw/cmssw/pulls/$PR" | python -c 'import sys, json; data = json.load(sys.stdin); print data["base"]["ref"]'`
# fetch the original branch
git fetch -n $REMOTE refs/heads/$MASTER:backport-from-$MASTER
# fetch the PR
git fetch -n $REMOTE refs/pull/$PR/head:backport-attempt
git rebase backport-from-$MASTER backport-attempt --onto $BRANCH
git checkout $BRANCH
git reset --hard backport-attempt
I never had time to polish it and test it properly, but maybe you could use it a a starting point for something fancier.
Pull request #79 was updated.
external issue cms-sw/cmsdist#2955
@fwyzard thanks for the comments, I implemented most of them.
Your point about the -n
option is well-taken. I tried to take a different approach now, so cms-merge-topic
can automatically detect if it is being called by the no-merge wrapper cms-checkout-topic
. I'm not sure if this is sufficiently portable, though...
Also, I noticed that git-cms-sparse-checkout
has a !/bin/sh
shebang instead of !/bin/bash
; should that be fixed?
Now that cms-checkout-topic just calls cms-merge-topic, isn't it easier to just have it as a symlink. With symlink basename $0 | sed -e's/^git-//'
should return the correct name.
@smuzaffar good idea
Pull request #79 was updated.
external issue cms-sw/cmsdist#2955
@smuzaffar does this need to be tested somehow?
yes, I will include it in DEVEL IBs after some local testing. Once tested in devel IBs, then I will include this for normal IBs
@kpedro88 , can you please also add man page entry for new tools in https://github.com/cms-sw/cms-git-tools/tree/master/docs/man
And may be update this tool recognize -h|--help option e.g. something like -h|--help) usage $COMMAND_NAME;;
currently --help option fails with Unknown option --help
@smuzaffar done
Pull request #79 was updated.
external issue cms-sw/cmsdist#2955
Pull request #79 was updated.
external issue cms-sw/cmsdist#2955
This adds
cms-checkout-topic
as a wrapper for a new--no-merge
option incms-merge-topic
. This option is primarily intended to help with rebasing PRs, by allowing users to set up the modified packages and source code for a topic branch in a release area without doing a merge (which can cause 100s of duplicate commits).Most of the functionality is duplicated from
cms-merge-topic
, so the new option is added there rather than making an entirely separate script. Thecms-checkout-topic
wrapper is added to have a more self-explanatory description of the command (however git-esquecms-merge-topic --no-merge
might be...).