summaryrefslogtreecommitdiff
path: root/logerrit
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2013-03-26 15:39:55 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2013-03-26 15:40:26 +0100
commit15e9f568fdd73bd783e89283602b4017af373a39 (patch)
tree472d62aa79da0c23c4fcc93663c997888d575ceb /logerrit
parent646b992ee306f83fa7175cc957cba9dc2277155a (diff)
add draft-submittal to logerrit and retab
Change-Id: I5f52d9c81c28c9a4b23eaf043e7b67b1fc6d82d9
Diffstat (limited to 'logerrit')
-rwxr-xr-xlogerrit400
1 files changed, 208 insertions, 192 deletions
diff --git a/logerrit b/logerrit
index 77004945817f..99d09ac8ba38 100755
--- a/logerrit
+++ b/logerrit
@@ -5,72 +5,81 @@ GERRITHOST=logerrit
GERRITURL=ssh://$GERRITHOST/core
get_SHA_for_change() {
- SHA=`ssh ${GERRITHOST?} gerrit query --all-approvals change:$1|grep ref|tail -1|cut -d: -f2`
+ SHA=`ssh ${GERRITHOST?} gerrit query --all-approvals change:$1|grep ref|tail -1|cut -d: -f2`
}
get_REVISION_for_change() {
- REVISION=`ssh ${GERRITHOST?} gerrit query --all-approvals change:$1|grep revision|tail -1|cut -d: -f2`
+ REVISION=`ssh ${GERRITHOST?} gerrit query --all-approvals change:$1|grep revision|tail -1|cut -d: -f2`
}
ask_tristate() {
- case $1 in
- [yY] | [yY][Ee][Ss] | [+] )
- ANSWER=y
- ;;
- [nN] | [n|N][O|o] | [-] )
- ANSWER=n
- ;;
- [] )
- ANSWER=
- ;;
- * )
- echo "Please answer with either +,-,y,n,yes,no or the empty string."
- exit 1
- ;;
- esac
+ case $1 in
+ [yY] | [yY][Ee][Ss] | [+] )
+ ANSWER=y
+ ;;
+ [nN] | [n|N][O|o] | [-] )
+ ANSWER=n
+ ;;
+ [] )
+ ANSWER=
+ ;;
+ * )
+ echo "Please answer with either +,-,y,n,yes,no or the empty string."
+ exit 1
+ ;;
+ esac
}
submit() {
- BRANCH=$1
- if test -z "$BRANCH"
- then
- BRANCH=`git symbolic-ref HEAD 2> /dev/null`
- BRANCH="${BRANCH##refs/heads/}"
- if test -z "$BRANCH"
- then
- echo "no branch specified, and could not guess the current branch"
- exit 1
- fi
- echo "no branch specified, guessing current branch $BRANCH"
- fi
- git push $GERRITURL HEAD:refs/for/$BRANCH
+ TYPE=$1
+ BRANCH=$2
+ if test -z "$BRANCH"
+ then
+ BRANCH=`git symbolic-ref HEAD 2> /dev/null`
+ BRANCH="${BRANCH##refs/heads/}"
+ if test -z "$BRANCH"
+ then
+ echo "no branch specified, and could not guess the current branch"
+ exit 1
+ fi
+ echo "no branch specified, guessing current branch $BRANCH"
+ fi
+ git push $GERRITURL HEAD:refs/$TYPE/$BRANCH
}
case "$1" in
- help|--help|"")
- echo "Usage: ./logerrit subcommand [options]"
- echo "simple and basic tool to interact with LibreOffice gerrit"
- echo "subcommands:"
- echo " setup walking you though your gerrit setup"
- echo " test test your gerrit setup"
- echo " --- for submitters:"
- echo " submit [BRANCH] submit your change for review"
- echo " resubmit [BRANCH] create a new Change-Id and submit your change for review"
- echo " (yes, this modifies your last commit)"
- echo " nextchange [BRANCH] reset branch to the remote to start with the next change"
- echo " --- for reviewers:"
- echo " checkout CHANGEID checkout the changes for review"
- echo " pull CHANGEID pull (and merge) the changes on current branch"
- echo " cherry-pick CHANGEID cherry-pick the change on current branch"
- echo " patch CHANGEID show the change as a patch"
- echo " review [CHANGEID] interactively review a change (current one if no changeid given)"
- echo " query .... query for changes for review on project core"
- echo " <any other gerrit command>"
- echo "advanced users should consider using git review instead:"
- echo "http://wiki.documentfoundation.org/Development/GitReview"
- exit
- ;;
+ help|--help|"")
+ echo "Usage: ./logerrit subcommand [options]"
+ echo "simple and basic tool to interact with LibreOffice gerrit"
+ echo "subcommands:"
+ echo " setup walking you though your gerrit setup"
+ echo " test test your gerrit setup"
+ echo
+ echo " --- for submitters:"
+ echo " submit [BRANCH] submit your change for review"
+ echo " resubmit [BRANCH] create a new Change-Id and submit your change for review"
+ echo " (yes, this modifies your last commit)"
+ echo " submit-draft [BRANCH] submit your change as draft"
+ echo " resubmit-draft [BRANCH] create a new Change-Id and submit your change as draft"
+ echo " (yes, this modifies your last commit)"
+ echo " (yes, this modifies your last commit)"
+ echo " nextchange [BRANCH] reset branch to the remote to start with the next change"
+ echo "Note: drafts are only visibly to yourself and those that you explicitly add as reviewers."
+ echo
+ echo " --- for reviewers:"
+ echo " checkout CHANGEID checkout the changes for review"
+ echo " pull CHANGEID pull (and merge) the changes on current branch"
+ echo " cherry-pick CHANGEID cherry-pick the change on current branch"
+ echo " patch CHANGEID show the change as a patch"
+ echo " review [CHANGEID] interactively review a change (current one if no changeid given)"
+ echo " query .... query for changes for review on project core"
+ echo " <any other gerrit command>"
+ echo
+ echo "advanced users should consider using git review instead:"
+ echo "http://wiki.documentfoundation.org/Development/GitReview"
+ exit
+ ;;
setup)
echo "Please go to https://gerrit.libreoffice.org/ and:"
echo "- press the 'sign-in' button in the top right corner"
@@ -81,7 +90,7 @@ case "$1" in
echo "commit from them. Additional emails must be confirmed with repling to the"
echo "invitation mail it sends you. Which user name did you choose? Sweetshark"
echo
- read -p 'Which user name did you choose? ' GERRITUSER
+ read -p 'Which user name did you choose? ' GERRITUSER
echo
echo "Please now add the following to your ~/.ssh/config, creating the file if needed:"
echo
@@ -98,146 +107,153 @@ case "$1" in
echo
echo "To see if your setup was successful, run './logerrit test' then."
;;
- test)
- if test -n "`ssh $GERRITHOST 2>&1|grep \"Welcome to Gerrit Code Review\"`"
- then
- echo "Your gerrit setup was successful!"
- else
- echo "There seems to be trouble."
- echo "please have the output of: ssh -vvvv logerrit"
- echo "at hand when looking for help."
- fi
- ;;
- submit)
- submit $2
- ;;
+ test)
+ if test -n "`ssh $GERRITHOST 2>&1|grep \"Welcome to Gerrit Code Review\"`"
+ then
+ echo "Your gerrit setup was successful!"
+ else
+ echo "There seems to be trouble."
+ echo "please have the output of: ssh -vvvv logerrit"
+ echo "at hand when looking for help."
+ fi
+ ;;
+ submit)
+ submit 'for' $2
+ ;;
resubmit)
git log -1 --pretty=%B | grep -v ^Change-Id: | git commit --amend -F -
- submit $2
+ submit 'for' $2
+ ;;
+ submit-draft)
+ submit drafts $2
+ ;;
+ resubmit-draft)
+ git log -1 --pretty=%B | grep -v ^Change-Id: | git commit --amend -F -
+ submit drafts $2
;;
- nextchange)
- if test -n "`git status -s -uno`"
- then
- echo "You have uncommitted changes. Please commit or stash these:"
- git status
- exit 1
- fi
- CHANGEID=`git log --format=format:%b -1 HEAD|grep Change-Id|cut -d: -f2|tr -d \ `
- if test -z "$CHANGEID"
- then
- CHANGEID="NOCHANGEID"
- fi
- BACKUPBRANCH=backup/$CHANGEID-`date +%F-%H%M%S`
- git branch $BACKUPBRANCH
- echo "current state backed up as $BACKUPBRANCH"
- BRANCH=$2
- if test -z "$BRANCH"
- then
- BRANCH=`git symbolic-ref HEAD 2> /dev/null`
- BRANCH="${BRANCH##refs/heads/}"
- if test -z "$BRANCH"
- then
- echo "no branch specified, and could not guess the current branch"
- exit 1
- fi
- echo "no branch specified, guessing current branch $BRANCH"
- fi
- git reset --hard remotes/origin/$BRANCH
- ;;
- review)
- CHANGEID=$2
- if test -z "$CHANGEID"
- then
- CHANGEID=`git log --format=format:%b -1 HEAD|grep Change-Id|cut -d: -f2`
- if test -z "$CHANGEID"
- then
- echo "could not find a Change-Id in your last commit, sorry"
- exit 1
- fi
- echo "no Change-Id given on the command line, reviewing change$CHANGEID"
- fi
- MESSAGEREQ=""
- read -p 'was the change verified to build successfully (+) or found not to build (-) or none of that ()? ' VERIFIED
- ask_tristate $VERIFIED
- case "$ANSWER" in
- "y")
- VERIFIEDFLAG=--verified=+1
- ;;
- "n")
- VERIFIEDFLAG="--verified=-1"
- MESSAGEREQ="$MESSAGEREQ and explain why you could not verify this"
- ;;
- *)
- VERIFIEDFLAG="--verified=0"
- ;;
+ nextchange)
+ if test -n "`git status -s -uno`"
+ then
+ echo "You have uncommitted changes. Please commit or stash these:"
+ git status
+ exit 1
+ fi
+ CHANGEID=`git log --format=format:%b -1 HEAD|grep Change-Id|cut -d: -f2|tr -d \ `
+ if test -z "$CHANGEID"
+ then
+ CHANGEID="NOCHANGEID"
+ fi
+ BACKUPBRANCH=backup/$CHANGEID-`date +%F-%H%M%S`
+ git branch $BACKUPBRANCH
+ echo "current state backed up as $BACKUPBRANCH"
+ BRANCH=$2
+ if test -z "$BRANCH"
+ then
+ BRANCH=`git symbolic-ref HEAD 2> /dev/null`
+ BRANCH="${BRANCH##refs/heads/}"
+ if test -z "$BRANCH"
+ then
+ echo "no branch specified, and could not guess the current branch"
+ exit 1
+ fi
+ echo "no branch specified, guessing current branch $BRANCH"
+ fi
+ git reset --hard remotes/origin/$BRANCH
+ ;;
+ review)
+ CHANGEID=$2
+ if test -z "$CHANGEID"
+ then
+ CHANGEID=`git log --format=format:%b -1 HEAD|grep Change-Id|cut -d: -f2`
+ if test -z "$CHANGEID"
+ then
+ echo "could not find a Change-Id in your last commit, sorry"
+ exit 1
+ fi
+ echo "no Change-Id given on the command line, reviewing change$CHANGEID"
+ fi
+ MESSAGEREQ=""
+ read -p 'was the change verified to build successfully (+) or found not to build (-) or none of that ()? ' VERIFIED
+ ask_tristate $VERIFIED
+ case "$ANSWER" in
+ "y")
+ VERIFIEDFLAG=--verified=+1
+ ;;
+ "n")
+ VERIFIEDFLAG="--verified=-1"
+ MESSAGEREQ="$MESSAGEREQ and explain why you could not verify this"
+ ;;
+ *)
+ VERIFIEDFLAG="--verified=0"
+ ;;
- esac
- read -p 'is the code looking good (+), bad (-) or none of that ()? ' CODEREVIEW
- ask_tristate $CODEREVIEW
- SUBMITFLAG=""
- case "$ANSWER" in
- "y")
- read -p 'do you approve the change (+) too, or prefer someone else to do that ()? ' CODEREVIEW
- ask_tristate $CODEREVIEW
- case "$ANSWER" in
- "y")
- CODEREVIEWFLAG="--code-review=2"
- SUBMITFLAG="--submit"
- ;;
- "n")
- CODEREVIEWFLAG="--code-review=1"
- ;;
- *)
- CODEREVIEWFLAG="--code-review=1"
- ;;
- esac
- ;;
- "n")
- read -p 'do you still allow the change to go in () or not (-)? ' CODEREVIEW
- ask_tristate $CODEREVIEW
- case "$ANSWER" in
- "y")
- CODEREVIEWFLAG="--code-review=-1"
- MESSAGEREQ="$MESSAGEREQ and explain why you have reservations about the code"
- ;;
- "n")
- CODEREVIEWFLAG="--code-review=-2"
- MESSAGEREQ="$MESSAGEREQ and explain why you want to block this"
- ;;
- *)
- CODEREVIEWFLAG="--code-review=-1"
- MESSAGEREQ="$MESSAGEREQ and explain why you have reservations about the code"
- ;;
- esac
- ;;
- *)
- ;;
- esac
- read -p "please type a friendly comment$MESSAGEREQ: " MESSAGE
- get_REVISION_for_change $CHANGEID
- ssh ${GERRITHOST?} gerrit review -m \"$MESSAGE\" $VERIFIEDFLAG $CODEREVIEWFLAG $SUBMITFLAG $REVISION
- ;;
- checkout)
- get_SHA_for_change $2
- git fetch $GERRITURL $SHA && git checkout FETCH_HEAD
- ;;
- pull)
- get_SHA_for_change $2
- git pull $GERRITURL $SHA
- ;;
- cherry-pick)
- get_SHA_for_change $2
- git fetch $GERRITURL $SHA && git cherry-pick FETCH_HEAD
- ;;
- patch)
- get_SHA_for_change $2
- git fetch $GERRITURL $SHA && git format-patch -1 --stdout FETCH_HEAD
- ;;
- query)
- shift
- ssh ${GERRITHOST?} gerrit query project:core $@
- ;;
- *)
- ssh ${GERRITHOST?} gerrit $@
- ;;
+ esac
+ read -p 'is the code looking good (+), bad (-) or none of that ()? ' CODEREVIEW
+ ask_tristate $CODEREVIEW
+ SUBMITFLAG=""
+ case "$ANSWER" in
+ "y")
+ read -p 'do you approve the change (+) too, or prefer someone else to do that ()? ' CODEREVIEW
+ ask_tristate $CODEREVIEW
+ case "$ANSWER" in
+ "y")
+ CODEREVIEWFLAG="--code-review=2"
+ SUBMITFLAG="--submit"
+ ;;
+ "n")
+ CODEREVIEWFLAG="--code-review=1"
+ ;;
+ *)
+ CODEREVIEWFLAG="--code-review=1"
+ ;;
+ esac
+ ;;
+ "n")
+ read -p 'do you still allow the change to go in () or not (-)? ' CODEREVIEW
+ ask_tristate $CODEREVIEW
+ case "$ANSWER" in
+ "y")
+ CODEREVIEWFLAG="--code-review=-1"
+ MESSAGEREQ="$MESSAGEREQ and explain why you have reservations about the code"
+ ;;
+ "n")
+ CODEREVIEWFLAG="--code-review=-2"
+ MESSAGEREQ="$MESSAGEREQ and explain why you want to block this"
+ ;;
+ *)
+ CODEREVIEWFLAG="--code-review=-1"
+ MESSAGEREQ="$MESSAGEREQ and explain why you have reservations about the code"
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
+ read -p "please type a friendly comment$MESSAGEREQ: " MESSAGE
+ get_REVISION_for_change $CHANGEID
+ ssh ${GERRITHOST?} gerrit review -m \"$MESSAGE\" $VERIFIEDFLAG $CODEREVIEWFLAG $SUBMITFLAG $REVISION
+ ;;
+ checkout)
+ get_SHA_for_change $2
+ git fetch $GERRITURL $SHA && git checkout FETCH_HEAD
+ ;;
+ pull)
+ get_SHA_for_change $2
+ git pull $GERRITURL $SHA
+ ;;
+ cherry-pick)
+ get_SHA_for_change $2
+ git fetch $GERRITURL $SHA && git cherry-pick FETCH_HEAD
+ ;;
+ patch)
+ get_SHA_for_change $2
+ git fetch $GERRITURL $SHA && git format-patch -1 --stdout FETCH_HEAD
+ ;;
+ query)
+ shift
+ ssh ${GERRITHOST?} gerrit query project:core $@
+ ;;
+ *)
+ ssh ${GERRITHOST?} gerrit $@
+ ;;
esac