redmine_stagecoach 0.6.12 → 0.6.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.12
1
+ 0.6.13
data/bin/stagecoach CHANGED
@@ -56,13 +56,6 @@ module Stagecoach
56
56
  end
57
57
  end
58
58
 
59
-
60
- # Set up redmine client config.
61
- RedmineApi::Client.instance_eval do
62
- self.site = config["redmine_site"]
63
- self.user = config["redmine_api_key"]
64
- end
65
-
66
59
  # Checks for uncommitted/unstashed changes and aborts if present.
67
60
  if Git.changes != ''
68
61
  puts "You have uncommitted changes:".red
@@ -72,10 +65,39 @@ module Stagecoach
72
65
  exit
73
66
  end
74
67
 
68
+
69
+ # ------------------------------------------------------------------
70
+ # Git branch operations: list, cleanup
71
+ # ------------------------------------------------------------------
72
+
73
+ if opts[:list]
74
+ CommandLine.line_break
75
+ puts "Local Git Branches created with Stagecoach:"
76
+ puts "%s = already merged into master" % "Green".green
77
+ puts "%s = not merged into master" % "Red".red
78
+ CommandLine.line_break
79
+ local_stagecoach_branches = {}
80
+ config.each { |k,v| local_stagecoach_branches[k] = v unless k =~ /redmine_site|redmine_api_key|redmine_user_id/}
81
+ local_stagecoach_branches.keys.sort.each do |branch_name|
82
+ branch_attributes = local_stagecoach_branches[branch_name]
83
+
84
+ if Git.branches.select { |a| a.match(/\W+#{branch_name}/) }
85
+ puts Git.branch_merged_to_master?(branch_name) ? branch_name.green : branch_name.red
86
+ end
87
+ end
88
+ exit
89
+ end
90
+
75
91
  # ------------------------------------------------------------------
76
92
  # Initial stage - set up branch and git issue.
77
93
  # ------------------------------------------------------------------
78
94
 
95
+ # Set up redmine client config.
96
+ RedmineApi::Client.instance_eval do
97
+ self.site = config["redmine_site"]
98
+ self.user = config["redmine_api_key"]
99
+ end
100
+
79
101
  unless opts[:deploy] or opts[:push]
80
102
 
81
103
  # If no issue argument has been given.
@@ -183,10 +205,10 @@ module Stagecoach
183
205
 
184
206
  # Issue handling.
185
207
  if opts[:github]
186
- config[Git.current_branch] = {:github_issue => opts[:github]}
208
+ config[Git.current_branch] = {'github_issue' => opts[:github]}
187
209
  #TODO check that github issue is not assigned to somebody already
188
210
  elsif opts[:redmine]
189
- config[Git.current_branch] = {:redmine_issue => redmine_issue_number}
211
+ config[Git.current_branch] = {'redmine_issue' => redmine_issue_number}
190
212
  end
191
213
 
192
214
  # Set up the related issue for this branch.
@@ -203,7 +225,7 @@ module Stagecoach
203
225
  Git.assign_issue_to_me(github_issue_id)
204
226
 
205
227
  # Save it so we can reference it in commits using the magic of git hooks!
206
- config[Git.current_branch] = {:github_issue => github_issue_id, :redmine_issue => redmine_issue_number}
228
+ config[Git.current_branch] = {'github_issue' => github_issue_id, 'redmine_issue' => redmine_issue_number}
207
229
 
208
230
  end
209
231
 
@@ -30,6 +30,7 @@ For more info see the readme at https://github.com/omnikron/stagecoach#readme
30
30
  opt :deploy, "Use this option to deploy from your current branch to any branch you choose, eg. stagecoach -d staging", :type => :string
31
31
  opt :from, "Use this option to set the branch you want to branch off from. Default is master", :type => :string, :default => "master"
32
32
  opt :github, "Enter your github issue number here, eg. stagecoach -g 1234 (optional)", :type => :string
33
+ opt :list, "Use this to list local branches which you have created with Stagecoach"
33
34
  opt :push, "Use this option to push your changes to your remote branch (will be created if necessary)"
34
35
  opt :redmine, "Enter your redmine/planio issue number here, eg. stagecoach -r 1234 (optional)", :type => :string
35
36
  opt :setup, "Use this the first time you run stagecoach to save your redmine repository and api key"
@@ -2,7 +2,7 @@ module Stagecoach
2
2
  class Git
3
3
  class << self
4
4
  def branches
5
- `git branch`.split("\n")
5
+ `git branch`.split("\n").each {|a| a.lstrip! }
6
6
  end
7
7
 
8
8
  def global_config(header, config)
@@ -29,6 +29,13 @@ module Stagecoach
29
29
  end
30
30
  end
31
31
 
32
+ def branch_merged_to_master?(branch)
33
+ list = `git branch --merged`.split("\n").collect(&:strip)
34
+ list << Git.current_branch
35
+ list.include?(branch.strip)
36
+ end
37
+
38
+
32
39
  def correct_branch?
33
40
  CommandLine.line_break
34
41
  print "You are currently in local branch: #{Git.current_branch.red} \nAre these details correct? ([Y]es or [Q]uit): "
@@ -74,7 +81,12 @@ module Stagecoach
74
81
  Git.change_to_branch(to_branch)
75
82
  puts `git pull origin #{to_branch}`
76
83
  puts `git merge #{from_branch}`
77
- raise 'merge failed' if $?.exitstatus != 0
84
+ begin
85
+ raise 'Merge failed' if $?.exitstatus != 0
86
+ rescue
87
+ puts $!.class.name + ": " + $!.message # $! refers to the last error object
88
+ puts "Please resolve the merge conflict and deploy again. Exiting..."
89
+ end
78
90
  end
79
91
 
80
92
  def push(branch)
@@ -25,7 +25,7 @@ module Stagecoach
25
25
  # RedmineApi::Client.site + "/issues/" + issue.id
26
26
  #
27
27
  # but this caused URI merge errors on some setups.
28
- "#{RedmineApi::Client.site}/issues/#{issue.id}"
28
+ "#{RedmineApi::Client.site}issues/#{issue.id}"
29
29
  end
30
30
 
31
31
  # Open the issue in a browser.
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "redmine_stagecoach"
8
- s.version = "0.6.12"
8
+ s.version = "0.6.13"
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"]
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.12
4
+ version: 0.6.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  segments:
170
170
  - 0
171
- hash: -1007617363068209098
171
+ hash: 2934984471721959034
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  none: false
174
174
  requirements: