-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgit-review
executable file
·49 lines (44 loc) · 1.19 KB
/
git-review
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
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: $0 rev-list reviewer summary [options]...";
echo
exit 1
fi
REVLIST=$1
REVIEWER=$2
SUMMARY=$3
if [[ $REVLIST == *.* ]]; then
DESCRIPTION=$(git whatchanged $REVLIST)
DIFF_CMD="git diff $REVLIST"
if [ -z "$SUMMARY" ]; then
echo Must provide a summary for a list of revisions
exit 1
fi
else
DESCRIPTION=$(git whatchanged -n1 $REVLIST)
DIFF_CMD="git show $REVLIST"
if [ -z "$SUMMARY" ]; then
SUMMARY=$(git log -n1 --pretty=format:%s $REVLIST)
fi
fi
remote_url=$(
git remote -v | egrep -o 'CDH/[a-zA-Z]+.git' | head -1)
if [ -n "$remote_url" ]; then
remote_url=git://github.sf.cloudera.com/$remote_url
else
remote_url=$(
git remote -v | grep '^origin ' | grep push | awk '{print $2}')
if [ -z "$remote_url" ]; then
echo 'could not figure out remote URL from remotes!'
exit 1
fi
if [[ "$remote_url" =~ ^git@github.*cloudera.com:(.+)$ ]] ; then
remote_url=git://github.mtv.cloudera.com/${BASH_REMATCH[1]}
fi
fi
post-review --description="$DESCRIPTION" \
--target-groups=hadoop \
--target-people="$REVIEWER" \
--diff-filename=<($DIFF_CMD) \
--repository-url=$remote_url \
--summary="$SUMMARY"