Created
September 12, 2013 14:45
-
-
Save cgreening/6538660 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 | |
require 'rubygems' | |
require 'json' | |
require 'net/https' | |
require 'uri' | |
if ARGV.length != 2 | |
puts "Usage: makeBranch.rb SPRINT_NUMBER PT_ID" | |
else | |
urlString = 'https://www.pivotaltracker.com/services/v5/stories/'+ARGV[1] | |
puts urlString | |
uri = URI.parse(urlString) | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
request = Net::HTTP::Get.new(uri.request_uri) | |
request.add_field("X-TrackerToken", "YOUR_TOKEN_HERE") | |
response = http.request(request) | |
json = JSON.parse(response.body) | |
storyName = json['name'] | |
if storyName != nil | |
storyName = storyName.gsub(/[^0-9a-z]/i, '-') | |
branchName = "PT-"+ARGV[1]+"-"+storyName | |
gitCommand = "git checkout -b Sprint-"+ARGV[0] + "/" + branchName | |
puts "Will execute '#{gitCommand}'" | |
puts "y/n?" | |
yesNo = STDIN.gets.chomp() | |
if yesNo.downcase[0,1]=='y' | |
exec gitCommand | |
else | |
puts "Abandon ship!" | |
end | |
else | |
puts "Couldn't find that story in pivotal tracker!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment