class JIRADiff::Git
Public Class Methods
new(dir = '.')
click to toggle source
# File lib/jira_diff/git.rb, line 6 def initialize(dir = '.') raise StandardError, "Directory '#{dir}' is not valid" unless Dir.exist?(dir) raise RuntimeError, "Doesn't look like '#{dir}' is a Git repository" unless Dir.exist?(File.join(dir, '.git')) @working_dir = dir end
Public Instance Methods
branch_valid?(branch)
click to toggle source
# File lib/jira_diff/git.rb, line 18 def branch_valid?(branch) run_command("\\git branch --all --list #{branch}").split("/n")[0] =~ /#{branch}/ end
log(branch)
click to toggle source
# File lib/jira_diff/git.rb, line 13 def log(branch) raise RuntimeError, "Invalid branch: #{branch}" unless branch_valid? branch run_command("\\git --no-pager log --no-merges --pretty='%H|%B\1' #{branch}").split("\1") end
Private Instance Methods
run_command(cmd)
click to toggle source
# File lib/jira_diff/git.rb, line 24 def run_command(cmd) Open3.popen3(cmd, chdir: @working_dir) do |_i, o, _e, _t| o.read end end