Skip to content
Browse files

Show merged and unmeregd branches for "list" command

  • Loading branch information...
1 parent fe860cc commit 097b6669addcabba68e9832f58c14ed42f5e2fed @danielbeardsley danielbeardsley committed Feb 20, 2012
Showing with 40 additions and 16 deletions.
  1. +7 −1 feature.rb
  2. +26 −14 git.rb
  3. +7 −1 hotfix.rb
View
8 feature.rb
@@ -47,7 +47,13 @@
when 'list'
- Git.show_branch_list(:feature, Git::feature_branches)
+ options = {
+ :feature => Git::feature_branches(:unmerged)
+ }
+ if ARGV.include?('-v')
+ options[:merged] = Git::feature_branches(:merged)
+ end
+ Git.show_branch_list(options)
when 'stashes'
current = Git::current_branch
View
40 git.rb
@@ -10,15 +10,25 @@ def self.branches_not_merged_into(branch)
end
# Returns an array of unmerged hotfix branches
- def self.hotfix_branches()
- self.branches_not_merged_into('stable').
- select {|branch| branch.start_with?('hotfix-') }
+ def self.hotfix_branches(type)
+ branches = if type == :unmerged
+ self.branches_not_merged_into('stable')
+ elsif type == :merged
+ self.merged_branches('stable')
+ end
+
+ branches.select {|branch| branch.start_with?('hotfix-') }
end
# Returns an array of unmerged feature branches
- def self.feature_branches()
- self.branches_not_merged_into('master').
- reject {|branch| branch.start_with?('hotfix-') }
+ def self.feature_branches(type)
+ branches = if type == :unmerged
+ self.branches_not_merged_into('master')
+ elsif type == :merged
+ self.merged_branches('master')
+ end
+
+ branches.reject {|branch| branch.start_with?('hotfix-') }
end
# Returns an array of all branch names that have have been merged into the
@@ -71,7 +81,7 @@ def self.show_stashes_saved_on(branch)
end
end
- def self.show_branch_list(branch_type, branches)
+ def self.show_branch_list(options = {})
puts "\nCurrent Branch:"
puts "--" * 30
current = Git::current_branch
@@ -83,14 +93,16 @@ def self.show_branch_list(branch_type, branches)
end
puts HIGHLIGHT_OFF
- puts "\nAvailable #{branch_type} branches:"
- puts "--" * 30
- if branches && !branches.empty?
- branches.each do |branch|
- puts Git::branch_info(branch)
+ options.each do |branch_type, branches|
+ puts "\nAvailable #{branch_type} branches:"
+ puts "--" * 30
+ if branches && !branches.empty?
+ branches.each do |branch|
+ puts Git::branch_info(branch)
+ end
+ else
+ puts "(none)"
end
- else
- puts "(none)"
end
end
View
8 hotfix.rb
@@ -55,5 +55,11 @@
puts "Successfully merged hotfix branch: #{hotfix} into stable and master"
when 'list'
- Git.show_branch_list(:hotfix, Git::hotfix_branches)
+ options = {
+ :hotfix => Git::hotfix_branches(:unmerged)
+ }
+ if ARGV.include?('-v')
+ options[:merged] = Git::hotfix_branches(:merged)
+ end
+ Git.show_branch_list(options)
end

0 comments on commit 097b666

Please sign in to comment.
Something went wrong with that request. Please try again.