redmine_stagecoach 0.5.3 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -11,5 +11,4 @@ group :development do
11
11
  gem "shoulda", ">= 0"
12
12
  gem "bundler", "~> 1.0.0"
13
13
  gem "jeweler", "~> 1.6.4"
14
- gem "rcov", ">= 0"
15
14
  end
data/Gemfile.lock CHANGED
@@ -1,22 +1,31 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activeresource (2.3.14)
5
- activesupport (= 2.3.14)
6
- activesupport (2.3.14)
4
+ activemodel (3.2.1)
5
+ activesupport (= 3.2.1)
6
+ builder (~> 3.0.0)
7
+ activeresource (3.2.1)
8
+ activemodel (= 3.2.1)
9
+ activesupport (= 3.2.1)
10
+ activesupport (3.2.1)
11
+ i18n (~> 0.6)
12
+ multi_json (~> 1.0)
13
+ builder (3.0.0)
7
14
  capistrano (2.9.0)
8
15
  highline
9
16
  net-scp (>= 1.0.0)
10
17
  net-sftp (>= 2.0.0)
11
18
  net-ssh (>= 2.0.14)
12
19
  net-ssh-gateway (>= 1.1.0)
13
- ghi (0.3.0)
20
+ ghi (0.3.1)
14
21
  git (1.2.5)
15
- highline (1.6.9)
22
+ highline (1.6.11)
23
+ i18n (0.6.0)
16
24
  jeweler (1.6.4)
17
25
  bundler (~> 1.0)
18
26
  git (>= 1.2.5)
19
27
  rake
28
+ multi_json (1.0.4)
20
29
  net-scp (1.0.4)
21
30
  net-ssh (>= 1.99.1)
22
31
  net-sftp (2.0.5)
@@ -25,7 +34,6 @@ GEM
25
34
  net-ssh-gateway (1.1.0)
26
35
  net-ssh (>= 1.99.1)
27
36
  rake (0.9.2.2)
28
- rcov (0.9.11)
29
37
  shoulda (2.11.3)
30
38
  trollop (1.16.2)
31
39
 
@@ -38,6 +46,5 @@ DEPENDENCIES
38
46
  capistrano
39
47
  ghi
40
48
  jeweler (~> 1.6.4)
41
- rcov
42
49
  shoulda
43
50
  trollop
data/Rakefile CHANGED
@@ -33,13 +33,13 @@ Rake::TestTask.new(:test) do |test|
33
33
  test.verbose = true
34
34
  end
35
35
 
36
- require 'rcov/rcovtask'
37
- Rcov::RcovTask.new do |test|
38
- test.libs << 'test'
39
- test.pattern = 'test/**/test_*.rb'
40
- test.verbose = true
41
- test.rcov_opts << '--exclude "gems/*"'
42
- end
36
+ #require 'rcov/rcovtask'
37
+ #Rcov::RcovTask.new do |test|
38
+ # test.libs << 'test'
39
+ # test.pattern = 'test/**/test_*.rb'
40
+ # test.verbose = true
41
+ # test.rcov_opts << '--exclude "gems/*"'
42
+ #end
43
43
 
44
44
  task :default => :test
45
45
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.6.1
data/bin/stagecoach CHANGED
@@ -31,13 +31,13 @@ module Stagecoach
31
31
  Config.setup if config["redmine_api"] == "none"
32
32
 
33
33
  # Checks that command-line args are present and correct.
34
- Trollop::die :planio, "issue number can only contain digits" if opts[:planio] && opts[:planio][/\D/]
34
+ Trollop::die :redmine, "issue number can only contain digits" if opts[:redmine] && opts[:redmine][/\D/]
35
35
  Trollop::die :github, "issue number can only contain digits" if opts[:github] && opts[:github][/\D/]
36
36
  Trollop::die :branch, "name must be longer than 1 character" if opts[:branch] && opts[:branch].length <= 1
37
37
 
38
- # You can't give a planio and a github issue number (for the moment)
39
- if opts[:github] && opts[:planio]
40
- puts "You can't enter a github issue at the same time as a planio issue at the moment. Make up your mind!\nExiting..."
38
+ # You can't give a redmine and a github issue number (for the moment)
39
+ if opts[:github] && opts[:redmine]
40
+ puts "You can't enter a github issue at the same time as a redmine issue at the moment. Make up your mind!\nExiting..."
41
41
  exit
42
42
  end
43
43
  end
@@ -57,34 +57,36 @@ module Stagecoach
57
57
  exit
58
58
  end
59
59
 
60
+ # ------------------------------------------------------------------
60
61
  # Initial stage - set up branch and git issue.
62
+ # ------------------------------------------------------------------
61
63
 
62
- unless opts[:deploy]
64
+ unless opts[:deploy] or opts[:push]
63
65
 
64
66
  # If no issue argument has been given.
65
- if opts[:github].nil? && opts[:planio].nil?
66
- print "Are you working on a [P]lanio or a [G]ithub issue: "
67
+ if opts[:github].nil? && opts[:redmine].nil?
68
+ print "Are you working on a [R]edmine or a [G]ithub issue: "
67
69
  case STDIN.gets.chomp
68
- when 'P'
69
- print "Please enter your Planio issue number: "
70
- opts[:planio] = gets.chomp
70
+ when 'R'
71
+ print "Please enter your Redmine issue number: "
72
+ opts[:redmine] = gets.chomp
71
73
  when 'G'
72
74
  print "Please enter your Github issue number: "
73
75
  opts[:github] = gets.chomp
74
76
  end
75
77
  end
76
78
 
77
- # Check that the planio issue is not already assigned.
78
- if opts[:planio]
79
- planio_issue_number = opts[:planio]
80
- planio_issue = Redmine.issue(planio_issue_number)
81
- if planio_issue.status.id != '1'
79
+ # Check that the redmine issue is not already assigned.
80
+ if opts[:redmine]
81
+ redmine_issue_number = opts[:redmine]
82
+ redmine_issue = Redmine.issue(redmine_issue_number)
83
+ if redmine_issue.status.id != '1'
82
84
  puts "Warning!".red
83
- puts "This issue is in status '#{planio_issue.status.name}'"
85
+ puts "This issue is in status '#{redmine_issue.status.name}'"
84
86
  begin
85
- puts "It is assigned to #{planio_issue.assigned_to.name}"
87
+ puts "It is assigned to #{redmine_issue.assigned_to.name}"
86
88
  rescue
87
- puts "But it is not assigned to anybody yet."
89
+ puts "But it is not assigned to anybody yet."
88
90
  end
89
91
  print "Continue? [Y]es or [Q]uit: "
90
92
  case STDIN.gets.chomp
@@ -94,9 +96,9 @@ module Stagecoach
94
96
  end
95
97
  end
96
98
 
97
- # Set the planio issue status to 'In Bearbeitung'
98
- planio_issue.status_id = 2
99
- planio_issue.save
99
+ # Set the redmine issue status to 'In Bearbeitung'
100
+ redmine_issue.status_id = 2
101
+ redmine_issue.save
100
102
  end
101
103
 
102
104
  # TODO: Check that the github issue is not already assigned.
@@ -152,7 +154,7 @@ module Stagecoach
152
154
  else
153
155
  Git.new_branch(new_branch)
154
156
  end
155
-
157
+
156
158
  # Ugly code, pretty output...
157
159
  CommandLine.line_break
158
160
 
@@ -160,36 +162,36 @@ module Stagecoach
160
162
  if opts[:github]
161
163
  config[Git.current_branch] = {:github_issue => opts[:github]}
162
164
  #TODO check that github issue is not assigned to somebody already
163
- elsif opts[:planio]
164
- config[Git.current_branch] = {:planio_issue => planio_issue_number}
165
+ elsif opts[:redmine]
166
+ config[Git.current_branch] = {:redmine_issue => redmine_issue_number}
165
167
  end
166
168
 
167
169
  issue = config[Git.current_branch]
168
170
 
169
171
  # Set up the related issue for this branch.
170
- if planio_issue = issue[:planio_issue]
172
+ if redmine_issue = issue[:redmine_issue]
171
173
  begin
172
- puts "Searching for issue number #{planio_issue}..."
173
- redmine_issue = Redmine.issue(planio_issue)
174
+ puts "Searching for issue number #{redmine_issue}..."
175
+ redmine_issue = Redmine.issue(redmine_issue)
174
176
  rescue ActiveResource::ResourceNotFound => e
175
177
  puts e.message
176
178
  exit
177
179
  end
178
- puts "Issue found: #{redmine_issue.subject}\n"
180
+ puts "Issue found: #{redmine_issue.subject}\n"
179
181
 
180
- # Create a Github issue referencing the planio issue.
182
+ # Create a Github issue referencing the redmine issue.
181
183
  puts "Creating Git issue with subject: " + redmine_issue.subject
182
- body = "Planio issue: #{Redmine.issue_url(redmine_issue)} \n\n #{redmine_issue.description}"
184
+ body = "Redmine issue: #{Redmine.issue_url(redmine_issue)} \n\n #{redmine_issue.description}"
183
185
 
184
186
  # Create a Git issue.
185
187
  github_issue = Git.new_issue(redmine_issue.subject, body)
186
188
  github_issue_id = github_issue[/\d+/]
187
189
 
188
190
  # Save it so we can reference it in commits using the magic of git hooks!
189
- config[Git.current_branch] = {:github_issue => github_issue_id, :planio_issue => planio_issue}
191
+ config[Git.current_branch] = {:github_issue => github_issue_id, :redmine_issue => redmine_issue}
190
192
 
191
193
  print "Would you like to edit the issue on Github? [Y]es or anything else to continue: "
192
-
194
+
193
195
  if STDIN.gets.chomp == 'Y'
194
196
  Git.view_issue(github_issue_id)
195
197
  else
@@ -210,15 +212,21 @@ module Stagecoach
210
212
  end
211
213
 
212
214
  # ------------------------------------------------------------------
213
- # Deploy stage.
214
- if opts[:deploy]
215
+ # Push stage
216
+ # ------------------------------------------------------------------
215
217
 
218
+ if opts[:push]
216
219
  # Get the current git branch
217
220
  branch = Git.current_branch
218
221
 
219
- # There's no point in deploying without any commits
222
+ # There's no point in pushing without any commits
220
223
  unless Git.branch_has_commits?(branch)
221
- puts "You don't have any uncommitted changes on branch #{branch}. Please make some commits before running stagecoach!\nExiting..."
224
+ puts "You don't have any uncommitted changes on branch #{branch}."
225
+ puts "If you have already pushed your changes, run:"
226
+ puts "stagecoach -d [deploy_branch] - default is 'staging'"
227
+ puts "Otherwise, go make some commits!"
228
+ puts "#%s for help" % "stagecoach -h".green
229
+ puts "Exiting..."
222
230
  exit
223
231
  end
224
232
 
@@ -228,7 +236,7 @@ module Stagecoach
228
236
  puts "You have a dirty git branch:\n".red
229
237
  puts Git.status
230
238
  CommandLine.line_break
231
- print "[D]eploy anyway".red
239
+ print "[P]ush anyway".red
232
240
  print " or "
233
241
  print "[anything else] to cancel: ".green
234
242
  case STDIN.gets.chomp
@@ -242,26 +250,45 @@ module Stagecoach
242
250
  end
243
251
  end
244
252
 
245
-
253
+ # TODO this needs removing if we implement the 'deploy to staging' stuff
246
254
  # Stop anybody deploying master to staging...
247
255
  case branch
248
- when 'master', 'Master'
249
- puts "You can't use stagecoach to deploy your master branch.\nExiting..."
256
+ when 'master', 'Master', 'staging', 'Staging'
257
+ puts "You can't use stagecoach to deploy your #{branch} branch.\nExiting..."
250
258
  exit
251
259
  end
252
260
 
253
- # Finally, push, merge and deploy!
261
+ # Push the branch and give option to continue or quit
254
262
  Git.push(branch)
255
- Git.merge(staging, branch)
256
- Git.push(staging)
257
- Capistrano.deploy(staging)
263
+
264
+ puts "Push successful."
265
+ unless opts[:deploy_given]
266
+ "stagecoach -d [branch_name] to deploy (default is staging)."
267
+ "exiting..."
268
+ exit
269
+ end
270
+ end
271
+
272
+ # ------------------------------------------------------------------
273
+ # Deploy stage.
274
+ # ------------------------------------------------------------------
275
+
276
+ if opts[:deploy_given]
277
+
278
+ # Get the current git branch
279
+ from_branch = Git.current_branch
280
+ to_branch = opts[:deploy]
281
+
282
+ Git.merge(to_branch, from_branch)
283
+ Git.push(to_branch)
284
+ Capistrano.deploy(to_branch)
258
285
  Git.change_to_branch(master)
259
286
 
260
- # Planio issue to feedback status
261
- if planio_issue_number = config[branch][:planio_issue]
287
+ # Redmine issue to feedback status
288
+ if redmine_issue_number = config[branch][:redmine_issue]
262
289
  CommandLine.line_break
263
- puts "Attempting to change Planio ticket status to 'Feedback' for you:"
264
- issue = Redmine.issue(planio_issue_number)
290
+ puts "Attempting to change Redmine ticket status to 'Feedback' for you:"
291
+ issue = Redmine.issue(redmine_issue_number)
265
292
  issue.status_id = 4
266
293
  issue.save
267
294
  Redmine.view_issue(issue)
@@ -91,7 +91,7 @@ message =
91
91
  case flag
92
92
  when *NO_REFERENCE_FLAGS
93
93
  message
94
- when *CLOSING_FLAGS
94
+ when *CLOSE
95
95
  [ message, finish ].join(" ")
96
96
  else
97
97
  [ message, reference ].join(" ")
@@ -3,7 +3,7 @@ module Stagecoach
3
3
  class << self
4
4
  def deploy(branch)
5
5
  CommandLine.line_break
6
- puts "Deploying staging"
6
+ puts "Deploying to #{branch}"
7
7
  puts `bundle exec cap #{branch} deploy`
8
8
  end
9
9
  end
@@ -73,11 +73,15 @@ This automates the entire deploy workflow for you as follows:
73
73
  #{"Flags".red}
74
74
  EOS
75
75
  opt :branch, "Enter your new branch name here, eg. stagecoach -b new_branch (optional)", :type => :string
76
- opt :planio, "Enter your planio issue number here, eg. stagecoach -p 1234 (optional)", :type => :string
76
+ opt :redmine, "Enter your redmine/planio issue number here, eg. stagecoach -r 1234 (optional)", :type => :string
77
77
  opt :github, "Enter your github issue number here, eg. stagecoach -g 1234 (optional)", :type => :string
78
- opt :deploy, "Use this option to skip straight to push & deploy if you have already pulled from master and created your new branch"
78
+ opt :push, "Use this option to push your changes to your remote branch (will be created if necessary)"
79
+ opt :deploy, "Use this option to deploy from your current branch to any branch you choose, eg. stagecoach -d staging (default is staging)", :type => :string, :default => 'staging'
79
80
  opt :setup, "Use this the first time you run stagecoach to save your redmine repository and api key"
80
- opt :testing, "Dev testing tool"
81
+
82
+ # Some arguments don't belong together
83
+ conflicts(:redmine, :github)
84
+ conflicts(:push, :deploy)
81
85
  end
82
86
  end
83
87
  end
@@ -122,8 +122,7 @@ module Stagecoach
122
122
  end
123
123
 
124
124
  def view_issue(github_issue)
125
- issue_url = `ghi -u#{github_issue}`
126
- `open #{issue_url}`
125
+ `ghi -u#{github_issue}`
127
126
  end
128
127
 
129
128
  def issue(id)
