Created
November 27, 2009 06:06
-
-
Save softcraft-development/243851 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Merges the current branch into the specified branch after checking out that branch. | |
# Usage: | |
# git merge-into [branch] | |
# [branch] defaults to "master" if not specified | |
# "sprint" is my convenience library for handling external processes. | |
# You can get it at http://github.com/softcraft-development/sprint and/or http://gemcutter.org/gems/sprint | |
# You can also replace it with a combination of back-ticks (``) and $? if you prefer. | |
require 'rubygems' | |
require 'sprint' | |
#grab the current branch name | |
branches = sprint "git branch --no-color" | |
match = /^ *\* *(.+)/.match(branches.to_s) | |
current_branch = match ? match[1] : nil | |
#target branch is the first argument to git-merge-into | |
target_branch = ARGV[0] || "master" | |
if current_branch | |
switch = sprint "git checkout #{target_branch}" | |
if switch.success? | |
merge = sprint "git merge #{current_branch}" | |
if merge.success? | |
puts "Merged #{current_branch} into #{target_branch}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment