Class: Danger::GitRepo
- Inherits:
-
Object
- Object
- Danger::GitRepo
- Defined in:
- lib/danger/scm_source/git_repo.rb
Instance Attribute Summary collapse
-
#diff ⇒ Object
Returns the value of attribute diff.
-
#log ⇒ Object
Returns the value of attribute log.
Instance Method Summary collapse
- #diff_for_folder(folder, from: "master", to: "HEAD") ⇒ Object
- #exec(string) ⇒ Object
- #head_commit ⇒ Object
- #origins ⇒ Object
Instance Attribute Details
#diff ⇒ Object
Returns the value of attribute diff.
7 8 9 |
# File 'lib/danger/scm_source/git_repo.rb', line 7 def diff @diff end |
#log ⇒ Object
Returns the value of attribute log.
7 8 9 |
# File 'lib/danger/scm_source/git_repo.rb', line 7 def log @log end |
Instance Method Details
#diff_for_folder(folder, from: "master", to: "HEAD") ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/danger/scm_source/git_repo.rb', line 9 def diff_for_folder(folder, from: "master", to: "HEAD") repo = Git.open folder merge_base = repo.merge_base(from, to) self.diff = repo.diff(merge_base.to_s, to) self.log = repo.log.between(from, to) end |
#exec(string) ⇒ Object
17 18 19 |
# File 'lib/danger/scm_source/git_repo.rb', line 17 def exec(string) `git #{string}`.strip end |
#head_commit ⇒ Object
21 22 23 |
# File 'lib/danger/scm_source/git_repo.rb', line 21 def head_commit exec "rev-parse HEAD" end |
#origins ⇒ Object
25 26 27 |
# File 'lib/danger/scm_source/git_repo.rb', line 25 def origins exec("remote show origin -n").lines.grep(/Fetch URL/)[0].split(": ", 2)[1].chomp end |