module Dronejob::Modules::Git
Public Instance Methods
git_clean()
click to toggle source
# File lib/dronejob/modules/git.rb, line 54 def git_clean @git.clean(force: true, d: true) end
git_collect_commits()
click to toggle source
# File lib/dronejob/modules/git.rb, line 43 def git_collect_commits @commits = {} begin @git.log(100).each do |c| @commits[c.message] = c.to_s end rescue StandardError # skip if log does not yet exist end end
git_commit(commit)
click to toggle source
# File lib/dronejob/modules/git.rb, line 33 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)
click to toggle source
# File lib/dronejob/modules/git.rb, line 29 def git_init(path) @git = ::Git.init(path) end
git_init_job()
click to toggle source
# File lib/dronejob/modules/git.rb, line 66 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)
click to toggle source
# File lib/dronejob/modules/git.rb, line 58 def git_reset(commit = nil) if commit @git.reset_hard(@commits[commit]) else @git.reset_hard end end
stateful(value = true)
click to toggle source
# File lib/dronejob/modules/git.rb, line 16 def stateful(value = true) @stateful = value end
stateful?()
click to toggle source
# File lib/dronejob/modules/git.rb, line 20 def stateful? !!@stateful end