Class: GitCoauthor::Git

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

Class Method Summary collapse

Class Method Details

.amend_commit_message(message) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/git_coauthor/git.rb', line 13

def self.amend_commit_message(message)
  Open3.popen2('git commit --amend --only --no-verify --file -') do |stdin, _, wait_thr|
    stdin.puts(message)
    stdin.close
    wait_thr.value.success?
  end
end

.commit_message(sha) ⇒ Object



8
9
10
11
# File 'lib/git_coauthor/git.rb', line 8

def self.commit_message(sha)
  message = `git log --format="%B" --max-count=1 #{sha} 2> /dev/null`
  [$CHILD_STATUS.success?, message]
end

.config_get(key) ⇒ Object



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

def self.config_get(key)
  value = `git config #{key} 2> /dev/null`.strip
  [$CHILD_STATUS.success?, value]
end

.config_set(key, value) ⇒ Object



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

def self.config_set(key, value)
  `git config #{key} #{value} 2> /dev/null`
  $CHILD_STATUS.success?
end

.config_unset(key) ⇒ Object



31
32
33
34
# File 'lib/git_coauthor/git.rb', line 31

def self.config_unset(key)
  `git config --unset #{key} 2> /dev/null`
  $CHILD_STATUS.success?
end