socialcast-git-extensions 0.12.2 → 1.0.0

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.12.2
1
+ 1.0.0
data/bin/git-integrate CHANGED
@@ -1,14 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # if the branch has already been integrated, the tickets can be inferred and looked up from jira
4
+ # usage:
5
+ # git integrate <ticket_id> <ticket_id2>...
6
+
3
7
  require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb')
4
8
  include Socialcast
5
9
 
6
- assert_tickets_provided
10
+ branch = current_branch
11
+ tickets = assert_tickets_provided(ARGV, branch)
7
12
 
8
13
  run_cmd 'git update'
9
-
10
- branch = current_branch
11
14
  integrate(branch, 'staging')
12
15
 
13
- update_tickets :branch => branch, :in_staging => true
14
- start_tickets
16
+ update_tickets tickets, :branch => branch, :in_staging => true
17
+ start_tickets tickets
data/bin/git-promote CHANGED
@@ -3,14 +3,13 @@
3
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb')
4
4
  include Socialcast
5
5
 
6
- assert_tickets_provided
6
+ branch = current_branch
7
+ tickets = assert_tickets_provided(ARGV, branch)
7
8
 
8
9
  run_cmd 'git update'
9
-
10
- branch = current_branch
11
10
  integrate(branch, 'next_release')
12
11
 
13
- update_tickets :branch => branch, :in_staging => true
14
- resolve_tickets
12
+ update_tickets tickets, :branch => branch, :in_staging => true
13
+ resolve_tickets tickets
15
14
 
16
15
  integrate(branch, 'staging')
data/bin/git-release CHANGED
@@ -7,17 +7,16 @@ include Socialcast
7
7
  branch = current_branch
8
8
  raise "Cannot release reserved branch" if %w{master staging}.include?(branch)
9
9
 
10
- assert_tickets_provided
10
+ tickets = assert_tickets_provided(ARGV, branch)
11
11
 
12
12
  exit unless Readline.readline("This will release #{branch} to production. Are you sure (y/n)? ") == 'y'
13
13
 
14
14
  run_cmd 'git update'
15
-
16
15
  integrate branch, 'master'
17
16
 
18
- update_tickets :branch => branch
19
- release_tickets
17
+ update_tickets tickets, :branch => branch
18
+ release_tickets tickets
20
19
 
21
- run_cmd "git promote #{ARGV.join(' ')}"
22
- run_cmd "git integrate #{ARGV.join(' ')}"
20
+ integrate branch, 'next_release'
21
+ integrate branch, 'staging'
23
22
  run_cmd "grb rm #{branch}"
@@ -30,16 +30,11 @@ branches.each do |branch|
30
30
  puts "\n\nChecking state of branch #{branch}:"
31
31
  if branches(:merged => true, :remote => true).include?(branch)
32
32
  puts "All changes in #{branch} have been merged into master"
33
- issues_in_branch = associated_tickets(branch)
34
- puts "Related tickets on branch #{branch}: #{issues_in_branch.collect(&:key).join(' ')}"
35
-
36
- issues_in_branch.each do |issue|
33
+ releasable_tickets = tickets_from_branch(branch).select do |issue|
37
34
  puts "#{issue.key} - #{issue.summary}"
38
- next unless Readline.readline("Mark this issue as released? (y/n)? ") == 'y'
39
-
40
- release_action = '101'
41
- jira_server.progressWorkflowAction issue.key, release_action, []
35
+ Readline.readline("Mark this issue as released? (y/n)? ") == 'y'
42
36
  end
37
+ release_tickets releasable_tickets
43
38
  else
44
39
  puts "#{branch} has NOT yet been merged into master"
45
40
  end
@@ -45,52 +45,59 @@ module Socialcast
45
45
  end
46
46
  end
47
47
 
