Class: Danger::LocalGitRepo

Inherits:
CI
  • Object
show all
Defined in:
lib/danger/ci_source/local_git_repo.rb

Overview

ignore

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

#initialize(env = {}) ⇒ LocalGitRepo

Returns a new instance of LocalGitRepo.



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_commitObject

Returns the value of attribute base_commit.



19
20
21
# File 'lib/danger/ci_source/local_git_repo.rb', line 19

def base_commit
  @base_commit
end

#head_commitObject

Returns the value of attribute head_commit.



19
20
21
# File 'lib/danger/ci_source/local_git_repo.rb', line 19

def head_commit
  @head_commit
end

Class Method Details

.validates_as_ci?(env) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/danger/ci_source/local_git_repo.rb', line 21

def self.validates_as_ci?(env)
  env.key? "DANGER_USE_LOCAL_GIT"
end

.validates_as_pr?(_env) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/danger/ci_source/local_git_repo.rb', line 25

def self.validates_as_pr?(_env)
  false
end

Instance Method Details

#gitObject



29
30
31
# File 'lib/danger/ci_source/local_git_repo.rb', line 29

def git
  @git ||= GitRepo.new
end

#run_git(command) ⇒ Object



33
34
35
# File 'lib/danger/ci_source/local_git_repo.rb', line 33

def run_git(command)
  git.exec(command).encode("UTF-8", "binary", invalid: :replace, undef: :replace, replace: "")
end

#supported_request_sourcesObject



37
38
39
40
41
42
43
44
# File 'lib/danger/ci_source/local_git_repo.rb', line 37

def supported_request_sources
  @supported_request_sources ||= [
    Danger::RequestSources::GitHub,
    Danger::RequestSources::BitbucketServer,
    Danger::RequestSources::BitbucketCloud,
    Danger::RequestSources::VSTS
  ]
end