Class: JIRADiff::Git
- Inherits:
-
Object
- Object
- JIRADiff::Git
- Defined in:
- lib/jira_diff/git.rb
Instance Method Summary collapse
- #branch_valid?(branch) ⇒ Boolean
-
#initialize(dir = '.') ⇒ Git
constructor
A new instance of Git.
- #log(branch) ⇒ Object
Constructor Details
#initialize(dir = '.') ⇒ Git
Returns a new instance of Git.
6 7 8 9 10 11 |
# 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 |
Instance Method Details
#branch_valid?(branch) ⇒ Boolean
18 19 20 |
# 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) ⇒ Object
13 14 15 16 |
# 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 |