redmine_stagecoach 0.6.10 → 0.6.12

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'activeresource'
4
- gem 'ghi', :git => 'git://github.com/stephencelis/ghi.git'
4
+ gem 'ghi', "~> 0.9.0.dev1"#, :git => 'git://github.com/stephencelis/ghi.git'
5
5
  gem 'trollop'
6
6
  gem 'capistrano'
7
7
 
data/Gemfile.lock CHANGED
@@ -1,9 +1,3 @@
1
- GIT
2
- remote: git://github.com/stephencelis/ghi.git
3
- revision: 1eef298c50744b54d06925d70c5bc26225f51d3d
4
- specs:
5
- ghi (0.9.0.20120501)
6
-
7
1
  GEM
8
2
  remote: http://rubygems.org/
9
3
  specs:
@@ -23,14 +17,15 @@ GEM
23
17
  net-sftp (>= 2.0.0)
24
18
  net-ssh (>= 2.0.14)
25
19
  net-ssh-gateway (>= 1.1.0)
20
+ ghi (0.9.0.dev1)
26
21
  git (1.2.5)
27
- highline (1.6.11)
22
+ highline (1.6.12)
28
23
  i18n (0.6.0)
29
24
  jeweler (1.6.4)
30
25
  bundler (~> 1.0)
31
26
  git (>= 1.2.5)
32
27
  rake
33
- multi_json (1.3.2)
28
+ multi_json (1.3.5)
34
29
  net-scp (1.0.4)
35
30
  net-ssh (>= 1.99.1)
36
31
  net-sftp (2.0.5)
@@ -53,7 +48,7 @@ DEPENDENCIES
53
48
  activeresource
54
49
  bundler (~> 1.0.0)
55
50
  capistrano
56
- ghi!
51
+ ghi (~> 0.9.0.dev1)
57
52
  jeweler (~> 1.6.4)
58
53
  shoulda
59
54
  trollop
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.10
1
+ 0.6.12
data/bin/stagecoach CHANGED
@@ -4,7 +4,8 @@ require File.dirname(__FILE__) + '/../lib/stagecoach.rb'
4
4
 
5
5
  module Stagecoach
6
6
  VERSION = File.open(File.dirname(__FILE__) + '/../VERSION').read
7
- CONFIG_FILE = `pwd`.chomp + '/.stagecoach~'
7
+ CONFIG_FILE = `pwd`.chomp + '/.stagecoach'
8
+ OLD_CONFIG_FILE = `pwd`.chomp + '/.stagecoach~'
8
9
 
9
10
  # Command line options courtesy of the Trollop gem.
10
11
  opts = CommandLine.trollop
@@ -101,7 +102,7 @@ module Stagecoach
101
102
  exit
102
103
  end
103
104
 
104
- if redmine_issue.status.id != '1'
105
+ if redmine_issue.status.id != 1
105
106
  puts "Warning!".red
106
107
  puts "This issue is in status '#{redmine_issue.status.name}'"
107
108
  begin
@@ -119,6 +120,7 @@ module Stagecoach
119
120
 
120
121
  # Set the redmine issue status to 'In Bearbeitung'
121
122
  redmine_issue.status_id = 2
123
+ redmine_issue.assigned_to_id = config["redmine_user_id"]
122
124
  redmine_issue.save
123
125
  end
124
126
 
@@ -198,17 +200,11 @@ module Stagecoach
198
200
  # Create a Git issue.
199
201
  github_issue = Git.new_issue(redmine_issue.subject, body)
200
202
  github_issue_id = github_issue[/\d+/]
203
+ Git.assign_issue_to_me(github_issue_id)
201
204
 
202
205
  # Save it so we can reference it in commits using the magic of git hooks!
203
206
  config[Git.current_branch] = {:github_issue => github_issue_id, :redmine_issue => redmine_issue_number}
204
207
 
205
-
206
- print "Would you like to edit the issue on Github? [Y]es or anything else to continue: "
207
-
208
- if STDIN.gets.chomp == 'Y'
209
- Git.view_issue(github_issue_id)
210
- else
211
- end
212
208
  end
213
209
 
214
210
  # Github issues are easier.
@@ -236,7 +232,7 @@ module Stagecoach
236
232
  unless Git.branch_has_commits?(branch)
237
233
  puts "You don't have any uncommitted changes on branch #{branch}."
238
234
  puts "If you have already pushed your changes, run:"
239
- puts "stagecoach -d [deploy_branch] - default is 'staging'"
235
+ puts "stagecoach -d [deploy_branch]"
240
236
  puts "Otherwise, go make some commits!"
241
237
  puts "#%s for help" % "stagecoach -h".green
242
238
  puts "Exiting..."
@@ -263,8 +259,6 @@ module Stagecoach
263
259
  end
264
260
  end
265
261
 
266
- # TODO this needs removing if we implement the 'deploy to staging' stuff
267
- # Stop anybody deploying master to staging...
268
262
  case branch
269
263
  when 'master', 'Master', 'staging', 'Staging'
270
264
  puts "You can't use stagecoach to deploy your #{branch} branch.\nExiting..."
@@ -276,7 +270,7 @@ module Stagecoach
276
270
 
277
271
  puts "Push successful."
278
272
  unless opts[:deploy_given]
279
- "stagecoach -d [branch_name] to deploy (default is staging)."
273
+ "stagecoach -d [branch_name] to deploy."
280
274
  "exiting..."
281
275
  exit
282
276
  end
@@ -299,11 +293,23 @@ module Stagecoach
299
293
  # Redmine issue to feedback status
300
294
  if redmine_issue_number = config[from_branch][:redmine_issue]
301
295
  CommandLine.line_break
302
- puts "Attempting to change Redmine ticket status to 'Feedback' for you:"
303
- issue = Redmine.issue(redmine_issue_number)
304
- issue.status_id = 4
305
- issue.save
306
- Redmine.view_issue(issue)
296
+ puts "Would you like to change your Redmine ticket status to [F]eedback or [E]rledigt? Leave blank to do nothing: "
297
+ case STDIN.gets.chomp
298
+ when 'F', 'f'
299
+ puts "Attempting to change Redmine ticket status to 'Feedback' for you..."
300
+ issue = Redmine.issue(redmine_issue_number)
301
+ issue.status_id = 4
302
+ issue.save
303
+ puts "Status set to 'Feedback'"
304
+ when 'E', 'e'
305
+ puts "Attempting to change Redmine ticket status to 'Erledigt' for you..."
306
+ issue = Redmine.issue(redmine_issue_number)
307
+ issue.status_id = 5
308
+ issue.save
309
+ puts "Status set to 'Erledigt'"
310
+ else
311
+ end
312
+ puts 'Completed deploy.'
307
313
  end
308
314
  end
309
315
  end
@@ -30,7 +30,7 @@ end
30
30
  if gem_available?('redmine_stagecoach') == false
31
31
  exit
32
32
  else
33
- config = YAML::load(File.open(File.dirname(__FILE__) + '/../../.stagecoach~', 'r'))
33
+ config = YAML::load(File.open(File.dirname(__FILE__) + '/../../.stagecoach', 'r'))
34
34
  end
35
35
 
36
36
  # Find out what branch we are on
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require 'psych'
2
3
  require 'yaml'
3
4
  require 'fileutils'
@@ -6,7 +7,14 @@ module Stagecoach
6
7
  class Config
7
8
  class << self
8
9
  def new
9
- File.open(CONFIG_FILE, 'w') { |f| f.write("---\nredmine_site: none\nredmine_api_key: none")}
10
+ File.open(CONFIG_FILE, 'w') { |f| f.write("---\nredmine_site: \nredmine_api_key: \nredmine_user_id:")}
11
+ end
12
+
13
+ def check_if_outdated
14
+ if File.exist?(OLD_CONFIG_FILE) && !File.exist?(CONFIG_FILE)
15
+ FileUtils.move(OLD_CONFIG_FILE, CONFIG_FILE)
16
+ puts "Stagecoach config is now at #{CONFIG_FILE}"
17
+ end
10
18
  end
11
19
 
12
20
  def open
@@ -44,7 +52,8 @@ module Stagecoach
44
52
  # Create a config file if necessary
45
53
  case STDIN.gets.chomp
46
54
  when 'C'
47
- Config.new unless File.exist?(CONFIG_FILE)
55
+ Config.check_if_outdated
56
+ Config.new unless File.exist?(CONFIG_FILE)
48
57
  when 'Q'
49
58
  puts "Exiting..."
50
59
  exit
@@ -120,23 +129,39 @@ module Stagecoach
120
129
  # TODO Some verification of the input at this stage, for example test the
121
130
  # connection and have the user re-enter the details if necessary
122
131
  # http://api.rubyonrails.org/classes/ActiveResource/Connection.html#method-i-head
123
- loop do
132
+ config = Config.yaml_to_hash
133
+ unless config["redmine_site"] && config["redmine_api_key"] && config["redmine_user_id"]
124
134
  CommandLine.line_break
125
135
  print "Enter your redmine/planio repository, eg. https://digitaleseiten.plan.io: "
126
- redmine_repo = STDIN.gets.chomp
136
+ redmine_site = STDIN.gets.chomp
127
137
  print "Enter your API key for that repo: "
128
138
  redmine_api_key = STDIN.gets.chomp
129
139
 
130
- Config.save({"redmine_site" => redmine_repo, "redmine_api_key" => redmine_api_key})
140
+ RedmineApi::Client.instance_eval do
141
+ self.site = config["redmine_site"] || redmine_site
142
+ self.user = config["redmine_api_key"] || redmine_api_key
143
+ end
144
+
145
+ all_users = Redmine.users
146
+
147
+ puts "ID | User Name"
148
+ all_users.each {|u| puts printf("%-5d",u.attributes["id"]).to_s + " | " + u.attributes["firstname"] + " " + u.attributes["lastname"]} rescue puts "This one"
149
+
150
+ puts "Which id is yours?"
151
+ user_id = STDIN.gets.chomp
152
+ Config.save({"redmine_site" => redmine_site, "redmine_api_key" => redmine_api_key, "redmine_user_id" => user_id.to_i })
131
153
 
132
154
  CommandLine.line_break
133
155
  puts "Settings saved OK:"
134
- puts "Repository: " + redmine_repo
135
- puts "API Key: " + redmine_api_key
156
+ puts "Repository: " + redmine_site if redmine_site
157
+ puts "API Key: " + redmine_api_key if redmine_api_key
158
+ puts "User ID: " + user_id if user_id
136
159
  CommandLine.line_break
137
160
  puts "Exiting..."
138
- exit
139
161
  end
162
+
163
+ exit
164
+
140
165
  end
141
166
  end
142
167
  end
@@ -97,7 +97,11 @@ module Stagecoach
97
97
  end
98
98
 
99
99
  def new_issue(title, description)
100
- `ghi -o "#{title}" -m "#{description}"`
100
+ `ghi open -m "#{title}\n#{description}"`
101
+ end
102
+
103
+ def assign_issue_to_me(issue_number)
104
+ `ghi assign #{issue_number}`
101
105
  end
102
106
 
103
107
  def branch_has_commits?(branch)
@@ -109,12 +113,8 @@ module Stagecoach
109
113
  end
110
114
  end
111
115
 
112
- def view_issue(github_issue)
113
- `ghi -u#{github_issue}`
114
- end
115
-
116
116
  def issue(id)
117
- `ghi -l #{id}`
117
+ `ghi list #{id}`
118
118
  end
119
119
  end
120
120
  end
@@ -4,29 +4,37 @@ require 'active_resource'
4
4
  module RedmineApi
5
5
  class Client < ActiveResource::Base; end
6
6
  class Issue < RedmineApi::Client; end
7
+ class Users < RedmineApi::Client; end
7
8
  end
8
9
 
9
10
  module Stagecoach
10
11
  class Redmine
11
- def self.issue(issue_number)
12
- return RedmineApi::Issue.find(issue_number)
13
- end
12
+ class << self
14
13
 
15
- def self.issue_url(issue)
16
- # originally this was:
17
- #
18
- # RedmineApi::Client.site + "/issues/" + issue.id
19
- #
20
- # but this caused URI merge errors on some setups.
21
- "#{RedmineApi::Client.site}/issues/#{issue.id}"
22
- end
14
+ def users
15
+ RedmineApi::Users.find(:all, :params => {:nometa => 1})
16
+ end
17
+
18
+ def issue(issue_number)
19
+ return RedmineApi::Issue.find(issue_number)
20
+ end
21
+
22
+ def issue_url(issue)
23
+ # originally this was:
24
+ #
25
+ # RedmineApi::Client.site + "/issues/" + issue.id
26
+ #
27
+ # but this caused URI merge errors on some setups.
28
+ "#{RedmineApi::Client.site}/issues/#{issue.id}"
29
+ end
23
30
 
24
- # Open the issue in a browser.
25
- def self.view_issue(issue)
26
- issue_url = Redmine.issue_url(issue)
31
+ # Open the issue in a browser.
32
+ def view_issue(issue)
33
+ issue_url = Redmine.issue_url(issue)
27
34
  print "Open issue in browser? [Y]es or anything else to exit: "
28
35
  `open #{issue_url.to_s}` if gets.chomp == "Y"
29
36
  puts "Staging completed! Exiting..."
37
+ end
30
38
  end
31
39
  end
32
40
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "redmine_stagecoach"
8
- s.version = "0.6.10"
8
+ s.version = "0.6.12"
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-05-04"
12
+ s.date = "2012-05-18"
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"]
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
42
42
  s.homepage = "http://github.com/omnikron/stagecoach"
43
43
  s.licenses = ["MIT"]
44
44
  s.require_paths = ["lib"]
45
- s.rubygems_version = "1.8.18"
45
+ s.rubygems_version = "1.8.24"
46
46
  s.summary = "Stagecoach is in ur Redmine, automating ur Git workflow."
47
47
 
48
48
  if s.respond_to? :specification_version then
@@ -50,7 +50,7 @@ Gem::Specification.new do |s|
50
50
 
51
51
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
52
  s.add_runtime_dependency(%q<activeresource>, [">= 0"])
53
- s.add_runtime_dependency(%q<ghi>, [">= 0"])
53
+ s.add_runtime_dependency(%q<ghi>, ["~> 0.9.0.dev1"])
54
54
  s.add_runtime_dependency(%q<trollop>, [">= 0"])
55
55
  s.add_runtime_dependency(%q<capistrano>, [">= 0"])
56
56
  s.add_development_dependency(%q<shoulda>, [">= 0"])
@@ -58,7 +58,7 @@ Gem::Specification.new do |s|
58
58
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
59
59
  else
60
60
  s.add_dependency(%q<activeresource>, [">= 0"])
61
- s.add_dependency(%q<ghi>, [">= 0"])
61
+ s.add_dependency(%q<ghi>, ["~> 0.9.0.dev1"])
62
62
  s.add_dependency(%q<trollop>, [">= 0"])
63
63
  s.add_dependency(%q<capistrano>, [">= 0"])
64
64
  s.add_dependency(%q<shoulda>, [">= 0"])
@@ -67,7 +67,7 @@ Gem::Specification.new do |s|
67
67
  end
68
68
  else
69
69
  s.add_dependency(%q<activeresource>, [">= 0"])
70
- s.add_dependency(%q<ghi>, [">= 0"])
70
+ s.add_dependency(%q<ghi>, ["~> 0.9.0.dev1"])
71
71
  s.add_dependency(%q<trollop>, [">= 0"])
72
72
  s.add_dependency(%q<capistrano>, [">= 0"])
73
73
  s.add_dependency(%q<shoulda>, [">= 0"])
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.6.10
4
+ version: 0.6.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-04 00:00:00.000000000Z
12
+ date: 2012-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource
@@ -32,17 +32,17 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '0'
37
+ version: 0.9.0.dev1
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '0'
45
+ version: 0.9.0.dev1
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: trollop
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  segments:
170
170
  - 0
171
- hash: 3067216657449835751
171
+ hash: -1007617363068209098
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  none: false
174
174
  requirements:
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  requirements: []
179
179
  rubyforge_project:
180
- rubygems_version: 1.8.18
180
+ rubygems_version: 1.8.24
181
181
  signing_key:
182
182
  specification_version: 3
183
183
  summary: Stagecoach is in ur Redmine, automating ur Git workflow.