lib/git_topic/naming.rb in git-topic-0.2.4.1 vs lib/git_topic/naming.rb in git-topic-0.2.5

- old
+ new

@@ -27,11 +27,23 @@ def remote_rejected_branch( topic, user=user ) "rejected/#{user}/#{strip_namespace topic}" end + def remote_branch( spec=current_branch ) + parts = topic_parts( spec ) + remote_branches.find do |remote_branch| + bp = topic_parts( remote_branch ) + + parts.all? do |part, value| + bp[part] == value + end + end + end + + def find_remote_review_branch( topic ) others_review_branches.find{|b| b.index topic} end def strip_namespace( ref ) @@ -55,11 +67,14 @@ end def topic_parts( ref, opts={} ) p = {} parts = ref.split( '/' ) + + parts.shift if parts.first == 'remotes' parts.shift if parts.first == "origin" + case parts.size when 3 p[:namespace], p[:user], p[:topic] = parts when 2 first_part = (parts.first =~ /(wip|review|rejected)/) ? :namespace : :user @@ -96,15 +111,9 @@ end def current_topic current_branch =~ %r{wip/\S*?/(\S*)} $1 - end - - def current_branch - @@current_branch ||= capture_git( "branch --no-color" ).split( "\n" ).find do |b| - b =~ %r{^\*} - end[ 2..-1 ] end def branches @@branches ||= capture_git( "branch --no-color" ).split( "\n" ).map{|b| b[2..-1]} end