-
-
Save mislav/259113 to your computer and use it in GitHub Desktop.
git workflow with peer review on topic branches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
so my workflow is that each ticket gets a branch. Before merging the branch to master | |
it needs to be peer-reviewed. So sometimes I have a bunch of branches that are off | |
being reviewed while I work on something else. | |
Currently when I run "git branch" I see: | |
[branch 1] | |
[branch 2] | |
[branch 3] | |
*[branch 4] | |
[branch 5] | |
So in the case where [branch 1] and [branch 2] are in review I want to be able to mark | |
them as such. So that I see: | |
-[branch 1] | |
-[branch 2] | |
[branch 3] | |
*[branch 4] | |
[branch 5] | |
That way I have a quick overview of the state of each branch I'm working on. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
# Usage: | |
# $ git rbranch [args] | |
# | |
# Branches with peer review in progress are rendered with '-' prefix. | |
# | |
args = ARGV.dup | |
args << '--color' unless args.include?('--no-color') | |
`git branch #{args.join(' ')}`.split("\n").each do |line| | |
if line =~ /^ ([\w-]+)/ | |
branch, rest = $1, $' | |
`git config --bool branch.#{branch}.peer-review` | |
prefix = $?.success?? '- ' : ' ' | |
puts prefix + branch + rest | |
else | |
puts line | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
# Usage: | |
# $ git review [action] [branch] | |
# | |
# Action defaults to "start" and branch to current branch. | |
# | |
# Examples: | |
# $ git review | |
# $ git review end | |
# $ git review start topic-1 | |
# $ git review end topic-1 | |
# | |
action, branch = ARGV | |
action ||= 'start' | |
branch ||= `git name-rev HEAD`.chomp.sub('HEAD ', '') # current branch | |
case action | |
when 'start' | |
`git config --bool branch.#{branch}.peer-review true` | |
puts "Marked '#{branch}' for peer review." | |
when 'end' | |
`git config --unset branch.#{branch}.peer-review` | |
puts "Peer review is done on '#{branch}'." | |
else | |
$stderr.puts "unknown action #{action}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment