Created
January 8, 2009 21:16
-
-
Save neilmock/44886 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
namespace :fogbugz do | |
# Usage: | |
# | |
# sake fogbugz:branch[source_branch, "My Project"] | |
# | |
# | |
desc "Setup a branch for each case assigned to me." | |
task :branch, [:target_branch, :project] do |t, args| | |
require 'fogbugz-api' | |
require 'git' | |
# assume CWD | |
g = Git.open('.') | |
g.checkout(args.target_branch) | |
fb = FogBugz.new("you.fogbugz.com",true) | |
fb.logon("you@you.com","youpw") | |
search = "AssignedTo:\"Thats You\"" | |
search += " AND Project:\"#{args.project}\"" unless args.project.nil? | |
mycases = fb.search(search) | |
mycases.each_key do |case_id| | |
g.branch(case_id).create | |
end | |
fb.logoff | |
end | |
# Usage: | |
# | |
# sake fogbugz:resolve[12345, customer_portal] | |
# | |
desc "Resolve a case. sake fogbugz:resolve[12345, my_branch]." | |
task :resolve, [:target_case, :target_branch] do |t, args| | |
require 'fogbugz-api' | |
require 'git' | |
# assume CWD + current branch | |
g = Git.open('.') | |
case_branch = g.current_branch | |
args.with_defaults(:target_case => case_branch) | |
# hack | |
# pulls any changes that may have occurred to your target branch | |
# while you were working and rebases changes into your topic branch | |
args.with_defaults(:target_branch => "master") | |
`git checkout #{args.target_branch}` | |
`git pull origin #{args.target_branch}` | |
`git checkout #{args.target_case}` | |
`git rebase #{args.target_branch}` | |
# ship | |
# merges your changes into target branch and pushes target | |
`git checkout #{args.target_branch}` | |
`git merge #{args.target_case}` | |
`git push origin #{args.target_branch}` | |
# `git branch -d #{args.target_case}` | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment