Class: Danger::LocalOnlyGitRepo
- Defined in:
- lib/danger/ci_source/local_only_git_repo.rb
Overview
### CI Setup
For setting up LocalOnlyGitRepo there is not much needed. Either ‘–base` and `–head` need to be specified or origin/master is expected for base and HEAD for head
Constant Summary collapse
- HEAD_VAR =
"DANGER_LOCAL_HEAD".freeze
- BASE_VAR =
"DANGER_LOCAL_BASE".freeze
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
#pull_request_id, #repo_slug, #repo_url
Class Method Summary collapse
Instance Method Summary collapse
- #git ⇒ Object
-
#initialize(env = {}) ⇒ LocalOnlyGitRepo
constructor
A new instance of LocalOnlyGitRepo.
- #run_git(command) ⇒ Object
- #supported_request_sources ⇒ Object
Methods inherited from CI
available_ci_sources, inherited, #supports?
Constructor Details
#initialize(env = {}) ⇒ LocalOnlyGitRepo
Returns a new instance of LocalOnlyGitRepo.
35 36 37 38 39 40 41 |
# File 'lib/danger/ci_source/local_only_git_repo.rb', line 35 def initialize(env = {}) @env = env # expects --base/--head specified OR origin/master to be base and HEAD head self.base_commit = env[BASE_VAR] || run_git("rev-parse --abbrev-ref origin/master") self.head_commit = env[HEAD_VAR] || run_git("rev-parse --abbrev-ref HEAD") end |
Instance Attribute Details
#base_commit ⇒ Object
Returns the value of attribute base_commit.
11 12 13 |
# File 'lib/danger/ci_source/local_only_git_repo.rb', line 11 def base_commit @base_commit end |
#head_commit ⇒ Object
Returns the value of attribute head_commit.
11 12 13 |
# File 'lib/danger/ci_source/local_only_git_repo.rb', line 11 def head_commit @head_commit end |
Class Method Details
.validates_as_ci?(env) ⇒ Boolean
15 16 17 |
# File 'lib/danger/ci_source/local_only_git_repo.rb', line 15 def self.validates_as_ci?(env) env.key? "DANGER_USE_LOCAL_ONLY_GIT" end |
.validates_as_pr?(_env) ⇒ Boolean
19 20 21 |
# File 'lib/danger/ci_source/local_only_git_repo.rb', line 19 def self.validates_as_pr?(_env) false end |
Instance Method Details
#git ⇒ Object
23 24 25 |
# File 'lib/danger/ci_source/local_only_git_repo.rb', line 23 def git @git ||= GitRepo.new end |
#run_git(command) ⇒ Object
27 28 29 |
# File 'lib/danger/ci_source/local_only_git_repo.rb', line 27 def run_git(command) git.exec(command).encode("UTF-8", "binary", invalid: :replace, undef: :replace, replace: "") end |
#supported_request_sources ⇒ Object
31 32 33 |
# File 'lib/danger/ci_source/local_only_git_repo.rb', line 31 def supported_request_sources @supported_request_sources ||= [Danger::RequestSources::LocalOnly] end |