@@ -24,7 +24,7 @@ module Stagecoach
24
24
  # Open the issue in a browser.
25
25
  def self.view_issue(issue)
26
26
  issue_url = Redmine.issue_url(issue)
27
- print "Open planio issue in browser? [Y]es or anything else to exit: "
27
+ print "Open issue in browser? [Y]es or anything else to exit: "
28
28
  `open #{issue_url.to_s}` if gets.chomp == "Y"
29
29
  puts "Staging completed! Exiting..."
30
30
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "redmine_stagecoach"
8
- s.version = "0.5.3"
8
+ s.version = "0.6.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oli Barnett"]
12
- s.date = "2012-01-26"
12
+ s.date = "2012-02-06"
13
13
  s.description = "Git/capistrano workflow automation script with Redmine & Github issue integration"
14
14
  s.email = "o.barnett@digitaleseiten.de"
15
15
  s.executables = ["stagecoach"]
@@ -56,7 +56,6 @@ Gem::Specification.new do |s|
56
56
  s.add_development_dependency(%q<shoulda>, [">= 0"])
57
57
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
58
58
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
59
- s.add_development_dependency(%q<rcov>, [">= 0"])
60
59
  else
61
60
  s.add_dependency(%q<activeresource>, [">= 0"])
62
61
  s.add_dependency(%q<ghi>, [">= 0"])
@@ -65,7 +64,6 @@ Gem::Specification.new do |s|
65
64
  s.add_dependency(%q<shoulda>, [">= 0"])
66
65
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
66
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
68
- s.add_dependency(%q<rcov>, [">= 0"])
69
67
  end
70
68
  else
71
69
  s.add_dependency(%q<activeresource>, [">= 0"])
@@ -75,7 +73,6 @@ Gem::Specification.new do |s|
75
73
  s.add_dependency(%q<shoulda>, [">= 0"])
76
74
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
77
75
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
78
- s.add_dependency(%q<rcov>, [">= 0"])
79
76
  end
80
77
  end
81
78
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_stagecoach
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-26 00:00:00.000000000Z
12
+ date: 2012-02-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource
16
- requirement: &70101551536900 !ruby/object:Gem::Requirement
16
+ requirement: &70339518370680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70101551536900
24
+ version_requirements: *70339518370680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ghi
27
- requirement: &70101551536420 !ruby/object:Gem::Requirement
27
+ requirement: &70339518366500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70101551536420
35
+ version_requirements: *70339518366500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: trollop
38
- requirement: &70101551535940 !ruby/object:Gem::Requirement
38
+ requirement: &70339518361640 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70101551535940
46
+ version_requirements: *70339518361640
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: capistrano
49
- requirement: &70101551535460 !ruby/object:Gem::Requirement
49
+ requirement: &70339518356740 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70101551535460
57
+ version_requirements: *70339518356740
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: shoulda
60
- requirement: &70101551534980 !ruby/object:Gem::Requirement
60
+ requirement: &70339518354140 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70101551534980
68
+ version_requirements: *70339518354140
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &70101551534500 !ruby/object:Gem::Requirement
71
+ requirement: &70339518348360 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70101551534500
79
+ version_requirements: *70339518348360
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &70101551534020 !ruby/object:Gem::Requirement
82
+ requirement: &70339518345820 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,18 +87,7 @@ dependencies:
87
87
  version: 1.6.4
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70101551534020
91
- - !ruby/object:Gem::Dependency
92
- name: rcov
93
- requirement: &70101551533540 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0'
99
- type: :development
100
- prerelease: false
101
- version_requirements: *70101551533540
90
+ version_requirements: *70339518345820
102
91
  description: Git/capistrano workflow automation script with Redmine & Github issue
103
92
  integration
104
93
  email: o.barnett@digitaleseiten.de
@@ -144,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
133
  version: '0'
145
134
  segments:
146
135
  - 0
147
- hash: 65861914571469357
136
+ hash: 4109014189137184230
148
137
  required_rubygems_version: !ruby/object:Gem::Requirement
149
138
  none: false
150
139
  requirements: