lib/braid/operations.rb in evilchelu-braid-0.3.7 vs lib/braid/operations.rb in evilchelu-braid-0.3.8

- old
+ new

@@ -71,10 +71,15 @@ def git_rm_r(path) exec!("git rm -r #{path}") true end + + def local_changes? + status, out, err = exec("git status") + out.split("\n").grep(/nothing to commit \(working directory clean\)/).empty? + end end module Svn # FIXME move def svn_remote_head_revision(path) @@ -107,9 +112,35 @@ module Helpers [:invoke, :exec, :exec!].each do |method| define_method(method) do |*args| Braid::Operations.send(method, *args) end + end + + def extract_git_version + status, out, err = exec!("git --version") + return out.sub(/^git version/, "").strip + end + + def verify_git_version(required) + required_version = required.split(".") + actual_version = extract_git_version.split(".") + actual_version.each_with_index do |actual_piece, idx| + required_piece = required_version[idx] + + return true unless required_piece + + case (actual_piece <=> required_piece) + when -1 + return false + when 1 + return true + when 0 + next + end + end + + return actual_version.length >= required_version.length end def find_git_revision(commit) invoke(:git_rev_parse, commit) rescue Braid::Commands::ShellExecutionError