git-whistles 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git-whistles (0.6.2)
4
+ git-whistles (0.6.3)
5
5
  pivotal-tracker (~> 0.5.6)
6
6
  term-ansicolor
7
7
 
@@ -13,9 +13,9 @@ GEM
13
13
  crack (0.3.2)
14
14
  happymapper (0.4.0)
15
15
  libxml-ruby (~> 2.0)
16
- libxml-ruby (2.5.0)
16
+ libxml-ruby (2.6.0)
17
17
  method_source (0.8)
18
- mime-types (1.20.1)
18
+ mime-types (1.21)
19
19
  nokogiri (1.5.6)
20
20
  nokogiri-happymapper (0.5.6)
21
21
  nokogiri (~> 1.5)
data/bin/git-select CHANGED
@@ -7,69 +7,119 @@
7
7
  # the story-id and checkout it
8
8
  #
9
9
  require 'rubygems'
10
+ require 'optparse'
10
11
  require 'term/ansicolor'
12
+ require 'git-whistles/app'
11
13
 
12
- # Helper functions
13
- def git_dir?
14
- `git config --get remote.origin.url`.strip == ''
15
- end
14
+ class App < Git::Whistles::App
16
15
 
17
- def process(branches)
18
- branches.split("\n").map { |branch| branch.strip.gsub(%r(\* ), '')}
19
- end
16
+ def initialize
17
+ super
18
+ end
20
19
 
21
- def select(branches, story_id)
22
- branches.select { |branch| branch =~ /#{story_id}/ }
23
- end
20
+ def main(args)
21
+ super
22
+ parse_args!(args)
24
23
 
24
+ die "Missing story id", :usage => true if args.count == 0
25
+ die "Too many arguments", :usage => true if args.count > 1
25
26
 
26
- if git_dir?
27
- puts "Not a valid git repo"
28
- exit 1
29
- end
27
+ story_id = args.first
30
28
 
31
- if ARGV[0] && ARGV[0] =~ /^\d+$/
32
- story_id = ARGV[0]
33
- else
34
- puts "story-id is not a number"
35
- exit 1
36
- end
29
+ unless story_id.match(/^\d+$/)
30
+ die "Story ID is not a number", :usage => true
31
+ end
37
32
 
33
+ # Find locally first
34
+ locals = process(`git branch`)
38
35
 
39
- # Find locally first
40
- locals = process(`git branch`)
36
+ # Select matching locals
37
+ found = select(locals, story_id)
41
38
 
42
- # Select matching locals
43
- found = select(locals, story_id)
39
+ case found.size
40
+ when 0
41
+ puts yellow 'failed lookup on local branches'
42
+ puts ""
43
+ when 1
44
+ `git checkout #{found.first}`
45
+ exit 0
46
+ else
47
+ puts "found #{found.size} matches on locals:"
48
+ found.each do |branch|
49
+ puts green(" #{branch}")
50
+ end
51
+ exit 1
52
+ end
53
+
54
+ # Find remote branch
55
+ remotes = process(`git branch -a`)
56
+
57
+ # Select matching remotes
58
+ found = select(remotes, story_id)
59
+
60
+ case found.size
61
+ when 0
62
+ puts yellow 'failed lookup on remote branches'
63
+ when 1
64
+ if options.remote_checkout
65
+ `git checkout #{branch_name(found.first)}`
66
+ exit 0
67
+ else
68
+ puts "found #{green(branch_name(found.first))} on remote"
69
+ puts "by default remote branches are not checked out"
70
+ puts "if you want to checkout do: #{green "git select -r #{story_id}"}"
71
+ exit 1
72
+ end
73
+ else
74
+ puts "Found #{found.size} matches on remotes:"
75
+ found.each do |branch|
76
+ puts green(" #{branch_name(branch)}")
77
+ end
78
+ exit 1
79
+ end
44
80
 
45
- case found.size
46
- when 0
47
- puts Term::ANSIColor.yellow 'Failed lookup on local branches'
48
- when 1
49
- `git checkout #{found.first}`
50
- exit 0
51
- else
52
- puts "Found #{found.size} matches on locals:"
53
- found.each do |branch|
54
- puts " #{branch}"
55
81
  end
56
- exit 1
57
- end
58
82
 
59
- # Find remote branch
60
- remotes = process(`git branch -a`)
83
+ def defaults
84
+ {
85
+ :remote_checkout => false
86
+ }
87
+ end
61
88
 
62
- # Select matching remotes
63
- found = select(remotes, story_id)
89
+ def option_parser
90
+ @option_parser ||= OptionParser.new do |op|
91
+ op.banner = "Usage: git select [options] STORY_ID"
92
+
93
+ op.on("-r", "--remote", "Checkout branch from remote if not present locally") do |v|
94
+ options.remote_checkout = true
95
+ end
96
+
97
+ op.on_tail("-h", "--help", "Show this message") do
98
+ puts op
99
+ exit
100
+ end
101
+ end
102
+ end
103
+
104
+ def process(branches)
105
+ branches.split("\n").map { |branch| branch.strip.gsub(%r(\* ), '')}
106
+ end
107
+
108
+ def select(branches, story_id)
109
+ branches.select { |branch| branch =~ /#{story_id}/ }
110
+ end
111
+
112
+ def branch_name(branch_ref)
113
+ branch_ref.gsub(%r(^remotes/origin/), "")
114
+ end
115
+
116
+ def green(text)
117
+ Term::ANSIColor.green(text)
118
+ end
64
119
 
65
- case found.size
66
- when 0
67
- puts Term::ANSIColor.yellow 'Failed lookup on remote branches'
68
- else
69
- puts "Found #{found.size} matches on remotes:"
70
- found.each do |branch|
71
- puts " #{branch.gsub(%r(^remotes/origin/), "")}"
120
+ def yellow(text)
121
+ Term::ANSIColor.yellow(text)
72
122
  end
73
- exit 1
74
123
  end
75
124
 
125
+ App.run!
@@ -4,7 +4,7 @@ require 'pathname'
4
4
 
5
5
  module Git
6
6
  module Whistles
7
- VERSION = "0.6.2"
7
+ VERSION = "0.6.3"
8
8
  GEMDIR = Pathname.new(__FILE__).parent.parent.parent
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,115 +1,116 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: git-whistles
3
- version: !ruby/object:Gem::Version
4
- hash: 3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 6
9
- - 2
10
- version: 0.6.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Julien Letessier
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-02-08 00:00:00 +00:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-02-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: bundler
23
- prerelease: false
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 0
33
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 1.0.0
35
22
  type: :development
36
- requirement: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rake
39
23
  prerelease: false
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
41
33
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
49
38
  type: :development
50
- requirement: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: pry
53
39
  prerelease: false
54
- version_requirements: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
55
41
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pry
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
63
54
  type: :development
64
- requirement: *id003
65
- - !ruby/object:Gem::Dependency
66
- name: pry-nav
67
55
  prerelease: false
68
- version_requirements: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: pry-nav
64
+ requirement: !ruby/object:Gem::Requirement
69
65
  none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
75
- - 0
76
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
77
70
  type: :development
78
- requirement: *id004
79
- - !ruby/object:Gem::Dependency
80
- name: pivotal-tracker
81
71
  prerelease: false
82
- version_requirements: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: pivotal-tracker
80
+ requirement: !ruby/object:Gem::Requirement
83
81
  none: false
84
- requirements:
82
+ requirements:
85
83
  - - ~>
86
- - !ruby/object:Gem::Version
87
- hash: 7
88
- segments:
89
- - 0
90
- - 5
91
- - 6
84
+ - !ruby/object:Gem::Version
92
85
  version: 0.5.6
93
86
  type: :runtime
94
- requirement: *id005
95
- - !ruby/object:Gem::Dependency
96
- name: term-ansicolor
97
87
  prerelease: false
98
- version_requirements: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.5.6
94
+ - !ruby/object:Gem::Dependency
95
+ name: term-ansicolor
96
+ requirement: !ruby/object:Gem::Requirement
99
97
  none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: 3
104
- segments:
105
- - 0
106
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
107
102
  type: :runtime
108
- requirement: *id006
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
109
110
  description: A few helpers for classic Git workflows
110
- email:
111
+ email:
111
112
  - julien.letessier@gmail.com
112
- executables:
113
+ executables:
113
114
  - git-chop
114
115
  - git-ff-all-branches
115
116
  - git-list-branches
@@ -119,10 +120,8 @@ executables:
119
120
  - git-select
120
121
  - git-stash-and-checkout
121
122
  extensions: []
122
-
123
123
  extra_rdoc_files: []
124
-
125
- files:
124
+ files:
126
125
  - .gitignore
127
126
  - Gemfile
128
127
  - Gemfile.lock
@@ -149,41 +148,32 @@ files:
149
148
  - libexec/git-outstanding-features.sh
150
149
  - libexec/git-stash-and-checkout.sh
151
150
  - libexec/runner.rb
152
- has_rdoc: true
153
151
  homepage: http://github.com/mezis/git-whistles
154
152
  licenses: []
155
-
156
153
  post_install_message:
157
154
  rdoc_options: []
158
-
159
- require_paths:
155
+ require_paths:
160
156
  - lib
161
- required_ruby_version: !ruby/object:Gem::Requirement
157
+ required_ruby_version: !ruby/object:Gem::Requirement
162
158
  none: false
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- hash: 3
167
- segments:
159
+ requirements:
160
+ - - ! '>='
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ segments:
168
164
  - 0
169
- version: "0"
170
- required_rubygems_version: !ruby/object:Gem::Requirement
165
+ hash: 4013642806970746288
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
167
  none: false
172
- requirements:
173
- - - ">="
174
- - !ruby/object:Gem::Version
175
- hash: 23
176
- segments:
177
- - 1
178
- - 3
179
- - 6
168
+ requirements:
169
+ - - ! '>='
170
+ - !ruby/object:Gem::Version
180
171
  version: 1.3.6
181
172
  requirements: []
182
-
183
173
  rubyforge_project:
184
- rubygems_version: 1.6.2
174
+ rubygems_version: 1.8.23
185
175
  signing_key:
186
176
  specification_version: 3
187
- summary: "A few helpers for classic Git workflows: makes branching and merging, PO file handling, issuing pull requests slightly simpler."
177
+ summary: ! 'A few helpers for classic Git workflows: makes branching and merging,
178
+ PO file handling, issuing pull requests slightly simpler.'
188
179
  test_files: []
189
-