48
- def assert_tickets_provided
49
- raise "JIRA ticket is required to run this process" unless tickets.any?
48
+ def assert_tickets_provided(ticket_ids, branch)
49
+ tickets = tickets_from_branch_and_arguments(ticket_ids, branch)
50
+ raise "JIRA ticket id or existing JIRA Git Branch is required to run this process" unless tickets.any?
51
+ tickets
50
52
  end
51
- def tickets
52
- ARGV
53
+ def tickets_from_branch_and_arguments(ticket_ids, branch)
54
+ tickets_from_arguments(ticket_ids) + tickets_from_branch(branch)
53
55
  end
54
- def update_tickets(options = {})
56
+ def tickets_from_arguments(ticket_ids)
57
+ ticket_ids.collect do |key|
58
+ jira_server.getIssue key
59
+ end
60
+ end
61
+ def tickets_from_branch(branch)
62
+ jira_server.getIssuesFromJqlSearch "project = 'SCWEBAPP' and 'Git Branch' ~ '#{branch}'", 1000
63
+ end
64
+ def update_tickets(tickets, options = {})
55
65
  tickets.each do |ticket|
66
+ puts "Updating ticket: #{ticket.key} - #{ticket.summary}"
56
67
  fields = []
57
68
  fields << Jira4R::V2::RemoteFieldValue.new(GIT_BRANCH_FIELD, [options[:branch]]) if options[:branch]
58
69
  fields << Jira4R::V2::RemoteFieldValue.new(IN_STAGING_FIELD, ['true']) if options[:in_staging]
59
70
  begin
60
- jira_server.updateIssue ticket, fields
71
+ jira_server.updateIssue ticket.key, fields
61
72
  rescue => e
62
73
  puts "Error updating ticket: #{e.message}"
63
74
  end
64
75
  end
65
76
  end
66
- def start_tickets
77
+ def start_tickets(tickets)
67
78
  tickets.each do |ticket|
68
79
  transition_ticket_if_has_status ticket, 1, 11
69
80
  end
70
81
  end
71
- def resolve_tickets
82
+ def resolve_tickets(tickets)
72
83
  tickets.each do |ticket|
73
84
  transition_ticket_if_has_status ticket, 3, 21
74
85
  end
75
86
  end
76
- def release_tickets
87
+ def release_tickets(tickets)
77
88
  tickets.each do |ticket|
78
89
  transition_ticket_if_has_status ticket, 5, 101
79
90
  end
80
91
  end
81
- def transition_ticket_if_has_status(ticket, status, action)
82
- issue = jira_server.getIssue ticket
92
+ def transition_ticket_if_has_status(issue, status, action)
83
93
  if issue.status == status.to_s
84
94
  begin
85
- jira_server.progressWorkflowAction ticket, action.to_s, []
95
+ jira_server.progressWorkflowAction issue.key, action.to_s, []
86
96
  rescue => e
87
97
  puts "Error updating ticket: #{e.message}"
88
98
  end
89
99
  end
90
100
  end
91
- def associated_tickets(branch)
92
- jira_server.getIssuesFromJqlSearch "project = 'SCWEBAPP' and 'Git Branch' ~ '#{branch}'", 1000
93
- end
94
101
 
95
102
  def run_cmd(cmd)
96
103
  puts "\nRunning: #{cmd}"
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{socialcast-git-extensions}
8
- s.version = "0.12.2"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Sonnek"]
12
- s.date = %q{2010-07-27}
12
+ s.date = %q{2010-07-30}
13
13
  s.description = %q{git extension scripts for socialcast workflow}
14
14
  s.email = %q{ryan@socialcast.com}
15
15
  s.executables = ["git-integrate", "git-promote", "git-prune-merged", "git-release", "git-release-pending", "git-reset-staging", "git-track", "git-update", "git-wtf"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcast-git-extensions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 43
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 12
9
- - 2
10
- version: 0.12.2
9
+ - 0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Sonnek
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-27 00:00:00 -05:00
18
+ date: 2010-07-30 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency