-
-
Save sprsquish/259124 to your computer and use it in GitHub Desktop.
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 mark [character] [branch] | |
# | |
# Marks a branch with an arbitrary character | |
# | |
# Examples: | |
# $ git mark # removes any mark on the current branch | |
# $ git mark r # marks the current branch with "r" | |
# $ git mark r topic-1 # marks the "topic-1" branch with "r" | |
# | |
case ARGV.size | |
when 0 then mark = nil | |
when 1 then mark, branch, _ = ARGV | |
else branch, mark, _ = ARGV | |
end | |
branch ||= `git name-rev HEAD`.chomp.sub('HEAD ', '') # current branch | |
if mark | |
`git config branch.#{branch}.peer-review #{mark}` | |
puts "Marked '#{branch}' with '#{mark}'." | |
else | |
`git config --unset branch.#{branch}.peer-review` | |
puts "Removed mark on '#{branch}'." | |
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 rbranch [args] | |
# | |
# Marked branches will be prefixed with their corresponding mark | |
# | |
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, $' | |
mark = `git config branch.#{branch}.peer-review`.strip | |
prefix = mark == '' ? ' ' : "#{mark} " | |
puts prefix + branch + rest | |
else | |
puts line | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment