Module: Dronejob::Modules::Git
Instance Method Summary collapse
- #git_clean ⇒ Object
- #git_collect_commits ⇒ Object
- #git_commit(commit) ⇒ Object
- #git_init(path) ⇒ Object
- #git_init_job ⇒ Object
- #git_reset(commit = nil) ⇒ Object
- #stateful? ⇒ Boolean
Instance Method Details
#git_clean ⇒ Object
53 54 55 |
# File 'lib/dronejob/modules/git.rb', line 53 def git_clean @git.clean(force: true, d: true) end |
#git_collect_commits ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dronejob/modules/git.rb', line 42 def git_collect_commits @commits = {} begin @git.log(100).each do |c| @commits[c.] = c.to_s end rescue StandardError # skip if log does not yet exist end end |
#git_commit(commit) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/dronejob/modules/git.rb', line 32 def git_commit(commit) unless @commits.keys.include?(commit.to_s) save_variables @git.add(all: true, force: true) @git.commit(commit.to_s, allow_empty: true) commit = @git.log(1).last @commits[commit] = commit.to_s end end |
#git_init(path) ⇒ Object
28 29 30 |
# File 'lib/dronejob/modules/git.rb', line 28 def git_init(path) @git = ::Git.init(path) end |
#git_init_job ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/dronejob/modules/git.rb', line 65 def git_init_job if self.class.stateful? load_variables git_init(@working_dir.to_s) git_collect_commits git_commit("start") if param(:from) == "start" info("starting from scratch") git_reset("start") elsif param(:from) info("starting from phase #{param(:from)}") phase = prev_phase(param(:from)) raise("phase '#{param(:from)}' not found!") if phase.nil? or @commits[phase.to_s].nil? git_reset(phase.to_s) else git_reset end git_collect_commits git_clean end end |
#git_reset(commit = nil) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/dronejob/modules/git.rb', line 57 def git_reset(commit = nil) if commit @git.reset_hard(@commits[commit]) else @git.reset_hard end end |
#stateful? ⇒ Boolean
24 25 26 |
# File 'lib/dronejob/modules/git.rb', line 24 def stateful? self.class.stateful? end |