Class: Hub::Context::Branch

Inherits:
Struct
  • Object
show all
Defined in:
lib/hub/context.rb

Instance Method Summary collapse

Instance Method Details

#master?Boolean

Returns:

  • (Boolean)


307
308
309
# File 'lib/hub/context.rb', line 307

def master?
  short_name == 'master'
end

#remote?Boolean

Returns:

  • (Boolean)


317
318
319
# File 'lib/hub/context.rb', line 317

def remote?
  name.index('refs/remotes/') == 0
end

#remote_nameObject



321
322
323
324
# File 'lib/hub/context.rb', line 321

def remote_name
  name =~ %r{^refs/remotes/([^/]+)} and $1 or
    raise Error, "can't get remote name from #{name.inspect}"
end

#short_nameObject



303
304
305
# File 'lib/hub/context.rb', line 303

def short_name
  name.sub(%r{^refs/(remotes/)?.+?/}, '')
end

#upstreamObject



311
312
313
314
315
# File 'lib/hub/context.rb', line 311

def upstream
  if branch = local_repo.git_command("rev-parse --symbolic-full-name #{short_name}@{upstream}")
    Branch.new local_repo, branch
  end
end