The workflow that this solution addresses is discussed more in-depth in a
previous
thread in this group
<https://groups.google.com/forum/#!topic/reviewboard/Z0WNZ_dgZO8>. The most
common use case is for small changes, hotfixes, etc. and can be summarized
as follows:
1. git checkout master
2. git fetch && git pull
3. git checkout -b working-branch
4. make some changes
5. git push --set-upstream origin working-branch (or otherwise push to
remote branch, usually this branch has same name as the JIRA tracking the
issue/task)
6. git commit
7. Make any changes to the draft pull request description/reviewers,
then click "Create pull request" button.
8. Address any review comments iteratively with edit/commit/push
9. Once approvals are in place, merge to master.
Step 5 is added as part of the process of creating a local branch; this
makes the rbt stamp URL appear as intended on the first actual change that
is pushed.
Setting --branch automatically and automatically determining whether stamp
and update flags are needed were some of the primary drivers for creating a
wrapper.
This will undergo some refinement as we work through the use cases of
feature branches off of master/next/live that take merges from
sub-branches, and I will update as we move forward.
To start with, the following ALIASES entries are added to the repo's
.reviewboardrc:
ALIASES = {
'commit': '!bash rb-git commit $*',
'push': '!bash rb-git push $*',
'checkoutb': '!git checkout -b $1 &&'
'git push --set-upstream origin $1',
}
Here are the contents of the rb-git wrapper script, which is a little
chatty for now -- eventually it will have many of the echo statements
removed:
#!/usr/bin/env bash
#
# This script is meant to be used in conjunction with rbt and the ALIASES
set
# in .reviewboardrc at the top of the repository. That means it is not meant
# to be called directly. Do so at your own risk.
#
#
if [[ $1 == 'commit' ]] || [[ $1 == 'push' ]]; then
ACTION=$1
else
echo
echo "ERROR: First argument must be 'push' or 'commit'."
echo
echo "Read the notes in $0 for details."
exit
fi
BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "You are on the branch: $BRANCH"
# If we don't see a "Reviewed" stamp on this branch, stamp this commit.
if (git log $BRANCH --not master | grep "Reviewed at http" ) ; then
echo "This will NOT be the first COMMIT/PUSH to $BRANCH."
echo "Request already stamped, will use update."
echo "If prompted to choose a review request to update refer to the"
echo "above URL for the proper request ID."
RB_UPDATE='-u' # For second and subsequent push, add "update" flag.
else
echo "This will be the first COMMIT/PUSH to $BRANCH. Will stamp
request."
RB_STAMP='-s'
fi
if [[ $ACTION == 'commit' ]]; then
echo "Enter Commit message, or <CR> to open editor for commit message."
read COMMIT_MESSAGE
if [[ $COMMIT_MESSAGE ]]; then
echo "Found a commit message."
echo "Will run \"git $* -m\"$COMMIT_MESSAGE\"\""
git $* -m"$COMMIT_MESSAGE"
else
echo "No commit message"
echo "Will run \"git $*\""
git $*
fi
elif [ $ACTION == 'push' ]]; then
git $*
fi
if [[ $3 ]]; then
echo "Will use tracking branch $3."
TRACKING_BRANCH="--tracking-branch $3"
fi
echo "rbt post $RB_STAMP $RB_UPDATE --guess-summary --guess-description
--branch $BRANCH $TRACKING_BRANCH"
rbt post $RB_STAMP $RB_UPDATE --guess-summary --guess-description --branch
$BRANCH $TRACKING_BRANCH
A general note about aliases and wrappers... 'git commit -m"message"' is no
longer a viable command because of the way that subprocess chops the
command line into an array, combined with the way that the shell eats
quotes. :( So, the user is prompted for a commit message, if they simply
hit enter they will be taken to an editor session to add the desired
message. Also, as noted in the thread linked above, it seems to be
impossible to set anything in the environment via the rc file.
This solution enables a couple of different workflows:
1. Create a diff for every commit, by always replacing "git commit" with
"rbt commit".
2. Create a diff only when pushing, by continuing to use "git commit" and
only using "rbt push" in place of "git push".
While this workflow might not work for everyone there may be concepts here
that will be useful for your workflow.
Again, I will update as this evolves.
--
Supercharge your Review Board with Power Pack:
https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons:
https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups
"reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.