# File lib/hub/context.rb, line 350 def master? master_name = if local_repo then local_repo.master_branch.short_name else 'master' end short_name == master_name end
# File lib/hub/context.rb, line 363 def push_target(owner_name, prefer_upstream = false) push_default = local_repo.git_config('push.default') if %w[upstream tracking].include?(push_default) upstream else short = short_name refs = local_repo.remotes_for_publish(owner_name).map { |remote| "refs/remotes/#{remote}/#{short}" } refs.reverse! if prefer_upstream if branch = refs.detect {|ref| local_repo.file_exist?(ref) } Branch.new(local_repo, branch) end end end
# File lib/hub/context.rb, line 379 def remote? name.index('refs/remotes/') == 0 end
# File lib/hub/context.rb, line 383 def remote_name name =~ %r{^refs/remotes/([^/]+)} and $1 or raise Error, "can't get remote name from #{name.inspect}" end
# File lib/hub/context.rb, line 346 def short_name name.sub(%r{^refs/(remotes/)?.+?/}, '') end
# File lib/hub/context.rb, line 357 def upstream if branch = local_repo.git_command("rev-parse --symbolic-full-name #{short_name}@{upstream}") Branch.new local_repo, branch end end