gitcycle 0.2.33 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +14 -1
  2. data/gitcycle.gemspec +3 -1
  3. data/lib/gitcycle.rb +67 -13
  4. metadata +69 -19
  5. checksums.yaml +0 -7
data/README.md CHANGED
@@ -76,6 +76,13 @@ When the branch is ready for code review:
76
76
 
77
77
  This will label the pull request as "Pending Review".
78
78
 
79
+ Open
80
+ ----
81
+
82
+ If you want to view the pull request without updating the ticket:
83
+
84
+ gitc open
85
+
79
86
  Code Review
80
87
  -----------
81
88
 
@@ -142,6 +149,12 @@ Checkout a branch from a ticket URL:
142
149
 
143
150
  gitc checkout [TICKET URL]
144
151
 
152
+ ### From Ticket Number
153
+
154
+ Checkout a branch from a ticket #:
155
+
156
+ gitc checkout [TICKET NUMBER]
157
+
145
158
  ### From User's Fork
146
159
 
147
160
  gitc checkout user/branch
@@ -169,4 +182,4 @@ Nice to haves:
169
182
  $ gitc st - shortcut
170
183
  * gitc clean # to clean up old branches
171
184
  * fail should change to inactive
172
- * gitc pull: shouldnt matter who does it, it should update the latest br/rc, not working https://gist.github.com/22b1e248e8dba7a32288
185
+ * gitc pull: shouldnt matter who does it, it should update the latest br/rc, not working https://gist.github.com/22b1e248e8dba7a32288
data/gitcycle.gemspec CHANGED
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "gitcycle"
9
- s.version = '0.2.33'
9
+ s.version = '0.3.0'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = [ 'Winton Welsh' ]
12
12
  s.email = [ 'mail@wintoni.us' ]
@@ -28,4 +28,6 @@ Gem::Specification.new do |s|
28
28
 
29
29
  s.add_dependency "launchy", "= 2.0.5"
30
30
  s.add_dependency "yajl-ruby", "= 1.1.0"
31
+ s.add_dependency "httpclient", "= 2.1.5"
32
+ s.add_dependency "httpi", "= 0.9.6"
31
33
  end
data/lib/gitcycle.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require 'rubygems'
2
2
 
3
3
  require 'fileutils'
4
- require 'open-uri'
5
4
  require 'uri'
6
5
  require 'yaml'
6
+ require 'httpclient'
7
+ require 'httpi'
7
8
 
8
9
  gem 'launchy', '= 2.0.5'
9
10
  require 'launchy'
@@ -92,23 +93,23 @@ class Gitcycle
92
93
  :branch => branch['source'],
93
94
  :target => name
94
95
  )
96
+
97
+ puts "Sending branch information to gitcycle.".green
98
+ get('branch',
99
+ 'branch[home]' => branch['home'],
100
+ 'branch[name]' => branch['name'],
101
+ 'branch[rename]' => name != branch['name'] ? name : nil,
102
+ 'branch[source]' => branch['source']
103
+ )
95
104
  rescue SystemExit, Interrupt
96
105
  puts "\nDeleting branch from gitcycle.\n".green
