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)


292
293
294
# File 'lib/hub/context.rb', line 292

def master?
  short_name == 'master'
end

#remote?Boolean

Returns:

  • (Boolean)


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

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

#remote_nameObject



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

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

#short_nameObject



288
289
290
# File 'lib/hub/context.rb', line 288

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

#upstreamObject



296
297
298
299
300
# File 'lib/hub/context.rb', line 296

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