git-whistles 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -66,7 +66,7 @@ This lets you keep work in progress on multiple branches without committing it.
66
66
  I tend to alias this to `git co`.
67
67
 
68
68
 
69
- ## outstanding-features
69
+ #### outstanding-features
70
70
 
71
71
  `git checkout production ; git outstanding-features`
72
72
 
data/bin/git-pull-request CHANGED
@@ -4,6 +4,9 @@
4
4
  #
5
5
  # Open a pull request for the current branch in your default browser
6
6
  #
7
+ # Assumes the branches are named
8
+ # <team>/<branch-title>-<story-id>
9
+ #
7
10
  # Copyright (C) 2012 Julien Letessier
8
11
  #
9
12
  # Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -24,7 +27,10 @@
24
27
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
28
  # SOFTWARE.
26
29
  #
27
- require 'CGI'
30
+ # require 'CGI'
31
+ require 'rubygems'
32
+ require 'pivotal-tracker'
33
+ require 'term/ansicolor'
28
34
 
29
35
  origin_url = `git config --get remote.origin.url`.strip
30
36
  unless origin_url =~ /github\.com/
@@ -48,6 +54,61 @@ end
48
54
 
49
55
  against = ARGV[1] || 'master'
50
56
 
51
- url = "https://github.com/#{repo}/pull/new?base_repo=#{CGI.escape(repo)}&base_ref=#{against}&head_ref=#{branch}"
57
+ # build the base query
58
+ query = {
59
+ :base_repo => repo,
60
+ :base_ref => against,
61
+ :head_ref => branch
62
+ }
63
+
64
+ # guess team name
65
+ if branch =~ %r{^(\w+)/.*}
66
+ team = $1.capitalize
67
+ end
68
+
69
+ # guess title.
70
+ title = branch.split('/').last.split(/[_-]/).delete_if { |word| word =~ /^\d+$/ }.join(' ').capitalize
71
+ query[:title] = "#{team}: #{title}"
72
+
73
+ # find the PT story, or fall back to the branch-name-based titling
74
+ if branch =~ /(\d+)$/
75
+ story_id = $1.to_i
76
+ token = `git config pivotal-tracker.token`.strip
77
+ if token.empty?
78
+ puts Term::ANSIColor.yellow %Q{
79
+ I don't know your Pivotal Tracker token!
80
+ Please set it with:
81
+ $ git config pivotal-tracker.token <token>
82
+ }
83
+ exit 1
84
+ else
85
+ $stdout.write Term::ANSIColor.green "Finding your project and story "
86
+ $stdout.flush
87
+
88
+ PivotalTracker::Client.token = token
89
+ story, project = PivotalTracker::Project.all.find do |project|
90
+ $stdout.write Term::ANSIColor.green '.'
91
+ $stdout.flush
92
+ story = project.stories.find(story_id) and break story, project
93
+ end
94
+ $stdout.puts
95
+
96
+ if story.nil?
97
+ puts Term::ANSIColor.yellow "Apologies... I could not find story #{story_id}."
98
+ else
99
+ $stdout.puts Term::ANSIColor.green "Found story #{story_id} in '#{project.name}'"
100
+
101
+ headline = "Pivotal tracker story [##{story_id}](#{story.url}) in project *#{project.name}*:"
102
+ description = story.description.split("\n").map { |line| "> #{line}" }
103
+ body = "#{headline}\n\n#{description}"
104
+ title = "#{project.name}: #{story.name} [##{story.id}]"
105
+
106
+ query.merge! :subject => story.name, :body => body, :title => title
107
+ end
108
+ end
109
+ end
110
+
111
+ query_string = query.map { |key,value| "#{CGI.escape key.to_s}=#{CGI.escape value}"}.join('&')
112
+ url = "https://github.com/#{repo}/pull/new?#{query_string}"
52
113
  puts "Preparing a pull request for branch #{branch}"
53
114
  system "open", url
data/git-whistles.gemspec CHANGED
@@ -16,6 +16,10 @@ Gem::Specification.new do |gem|
16
16
 
17
17
  gem.add_development_dependency "bundler", ">= 1.0.0"
18
18
  gem.add_development_dependency "rake"
19
+ gem.add_development_dependency "pry"
20
+
21
+ gem.add_dependency "pivotal-tracker", "~> 0.5.6"
22
+ gem.add_dependency "term-ansicolor"
19
23
 
20
24
  gem.files = `git ls-files`.split($\)
21
25
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -2,7 +2,7 @@ require 'pathname'
2
2
 
3
3
  module Git
4
4
  module Whistles
5
- VERSION = "0.3.1"
5
+ VERSION = "0.4.1"
6
6
  GEMDIR = Pathname.new(__FILE__).parent.parent.parent
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-whistles
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 4
9
9
  - 1
10
- version: 0.3.1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Julien Letessier
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-26 00:00:00 +01:00
18
+ date: 2012-08-31 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -48,6 +48,50 @@ dependencies:
48
48
  name: rake
49
49
  type: :development
50
50
  version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ prerelease: false
62
+ name: pry
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ hash: 7
72
+ segments:
73
+ - 0
74
+ - 5
75
+ - 6
76
+ version: 0.5.6
77
+ prerelease: false
78
+ name: pivotal-tracker
79
+ type: :runtime
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ prerelease: false
92
+ name: term-ansicolor
93
+ type: :runtime
94
+ version_requirements: *id005
51
95
  description: A few helpers for classic Git workflows
52
96
  email:
53
97
  - julien.letessier@gmail.com