Module: Avm::Git::Issue::Complete::LocalBranch

Defined in:
lib/avm/git/issue/complete/local_branch.rb

Instance Method Summary collapse

Instance Method Details

#branch_hash_resultObject



26
27
28
29
30
31
# File 'lib/avm/git/issue/complete/local_branch.rb', line 26

def branch_hash_result
  ::Avm::Result.success_or_error(
    branch_hash.present?,
    branch_hash
  )
end

#branch_hash_uncachedObject



14
15
16
# File 'lib/avm/git/issue/complete/local_branch.rb', line 14

def branch_hash_uncached
  @git.rev_parse("refs/heads/#{branch}")
end

#branch_nameObject



18
19
20
# File 'lib/avm/git/issue/complete/local_branch.rb', line 18

def branch_name
  branch.split('/')[-1]
end

#branch_name_resultObject



22
23
24
# File 'lib/avm/git/issue/complete/local_branch.rb', line 22

def branch_name_result
  ::Avm::Result.success_or_error(issue_id.present?, branch_name)
end

#branch_uncachedObject



10
11
12
# File 'lib/avm/git/issue/complete/local_branch.rb', line 10

def branch_uncached
  @git.current_branch
end

#follow_master?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/avm/git/issue/complete/local_branch.rb', line 40

def follow_master?
  remote_master_hash ? @git.descendant?(branch_hash, remote_master_hash) : true
end

#follow_master_resultObject



33
34
35
36
37
38
# File 'lib/avm/git/issue/complete/local_branch.rb', line 33

def follow_master_result
  return ::Avm::Result.neutral('No branch hash') unless branch_hash

  r = follow_master?
  ::Avm::Result.success_or_error(r, 'yes', 'no')
end

#remove_local_branchObject



44
45
46
47
48
49
# File 'lib/avm/git/issue/complete/local_branch.rb', line 44

def remove_local_branch
  info 'Removendo branch local...'
  bn = branch_name
  git(['checkout', branch_hash])
  git(['branch', '-D', bn])
end