-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathgit-cms-show-pr
More file actions
executable file
·37 lines (27 loc) · 986 Bytes
/
git-cms-show-pr
File metadata and controls
executable file
·37 lines (27 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /bin/bash -e
function usage() {
cat <<@EOF
Usage: git cms-show-pr <pull request> [<branch>]
Description:
Show the commits that are part of a pull request that has been opened or merged
in the master branch, or in <branch> if it is specified.
@EOF
exit $1
}
# the number of the pull request
PULL=$1
[ "$PULL" ] || usage 1
# for a backport, specify the target branch that was used
BRANCH=$2
[ "$BRANCH" ] || BRANCH=master
# FIXME add an option to support alternate repositories ?
REMOTE="official-cmssw"
[ "$CMSSW_BASE" ] && cd $CMSSW_BASE/src
# fetch the master branch from upstream
git fetch -q $REMOTE $BRANCH
# fetch the pull request
git fetch -q $REMOTE pull/$PULL/head
# find the branch point
BRANCH_POINT=$(diff -u <(git rev-list --first-parent FETCH_HEAD) <(git rev-list --first-parent $REMOTE/$BRANCH) | sed -ne 's/^ //p' | head -n1 -)
# show the commits in the pull request
git log --no-decorate --oneline --reverse --topo-order FETCH_HEAD...$BRANCH_POINT