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

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

Constant Summary collapse

NO_CURRENT_BRANCH_NAME =
'none'

Instance Method Summary collapse

Instance Method Details

#branch_hash_resultObject



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

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

#branch_hash_uncachedObject



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

def branch_hash_uncached
  branch.if_present(&:current_commit_id)
end

#branch_nameObject



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

def branch_name
  branch.if_present(NO_CURRENT_BRANCH_NAME, &:name)
end

#branch_name_resultObject



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

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

#branch_uncachedEacGit::Local::Branch?

Retrieves the current local branch.

Returns:

  • (EacGit::Local::Branch, nil)


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

def branch_uncached
  eac_git.current_branch
end

#follow_master?Boolean

Returns:

  • (Boolean)


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

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

#follow_master_resultObject



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

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



49
50
51
52
53
54
55
56
# File 'lib/avm/git/issue/complete/local_branch.rb', line 49

def remove_local_branch
  return unless branch

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