git-whistles 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  pkg
7
7
  rdoc
8
8
  tmp
9
+ nbproject
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git-whistles (0.7.4)
4
+ git-whistles (0.7.5)
5
5
  pivotal-tracker (~> 0.5.6)
6
6
  term-ansicolor
7
7
 
data/HISTORY CHANGED
@@ -1,2 +1,6 @@
1
+ # 2013-07-18: 0.7.5
2
+ * [FEATURE] git pivotal-branch <story-id> Creates a branch name suggestion from the specified Pivotal Tracker story ID. [dncrht]
3
+ * [FEATURE] git outstanding-features -o allows to view all features to be deployed in one single line
4
+
1
5
  # 2013-06-18: 0.7.4
2
6
  * [FIX] Adjusted git-pull-request to play with the new GitHub pull request user interface
data/README.md CHANGED
@@ -12,13 +12,14 @@ Use it with:
12
12
 
13
13
  - `git ff-all-branches [-f] [-p] [-v]`. Fast-forward all local tracking branches to their remote counterpart (where possible). Very useful on big projects.
14
14
  - `git stash-and-checkout [branch]` As the name implies: stash and checkout another branch.
15
- - `git-pull-request [--from your-branch] [--to target-branch]` Open your browser at a Github pull-request page for the specified branch (defaults to the current `head`). If you're using Pivotal Tracker and your branch has a story number in its name, populates your pull request with story details.
16
- - `git outstanding-features [-f from-branch] [-t to-branch]` List the pull requests merged in `[to-branch]` but not in `[from-branch]`. Useful to prepare a list of stuff you're going to deploy. Defaults to listing what's on `origin/master` but not on `origin/production`. [[PedroCunha](https://github.com/PedroCunha)]
17
- - `git chop [branch]` Delete the local and origin copy of a branch. Useful to close feature branches once a feature is completed.
15
+ - `git pull-request [--from your-branch] [--to target-branch]` Open your browser at a Github pull-request page for the specified branch (defaults to the current `head`). If you're using Pivotal Tracker and your branch has a story number in its name, populates your pull request with story details.
16
+ - `git outstanding-features [-f from-branch] [-t to-branch] [--oneline]` List the pull requests merged in `[to-branch]` but not in `[from-branch]`. Useful to prepare a list of stuff you're going to deploy. Defaults to listing what's on `origin/master` but not on `origin/production`. By default lists one feature per line, if `--oneline` or `-o` is specified features will be separated by spaces instead. [[PedroCunha](https://github.com/PedroCunha)]
17
+ - `git chop [branch]` Delete the local and origin copy of a branch. Useful to close feature branches once a feature is completed.
18
18
  - `git list-branches [-l] [-r] [-i integration-branch]` Colourful listing of all local or origin branches, and their distance to an integration branch (`master` by default).
19
19
  - `git merge-po <ancestor> <left> <right>` Merge engine for GetText PO files.
20
20
  - `git select <story-id>` Checkout a local branch with the matching number. If not found, lists remote branches
21
21
  - `git latest-pushes [-n NR_RESULTS] [-p PATTERN]` Show latest pushed branches to origin. Defaults to 20 results. Pattern is appended to refs/remotes/origin/ so include the team or project name to filter results. [[PedroCunha](https://github.com/PedroCunha)]
22
+ - `git pivotal-branch <story-id>` Creates a branch name suggestion from the specified Pivotal Tracker story ID. [[dncrht](https://github.com/dncrht)]
22
23
 
23
24
  ### More details on some of the commands
24
25
 
@@ -20,13 +20,16 @@ class App < Git::Whistles::App
20
20
  super
21
21
  parse_args!(args)
22
22
 
23
- puts `git log --oneline #{options.from} ^#{options.to} | grep 'Merge pull request' | sed -e 's:.*from [^/]*/::'`
23
+ output = `git log --oneline #{options.from} ^#{options.to} | grep 'Merge pull request' | sed -e 's:.*from [^/]*/::'`
24
+ return output if output.nil?
25
+ puts options.oneline ? output.gsub(/\s+/, ' ') : output
24
26
  end
25
27
 
26
28
  def defaults
27
29
  {
28
- :from => 'origin/master',
29
- :to => 'origin/production'
30
+ :from => 'origin/master',
31
+ :to => 'origin/production',
32
+ :oneline => false
30
33
  }
31
34
  end
32
35
 
@@ -42,6 +45,10 @@ class App < Git::Whistles::App
42
45
  options.to = to
43
46
  end
44
47
 
48
+ op.on("-o", "--oneline", "Output features in one line separated by spaces") do |oneline|
49
+ options.oneline = true
50
+ end
51
+
45
52
  op.on_tail("-h", "--help", "Show this message") do
46
53
  puts op
47
54
  exit
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # git-pivotal-branch
5
+ #
6
+ # Suggest a branch name from the given Pivotal Tracker story ID
7
+ #
8
+ # Assumes the branches are named as:
9
+ # <team>/<branch-title>-<story-id>
10
+ #
11
+ require 'rubygems'
12
+ require 'optparse'
13
+ require 'pivotal-tracker'
14
+ require 'readline'
15
+ require 'term/ansicolor'
16
+ require 'git-whistles/app'
17
+
18
+
19
+ class App < Git::Whistles::App
20
+
21
+ def initialize
22
+ super
23
+ end
24
+
25
+ def main(args)
26
+ super
27
+ parse_args!(args)
28
+
29
+ if args.count < 1
30
+ show_and_exit usage
31
+ end
32
+
33
+ story_id = args[0]
34
+
35
+ # get PT info
36
+ story, project = get_pivotal_info(story_id)
37
+
38
+ branch_name_suggested = "#{project.name}/#{story.name}-#{story_id}".downcase
39
+ branch_name_suggested.gsub!(/[^\w\d\/]/, '-').gsub!(/-+/, '-')
40
+
41
+ puts 'The suggested branch name is: ' << Term::ANSIColor.yellow(branch_name_suggested)
42
+ puts ' Press ENTER if you agree'
43
+ puts ' or Write any other name and press ENTER'
44
+ puts ' or Press CTRL-D to cancel'
45
+
46
+ branch_name = Readline.readline ' > ', false
47
+
48
+ if branch_name.nil?
49
+ log.warn "\nCancelled by user"
50
+ exit 2
51
+ end
52
+
53
+ branch_name = branch_name.empty? ? branch_name_suggested : branch_name
54
+
55
+ # create branch
56
+ `cd #{ENV['PWD']} && git co -b #{branch_name}`
57
+
58
+ # comment and start on PT
59
+ story.notes.create :text => "Created branch #{branch_name}"
60
+ story.update :current_state => 'started'
61
+
62
+ puts Term::ANSIColor.green('Created branch and started PT story')
63
+ end
64
+
65
+ private
66
+
67
+ def usage
68
+ 'Usage: git pivotal-branch PIVOTAL_TRACKER_STORY_ID'
69
+ end
70
+
71
+ def show_and_exit(message)
72
+ puts message
73
+ exit 1
74
+ end
75
+
76
+ def option_parser
77
+ @option_parser ||= OptionParser.new do |op|
78
+ op.banner = usage
79
+
80
+ op.on_tail('-h', '--help', 'Show this message') do
81
+ show_and_exit op
82
+ end
83
+ end
84
+ end
85
+
86
+ def get_pivotal_info(story_id)
87
+ token = `git config pivotal-tracker.token`.strip
88
+ if token.empty?
89
+ puts Term::ANSIColor.yellow %Q{
90
+ Your branch appears to have a story ID,
91
+ but I don't know your Pivotal Tracker token!
92
+ Please set it with:
93
+ $ git config [--global] pivotal-tracker.token <token>
94
+ }
95
+ die "Aborting."
96
+ end
97
+
98
+ log.info "Finding your project and story¬"
99
+
100
+ PivotalTracker::Client.token = token
101
+ story, project = PivotalTracker::Project.all.find do |project|
102
+ log.info '.¬'
103
+ story = project.stories.find(story_id) and break story, project
104
+ end
105
+ log.info '.'
106
+
107
+ if story.nil?
108
+ log.warn "Apologies... I could not find story #{story_id}."
109
+ exit 1
110
+ end
111
+
112
+ log.info "Found story #{story_id} in '#{project.name}'"
113
+
114
+ [story, project]
115
+ end
116
+
117
+
118
+ end
119
+
120
+ ############################################################################
121
+
122
+ App.run!
data/git-whistles.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
  require File.expand_path('../lib/git-whistles/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Julien Letessier"]
5
+ gem.authors = ["Julien Letessier", "Pedro Cunha"]
6
6
  gem.email = ["julien.letessier@gmail.com"]
7
7
  gem.description = %q{A few helpers for classic Git workflows}
8
8
  gem.summary = %q{
@@ -4,7 +4,7 @@ require 'pathname'
4
4
 
5
5
  module Git
6
6
  module Whistles
7
- VERSION = "0.7.4"
7
+ VERSION = "0.7.5"
8
8
  GEMDIR = Pathname.new(__FILE__).parent.parent.parent
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-whistles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Julien Letessier
9
+ - Pedro Cunha
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-06-18 00:00:00.000000000 Z
13
+ date: 2013-07-18 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: bundler
@@ -117,6 +118,7 @@ executables:
117
118
  - git-list-branches
118
119
  - git-merge-po
119
120
  - git-outstanding-features
121
+ - git-pivotal-branch
120
122
  - git-pull-request
121
123
  - git-select
122
124
  - git-stash-and-checkout
@@ -136,6 +138,7 @@ files:
136
138
  - bin/git-list-branches
137
139
  - bin/git-merge-po
138
140
  - bin/git-outstanding-features
141
+ - bin/git-pivotal-branch
139
142
  - bin/git-pull-request
140
143
  - bin/git-select
141
144
  - bin/git-stash-and-checkout
@@ -164,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
167
  version: '0'
165
168
  segments:
166
169
  - 0
167
- hash: 4357258647200684610
170
+ hash: 1077237623234121323
168
171
  required_rubygems_version: !ruby/object:Gem::Requirement
169
172
  none: false
170
173
  requirements: