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.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/danger/ci_source/local_git_repo.rb', line 39

def initialize(env = {})
  @env = 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.



17
18
19
# File 'lib/danger/ci_source/local_git_repo.rb', line 17

def base_commit
  @base_commit
end

#head_commitObject

Returns the value of attribute head_commit.



17
18
19
# File 'lib/danger/ci_source/local_git_repo.rb', line 17

def head_commit
  @head_commit
end

Class Method Details

.validates_as_ci?(env) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.validates_as_pr?(_env) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/danger/ci_source/local_git_repo.rb', line 23

def self.validates_as_pr?(_env)
  false
end

Instance Method Details

#gitObject



27
28
29
# File 'lib/danger/ci_source/local_git_repo.rb', line 27

def git
  @git ||= GitRepo.new
end

#run_git(command) ⇒ Object



31
32
33
# File 'lib/danger/ci_source/local_git_repo.rb', line 31

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

#supported_request_sourcesObject



35
36
37
# File 'lib/danger/ci_source/local_git_repo.rb', line 35

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