97
- branch = get('branch',
106
+ get('branch',
98
107
  'branch[name]' => branch['name'],
99
108
  'create' => 0,
100
109
  'reset' => 1
101
110
  )
102
111
  end
103
112
 
104
- puts "Sending branch information to gitcycle.".green
105
- get('branch',
106
- 'branch[home]' => branch['home'],
107
- 'branch[name]' => branch['name'],
108
- 'branch[rename]' => name != branch['name'] ? name : nil,
109
- 'branch[source]' => branch['source']
110
- )
111
-
112
113
  puts "\n"
113
114
  end
114
115
 
@@ -128,6 +129,24 @@ class Gitcycle
128
129
  puts "\nBranch not found!\n".red
129
130
  puts "\nDid you mean: gitc branch #{args[0]}\n".yellow
130
131
  end
132
+ elsif args[0] =~ /^\d*$/
133
+ puts "\nLooking for a branch for LH ticket ##{args[0]}.\n".green
134
+ results = branches(:array => true).select {|b| b.include?("-#{args[0]}-") }
135
+ if results.size == 0
136
+ puts "\nNo matches for ticket ##{args[0]} found.\n".red
137
+ elsif results.size == 1
138
+ branch = results.first
139
+ if branch.strip == branches(:current => true).strip
140
+ puts "Already on Github branch for LH ticket ##{args[0]} (#{branch})".yellow
141
+ else
142
+ puts "\nSwitching to branch '#{branch}'\n".green
143
+ run("git checkout #{branch}")
144
+ end
145
+ else
146
+ puts "\nFound #{results.size} matches with that LH ticket number:\n".yellow
147
+ puts results
148
+ puts "\nDid not switch branches. Please check your ticket number.\n".red
149
+ end
131
150
  else
132
151
  remote, branch = args[0].split('/')
133
152
  remote, branch = nil, remote if branch.nil?
@@ -504,6 +523,34 @@ class Gitcycle
504
523
  end
505
524
  end
506
525
 
526
+ def open(*issues)
527
+ require_git && require_config
528
+
529
+ if issues.empty?
530
+ branch = create_pull_request
531
+
532
+ if branch == false
533
+ puts "Branch not found.\n".red
534
+ elsif branch['issue_url']
535
+ puts "\nOpening the pull request in GitHub\n".green
536
+
537
+ puts "Opening issue: #{branch['issue_url']}\n".green
538
+ Launchy.open(branch['issue_url'])
539
+ else
540
+ puts "You must push code before opening a pull request.\n".red
541
+ end
542
+ else
543
+ puts "\nRetrieving branch information from gitcycle.\n".green
544
+
545
+ get('branch', 'issues' => issues, 'scope' => 'repo').each do |branch|
546
+ if branch['issue_url']
547
+ puts "Opening issue: #{branch['issue_url']}\n".green
548
+ Launchy.open(branch['issue_url'])
549
+ end
550
+ end
551
+ end
552
+ end
553
+
507
554
  def setup(login, repo, token)
508
555
  repo = "#{login}/#{repo}" unless repo.include?('/')
509
556
  @config[repo] = [ login, token ]
@@ -556,6 +603,8 @@ class Gitcycle
556
603
  b.match(/\*\s+(.+)/)[1]
557
604
  elsif options[:match]
558
605
  b.match(/([\s]+|origin\/)(#{options[:match]})$/)[2] rescue nil
606
+ elsif options[:array]
607
+ b.split(/\n/).map{|b| b[2..-1]}
559
608
  else
560
609
  b
561
610
  end
@@ -757,9 +806,12 @@ class Gitcycle
757
806
  def get(path, hash={})
758
807
  hash.merge!(
759
808
  :login => @login,
760
- :token => @token
809
+ :token => @token,
810
+ :uid => (0...20).map{ ('a'..'z').to_a[rand(26)] }.join
761
811
  )
762
812
 
813
+ puts "\nTransaction ID: #{hash[:uid]}".green
814
+
763
815
  params = ''
764
816
  hash[:session] = 0
765
817
  hash.each do |k, v|
@@ -772,8 +824,10 @@ class Gitcycle
772
824
  params.chop! # trailing &
773
825
 
774
826
  begin
775
- json = open("#{API}/#{path}.json?#{params}").read
776
- rescue Exception
827
+ req = HTTPI::Request.new "#{API}/#{path}.json?#{params}"
828
+ json = HTTPI.get(req).body
829
+ rescue Exception => error
830
+ puts error.to_s
777
831
  puts "\nCould not connect to Gitcycle.".red
778
832
  puts "\nPlease verify your Internet connection and try again later.\n".yellow
779
833
  exit
metadata CHANGED
@@ -1,102 +1,116 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitcycle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.33
4
+ version: 0.3.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Winton Welsh
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-03-27 00:00:00.000000000 Z
12
+ date: 2013-07-03 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: cucumber
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: lighthouse
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: redis
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rspec
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: simplecov
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - '>='
83
+ - - ! '>='
74
84
  - !ruby/object:Gem::Version
75
85
  version: '0'
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - '>='
91
+ - - ! '>='
81
92
  - !ruby/object:Gem::Version
82
93
  version: '0'
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: yajl-ruby
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - '>='
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - '>='
107
+ - - ! '>='
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: launchy
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - '='
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - '='
109
124
  - !ruby/object:Gem::Version
@@ -111,6 +126,7 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: yajl-ruby
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
131
  - - '='
116
132
  - !ruby/object:Gem::Version
@@ -118,10 +134,43 @@ dependencies:
118
134
  type: :runtime
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
139
  - - '='
123
140
  - !ruby/object:Gem::Version
124
141
  version: 1.1.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: httpclient
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - '='
148
+ - !ruby/object:Gem::Version
149
+ version: 2.1.5
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - '='
156
+ - !ruby/object:Gem::Version
157
+ version: 2.1.5
158
+ - !ruby/object:Gem::Dependency
159
+ name: httpi
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - '='
164
+ - !ruby/object:Gem::Version
165
+ version: 0.9.6
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 0.9.6
125
174
  description: Tame your development cycle.
126
175
  email:
127
176
  - mail@wintoni.us
@@ -154,26 +203,27 @@ files:
154
203
  - lib/gitcycle.rb
155
204
  homepage: https://github.com/winton/gitcycle
156
205
  licenses: []
157
- metadata: {}
158
206
  post_install_message:
159
207
  rdoc_options: []
160
208
  require_paths:
161
209
  - lib
162
210
  required_ruby_version: !ruby/object:Gem::Requirement
211
+ none: false
163
212
  requirements:
164
- - - '>='
213
+ - - ! '>='
165
214
  - !ruby/object:Gem::Version
166
215
  version: '0'
167
216
  required_rubygems_version: !ruby/object:Gem::Requirement
217
+ none: false
168
218
  requirements:
169
- - - '>='
219
+ - - ! '>='
170
220
  - !ruby/object:Gem::Version
171
221
  version: '0'
172
222
  requirements: []
173
223
  rubyforge_project:
174
- rubygems_version: 2.0.0
224
+ rubygems_version: 1.8.25
175
225
  signing_key:
176
- specification_version: 4
226
+ specification_version: 3
177
227
  summary: Tame your development cycle
178
228
  test_files:
179
229
  - features/branch.feature
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: b085b23b392ce71dd72c7a3593744ca86f074ec5
4
- data.tar.gz: abb887b371c6fe7ae835df8c904ebdb70bb18523
5
- SHA512:
6
- metadata.gz: b229a874f88d9ca9540eda5b45d25888fbde97386be130a9aeb6b8d8d23e30a548f516ea541bd7bfd9f8fa12d768aa9bc572f42b4bac1d5ee153a0626ec63c87
7
- data.tar.gz: e1130baee89daf8a181860bc4c0a6012174d14e5872b76493c0f665ccce7c49c93b6af56556cae32ced42ad6cbfeeaad9d9117c04e6c15385678351977cfeddb