add backporting git alias
This commit is contained in:
@@ -31,6 +31,8 @@
|
|||||||
la = !git l --all
|
la = !git l --all
|
||||||
sync = "!source ~/.githelpers && sync_to_remote"
|
sync = "!source ~/.githelpers && sync_to_remote"
|
||||||
bsync = "!source ~/.githelpers && update_branch"
|
bsync = "!source ~/.githelpers && update_branch"
|
||||||
|
bp = !git backport
|
||||||
|
backport = "!source ~/.githelpers && backport_pr"
|
||||||
|
|
||||||
todo = grep --heading --break --ignore-case -e ' FIX: *' -e ' TODO: *'
|
todo = grep --heading --break --ignore-case -e ' FIX: *' -e ' TODO: *'
|
||||||
pr = "!source ~/.githelpers && get_pr"
|
pr = "!source ~/.githelpers && get_pr"
|
||||||
|
|||||||
@@ -87,4 +87,23 @@ clean_branches() {
|
|||||||
for i in ${BRANCHES}; do
|
for i in ${BRANCHES}; do
|
||||||
git branch -d $i
|
git branch -d $i
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backport_pr() {
|
||||||
|
PR=$1
|
||||||
|
BRANCH=$2
|
||||||
|
[ -z "$BRANCH" ] && BRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||||
|
REMOTE=$3
|
||||||
|
: ${REMOTE:=$DEFAULT_REMOTE}
|
||||||
|
THISBRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||||
|
|
||||||
|
if [ -z "$PR" ]; then
|
||||||
|
echo "Please specify a PR to backport"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo Backporting ${PR} to ${BRANCH} from ${REMOTE}
|
||||||
|
git fetch ${REMOTE} pull/${1}/head:pr/${1}
|
||||||
|
git checkout ${BRANCH} && curl -s "https://github.com/elastic/kibana/pull/${PR}.patch" | git am
|
||||||
|
[ "$THISBRANCH" != "$BRANCH" ] && git checkout -
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user