Class: GitStatistics::Branches

Inherits:
Object
  • Object
show all
Defined in:
lib/git_statistics/branches.rb

Constant Summary collapse

CURRENT_BRANCH =
/\A\*\s/
NO_BRANCH =
/no branch/i

Class Method Summary collapse

Class Method Details

.allObject



7
8
9
# File 'lib/git_statistics/branches.rb', line 7

def self.all
  list.collect { |branch| branch.sub(CURRENT_BRANCH, "") }
end

.currentObject



11
12
13
14
# File 'lib/git_statistics/branches.rb', line 11

def self.current
  return '(none)' if detached?
  list.detect { |branch| branch =~ CURRENT_BRANCH }.sub(CURRENT_BRANCH, "")
end

.detached?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/git_statistics/branches.rb', line 16

def self.detached?
  stripped.grep(NO_BRANCH).any?
end