Class: Danger::LocalGitRepo
- Inherits:
-
CI
- Object
- CI
- Danger::LocalGitRepo
show all
- Defined in:
- lib/danger/ci_source/local_git_repo.rb
Instance Attribute Summary collapse
Attributes inherited from CI
#pull_request_id, #repo_slug, #repo_url
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from CI
available_ci_sources, inherited, #supports?
Constructor Details
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/danger/ci_source/local_git_repo.rb', line 46
def initialize(env = {})
@remote_info = find_remote_info(env)
@found_pull_request = find_pull_request(env)
self.repo_slug = remote_info.slug
raise_error_for_missing_remote if remote_info.kind_of?(NoRepoInfo)
self.pull_request_id = found_pull_request.pull_request_id
if sha
self.base_commit = commits.base
self.head_commit = commits.head
else
self.base_commit = found_pull_request.base
self.head_commit = found_pull_request.head
end
end
|
Instance Attribute Details
#base_commit ⇒ Object
Returns the value of attribute base_commit.
18
19
20
|
# File 'lib/danger/ci_source/local_git_repo.rb', line 18
def base_commit
@base_commit
end
|
#head_commit ⇒ Object
Returns the value of attribute head_commit.
18
19
20
|
# File 'lib/danger/ci_source/local_git_repo.rb', line 18
def head_commit
@head_commit
end
|
Class Method Details
.validates_as_ci?(env) ⇒ Boolean
20
21
22
|
# File 'lib/danger/ci_source/local_git_repo.rb', line 20
def self.validates_as_ci?(env)
env.key? "DANGER_USE_LOCAL_GIT"
end
|
.validates_as_pr?(_env) ⇒ Boolean
24
25
26
|
# File 'lib/danger/ci_source/local_git_repo.rb', line 24
def self.validates_as_pr?(_env)
false
end
|
Instance Method Details
#git ⇒ Object
28
29
30
|
# File 'lib/danger/ci_source/local_git_repo.rb', line 28
def git
@git ||= GitRepo.new
end
|
#run_git(command) ⇒ Object
32
33
34
|
# File 'lib/danger/ci_source/local_git_repo.rb', line 32
def run_git(command)
git.exec(command).encode("UTF-8", "binary", invalid: :replace, undef: :replace, replace: "")
end
|
#supported_request_sources ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/danger/ci_source/local_git_repo.rb', line 36
def supported_request_sources
@supported_request_sources ||= [
Danger::RequestSources::GitHub,
Danger::RequestSources::BitbucketServer,
Danger::RequestSources::BitbucketCloud,
Danger::RequestSources::VSTS,
Danger::RequestSources::GitLab
]
end
|