Class: BuPr::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/bu_pr/git.rb

Constant Summary collapse

LOCKFILE =
"Gemfile.lock"

Instance Method Summary collapse

Instance Method Details

#current_branchString

Returns:

  • (String)


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bu_pr/git.rb', line 8

def current_branch
  @current_branch ||=
    begin
      branches.each_line do |line|
        matched = line.strip.match(/\*\s+(?<current_branch>.+)/)
        next unless matched

        break matched["current_branch"]
      end
    end
end

#diff?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/bu_pr/git.rb', line 21

def diff?
  `git status`.include? LOCKFILE
end

#installed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/bu_pr/git.rb', line 26

def installed?
  system "git --help > /dev/null 2>&1"
end

#pushObject



30
31
32
# File 'lib/bu_pr/git.rb', line 30

def push
  add && commit && _push
end