Module: BranchDb::GitUtils

Included in:
Naming
Defined in:
lib/branch_db/git_utils.rb

Instance Method Summary collapse

Instance Method Details

#current_branchObject



3
4
5
6
7
8
# File 'lib/branch_db/git_utils.rb', line 3

def current_branch
  override = ENV.fetch("BRANCH_DB_BRANCH", nil)
  return override if override && !override.empty?

  `git symbolic-ref HEAD 2>/dev/null`.chomp.sub("refs/heads/", "")
end

#git_branchesObject



10
11
12
13
# File 'lib/branch_db/git_utils.rb', line 10

def git_branches
  output = `git branch --format='%(refname:short)' 2>/dev/null`
  output.split("\n").map(&:strip).reject(&:empty?)
end

#parent_branchObject



15
# File 'lib/branch_db/git_utils.rb', line 15

def parent_branch = @parent_branch ||= detect_parent_branch

#reset_parent_cache!Object



17
# File 'lib/branch_db/git_utils.rb', line 17

def reset_parent_cache! = @parent_branch = nil