Class: Danger::CISource::LocalGitRepo
- Defined in:
- lib/danger/ci_source/local_git_repo.rb
Instance Attribute Summary collapse
-
#base_commit ⇒ Object
Returns the value of attribute base_commit.
-
#head_commit ⇒ Object
Returns the value of attribute head_commit.
Attributes inherited from CI
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ LocalGitRepo
constructor
A new instance of LocalGitRepo.
Constructor Details
#initialize ⇒ LocalGitRepo
Returns a new instance of LocalGitRepo.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/danger/ci_source/local_git_repo.rb', line 15 def initialize(*) git = Git.open(".") if git.remote("origin") url = git.remote("origin").url # deal with https:// if url.start_with? "https://github.com/" self.repo_slug = url.gsub("https://github.com/", "").gsub(".git", '') # deal with SSH origin elsif url.start_with? "[email protected]:" self.repo_slug = url.gsub("[email protected]:", "").gsub(".git", '') end end logs = git.log.since('2 weeks ago') # Look for something like # "Merge pull request #38 from KrauseFx/funky_circles\n\nAdd support for GitHub compare URLs that don't conform pr_merge = logs.detect { |log| (/Merge pull request #[0-9]* from/ =~ log.) == 0 } if pr_merge # then pull out the 38, to_i self.pull_request_id = pr_merge..gsub("Merge pull request #", "").to_i self.base_commit = pr_merge.parents[0].sha self.head_commit = pr_merge.parents[1].sha end end |
Instance Attribute Details
#base_commit ⇒ Object
Returns the value of attribute base_commit.
9 10 11 |
# File 'lib/danger/ci_source/local_git_repo.rb', line 9 def base_commit @base_commit end |
#head_commit ⇒ Object
Returns the value of attribute head_commit.
9 10 11 |
# File 'lib/danger/ci_source/local_git_repo.rb', line 9 def head_commit @head_commit end |
Class Method Details
.validates?(env) ⇒ Boolean
11 12 13 |
# File 'lib/danger/ci_source/local_git_repo.rb', line 11 def self.validates?(env) return !env["DANGER_USE_LOCAL_GIT"].nil? end |