2 MINIMUM_VERSION = [1, 5, 3]
5 File.directory?(dir) and File.directory?(File.join(dir, ".git"))
9 `git branch | grep "*"`.strip[2..-1]
13 v = `git version`.scan(/version (\d+).(\d+).(\d+)/).flatten.map { |s| s.to_i }
16 (v <=> MINIMUM_VERSION) >= 0
20 raise "Invalid git version, use at least #{MINIMUM_VERSION.join(".")}" unless
26 switch = if branch != "master" then
28 puts "* Switching back to master..."
35 puts "* Porting changes into #{branch}..."
36 `git checkout #{branch}`
37 sh "git rebase master"
42 `git diff-files --quiet`
43 if $?.exitstatus == 1 then
53 stash = with_git_changes do
54 clear = `git stash list`.scan("\n").size == 0
55 puts "* Saving changes..."
61 puts "* Pulling in new commits..."
63 sh "git rebase origin"
67 puts "* Applying changes..."
69 `git stash clear` if clear
77 abort "You have outstanding changes. Please commit them first."
78 end if branch != "master"
81 puts "* Merging topic '#{branch}' back into master..."
82 sh "git merge #{branch}"
83 puts "* Pushing changes..."