Class: Dependabot::Workspace::Git
- Inherits:
-
Base
- Object
- Base
- Dependabot::Workspace::Git
show all
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/dependabot/workspace/git.rb
Constant Summary
collapse
- USER =
"dependabot[bot]"
- EMAIL =
T.let("#{USER}@users.noreply.github.com".freeze, String)
Instance Attribute Summary collapse
Attributes inherited from Base
#change_attempts, #path
Instance Method Summary
collapse
Methods inherited from Base
#change, #changes, #failed_change_attempts
Constructor Details
#initialize(path) ⇒ Git
Returns a new instance of Git.
21
22
23
24
25
|
# File 'lib/dependabot/workspace/git.rb', line 21
def initialize(path)
super
@initial_head_sha = T.let(head_sha, String)
configure_git
end
|
Instance Attribute Details
#initial_head_sha ⇒ Object
Returns the value of attribute initial_head_sha.
18
19
20
|
# File 'lib/dependabot/workspace/git.rb', line 18
def initial_head_sha
@initial_head_sha
end
|
Instance Method Details
#changed? ⇒ Boolean
28
29
30
|
# File 'lib/dependabot/workspace/git.rb', line 28
def changed?
changes.any? || !changed_files(ignored_mode: "no").empty?
end
|
#reset! ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/dependabot/workspace/git.rb', line 41
def reset!
reset(initial_head_sha)
clean
run_shell_command("git stash clear")
@change_attempts = []
nil
end
|
#store_change(memo = nil) ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/dependabot/workspace/git.rb', line 55
def store_change(memo = nil)
return nil if changed_files(ignored_mode: "no").empty?
debug("store_change - before: #{current_commit}")
sha, diff = commit(memo)
change_attempts << ChangeAttempt.new(self, id: sha, memo: memo, diff: diff)
ensure
debug("store_change - after: #{current_commit}")
end
|
#to_patch ⇒ Object
33
34
35
36
37
38
|
# File 'lib/dependabot/workspace/git.rb', line 33
def to_patch
run_shell_command(
"git diff --patch #{@initial_head_sha}.. .",
fingerprint: "git diff --path <initial_head_sha>.. ."
)
end
|