papa 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7f41dc463422d1dbf50d5a78d6d28e6bac9c0197
4
- data.tar.gz: b93823396cca9585dbf8b8dab8efb5292b8de2ab
2
+ SHA256:
3
+ metadata.gz: 3d3673db02cd16b804010fa3df5884f1b2e97d33e8a3dca2609af7eb0a20614a
4
+ data.tar.gz: 5cf1be5f8044e36c2dfe57cf573234ca2922a0a476cb635e75762488687832c9
5
5
  SHA512:
6
- metadata.gz: 8fd359891d3d637446ffce516aead288b6d7218c4fb1d2d40a81c6e74d3fe335249981014bb58e376ce8576604b7fa638908849fa983fd8375b018aa39c9b7ec
7
- data.tar.gz: a733d8f6821fea1d56b903ac53bfa555727098bb19a4fb5915cbbc299cd466556b13c147f409c8c4af3884ae2e2834b4ea856a4050ef630b1326f5a5a7023d6f
6
+ metadata.gz: 2e00a8b49144a6f15b5cb7ffc569238b977c08e0277b9731c3f0a7e8403d8e2e083a864b05a44f82efa0bdf680f23832e8cdce48f158b569aaed685ff846312b
7
+ data.tar.gz: 4832a8e1f7547d96469f6a1d8f7be71479d53df9235717e6f2ee7e87c3f41cc7c36e2b100f4644547b3be8d271719d8e256af5b8076594675a7f1f02840ab15b
@@ -0,0 +1 @@
1
+ slack_webhook: https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+ * All output will be logged to a log file in the current working directory
5
+ * Properly determine whether to build or redeploy an integration or hotfix environment
6
+ * Destroy old outdated integration or hotfix environments if a different branch is to be deployed
7
+ * Slack notifications for integration and hotfix deployments
8
+ * Add documentation for the `-b` option in `papa hotfix finish`
9
+ * Minor documentation formatting changes
10
+
11
+ ## 0.6.3
12
+ * Fixed bug when cleaning up after a failed `git merge`
13
+ * Exit out of `papa [hotfix, release] finish` when one of the base branches fails to be merged on
14
+
3
15
  ## 0.6.2
4
16
  * Reset build branch from origin every time a new branch is added
5
17
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Papa [![Gem Version](https://badge.fury.io/rb/papa.svg)](https://badge.fury.io/rb/papa) [![Build Status](https://travis-ci.org/b-ggs/papa.svg?branch=master)](https://travis-ci.org/b-ggs/papa)
1
+ # Papa [![Version](https://img.shields.io/gem/v/papa.svg?style=flat)](https://rubygems.org/gems/papa) [![Build Status](https://img.shields.io/travis/b-ggs/papa/master.svg?style=flat)](https://travis-ci.org/b-ggs/papa)
2
2
 
3
3
  Helper tool for inDinero's git workflow. Ako ang papa mo.
4
4
 
@@ -7,20 +7,40 @@ Helper tool for inDinero's git workflow. Ako ang papa mo.
7
7
  * [Getting Started](#getting-started)
8
8
  * [Commands](#commands)
9
9
  * [papa release](#papa-release)
10
+ * [start](#starting-a-release-branch)
11
+ * [add](#adding-feature-branches-to-a-release-branch)
12
+ * [finish](#finishing-a-release-branch)
10
13
  * [papa hotfix](#papa-hotfix)
14
+ * [start](#starting-a-hotfix-branch)
15
+ * [add](#adding-bugfix-branches-to-a-hotfix-branch)
16
+ * [deploy](#deploying-a-hotfix-branch-to-a-hotfix-environment)
17
+ * [finish](#finishing-a-hotfix-branch)
11
18
  * [papa integration](#papa-integration)
12
- * [papa deploy](#papa-deploy)
19
+ * [start](#starting-an-integration-branch)
20
+ * [add](#adding-branches-to-an-integration-branch)
21
+ * [deploy](#deploying-an-integration-branch-to-an-integration-environment)
13
22
  * [papa sandbox](#papa-sandbox)
23
+ * [generate](#papa-sandbox)
14
24
 
15
25
  ## Getting Started
16
26
 
17
- Install `papa` from Rubygems.
27
+ ### Install `papa` from Rubygems
18
28
 
19
29
  ```
20
30
  $ gem install papa
21
31
  ```
22
32
 
23
- That's it, you're ready to go!
33
+ ### Set up configs
34
+
35
+ Create a config file in `~/.papa.config.yml`.
36
+
37
+ An example config file can be found in `.papa.config.yml.example`.
38
+
39
+ tl;dr:
40
+
41
+ ```
42
+ echo 'slack_webhook: YOUR_SLACK_WEBHOOK_URL_HERE' > ~/.papa.config.yml
43
+ ```
24
44
 
25
45
  ## Usage
26
46
 
@@ -86,7 +106,11 @@ $ papa hotfix deploy -v 17.12.0
86
106
  #### Finishing a hotfix branch
87
107
 
88
108
  ```
89
- $ papa release hotfix -v 17.12.0
109
+ $ papa hotfix finish -v 17.12.0
110
+ ```
111
+
112
+ ```
113
+ $ papa hotfix finish -v 17.12.0 -b release/17.11.0
90
114
  ```
91
115
 
92
116
  ### `papa integration`
data/USAGE.md CHANGED
@@ -121,15 +121,23 @@ $ papa hotfix deploy -v 17.12.0
121
121
  The finished hotfix branch will be merged to `master` and `develop`. The updated `master` and `develop` branches will be pushed to origin.
122
122
 
123
123
  ```
124
- $ papa release hotfix -v, --version=VERSION
124
+ $ papa release hotfix -v, --version=VERSION [-b, --additional-branches=one two three]
125
125
  ```
126
126
 
127
+ If `--additional-branches` is specified, the hotfix branch will also be merged to the specified branches.
128
+
127
129
  #### Sample Usage:
128
130
 
129
131
  ```
130
132
  $ papa release hotfix -v 17.12.0
131
133
  ```
132
134
 
135
+ If the hotfix branch will also be merged to a release branch:
136
+
137
+ ```
138
+ $ papa hotfix finish -v 17.12.0 -b release/17.11.0
139
+ ```
140
+
133
141
  ## `papa integration`
134
142
 
135
143
  #### Starting an integration branch
@@ -17,6 +17,9 @@ module Papa
17
17
 
18
18
  def cleanup
19
19
  super
20
+ require 'papa/command/git/merge_abort'
21
+ require 'papa/command/git/checkout'
22
+
20
23
  Command::Git::MergeAbort.new.run
21
24
  Command::Git::Checkout.new(current_branch).run
22
25
  end
@@ -4,10 +4,8 @@ module Papa
4
4
  module Command
5
5
  module Larga
6
6
  class Deploy < Command::Base
7
- RELEASE_OR_HOTFIX_LIFESPAN = '3d'
8
- DEFAULT_LIFESPAN = '4h'
9
- RELEASE_OR_HOTFIX_PROTECTION = 'off'
10
- DEFAULT_PROTECTION = 'on'
7
+ RELEASE_OR_INTEGRATION_LIFESPAN = '3d'
8
+ RELEASE_OR_INTEGRATION_PROTECTION = 'off'
11
9
 
12
10
  def initialize(options)
13
11
  @options = options
@@ -21,7 +19,7 @@ module Papa
21
19
  @stdout = ''
22
20
  IO.popen(command).each do |line|
23
21
  @stdout << line
24
- puts line
22
+ Helper::Output.info line
25
23
  end
26
24
  self
27
25
  end
@@ -38,32 +36,45 @@ module Papa
38
36
  private
39
37
 
40
38
  def larga_options
39
+ action = determine_action
41
40
  branch = @options[:branch]
42
- lifespan =
43
- if branch_is_release_or_hotfix?
44
- RELEASE_OR_HOTFIX_LIFESPAN
45
- else
46
- DEFAULT_LIFESPAN
47
- end
48
- protection =
49
- if branch_is_release_or_hotfix?
50
- RELEASE_OR_HOTFIX_PROTECTION
51
- else
52
- DEFAULT_PROTECTION
53
- end
41
+ lifespan = RELEASE_OR_INTEGRATION_LIFESPAN
42
+ protection = RELEASE_OR_INTEGRATION_PROTECTION
54
43
  hostname = @options[:hostname]
55
44
 
56
45
  options = []
57
- options << '-action build'
46
+ options << "-action #{action}"
58
47
  options << "-branch #{branch}"
59
48
  options << "-lifespan #{lifespan}"
60
49
  options << "-protection #{protection}"
61
- options << "-hostname #{hostname}" if hostname
50
+ options << "-hostname #{hostname}"
62
51
  options
63
52
  end
64
53
 
65
- def branch_is_release_or_hotfix?
66
- ['release', 'hotfix'].any? { |s| @options[:branch].include?(s) }
54
+ def determine_action
55
+ previous_branches = `larga -action show -branch x | grep https://#{@options[:hostname]} | awk '{print $1}'`.chomp.split("\n")
56
+ if previous_branches.empty?
57
+ # If there are no old instances with the same hostname, continue building instance.
58
+ return 'build'
59
+ elsif previous_branches.count == 1 && previous_branches.include?(@options[:branch])
60
+ # If the old instance has the same branch name, skip building and just deploy.
61
+ return 'deploy'
62
+ else
63
+ # If all else fails, destroy old instance(s), and continue building.
64
+ destroy_old_instances(previous_branches)
65
+ return 'build'
66
+ end
67
+ end
68
+
69
+ def destroy_old_instances(previous_branches)
70
+ Helper::Output.stdout "Destroying old instances..."
71
+ previous_branches.each do |previous_branch|
72
+ destroy_command = "larga -action destroy -branch #{previous_branch}"
73
+ Helper::Output.stdout "Running #{destroy_command.bold}..."
74
+ IO.popen(destroy_command).each do |line|
75
+ Helper::Output.info line
76
+ end
77
+ end
67
78
  end
68
79
  end
69
80
  end
@@ -0,0 +1,33 @@
1
+ require 'papa/command/base'
2
+ require 'papa/helper/config'
3
+ require 'json'
4
+
5
+ module Papa
6
+ module Command
7
+ module Slack
8
+ class SendMessage < Command::Base
9
+ def initialize(build_type, hostname, action)
10
+ @build_type = build_type
11
+ @hostname = hostname
12
+ @action = action
13
+
14
+ command = "curl -X POST --data-urlencode 'payload=#{payload.to_json}' #{webhook_url}"
15
+ super(command)
16
+ end
17
+
18
+ private
19
+
20
+ def payload
21
+ url = "https://#{@hostname}.indinerocorp.com"
22
+ {
23
+ 'text' => "<!channel> Deployment to <#{url}|#{@build_type}> #{@action}."
24
+ }
25
+ end
26
+
27
+ def webhook_url
28
+ Helper::Config.read["slack_webhook"]
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ require 'yaml'
2
+ require 'papa/helper/output'
3
+
4
+ module Papa
5
+ module Helper
6
+ class Config
7
+ def self.read
8
+ return @config if defined?(@config)
9
+ exit_on_config_not_exists unless config_exists?
10
+ @config = YAML.load_file(config_path)
11
+ end
12
+
13
+ def self.config_path
14
+ "#{Dir.home}/.papa.config.yml"
15
+ end
16
+
17
+ def self.config_exists?
18
+ File.exists?(config_path)
19
+ end
20
+
21
+ def self.exit_on_config_not_exists
22
+ message = 'Cannot find config file.'
23
+ Helper::Output.failure message
24
+ info = <<-INFO
25
+ Make sure you have a valid config file in #{config_path}.
26
+ See README.md for more details.
27
+ INFO
28
+ Helper::Output.failure_info info
29
+ exit 1
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ module Papa
2
+ module Helper
3
+ class Logger
4
+ def self.log(message)
5
+ File.open(log_path, 'a+') do |file|
6
+ file.puts message
7
+ end
8
+ end
9
+
10
+ def self.log_path
11
+ return @log_path if defined?(@log_path)
12
+ command = ARGV.first(2).join('_')
13
+ timestamp = Time.now.strftime('%Y_%m_%d_%I_%M_%S')
14
+ @log_path = ['papa', command, timestamp].join('_') + '.log'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,38 +1,55 @@
1
- require 'date'
1
+ require 'papa/helper/logger'
2
2
 
3
3
  module Papa
4
4
  module Helper
5
- class Helper::Output
5
+ class Output
6
6
  REDIRECT_TO_NULL = '> /dev/null 2>&1'
7
7
 
8
8
  def self.stdout(message, options = {})
9
- puts build_output(message)
9
+ message = build_output(message)
10
+ puts message
11
+ Helper::Logger.log(message)
10
12
  end
11
13
 
12
14
  def self.stderr(message, options = {})
13
- STDERR.puts build_output(message)
15
+ message = build_output(message)
16
+ STDERR.puts message
17
+ Helper::Logger.log(message)
14
18
  end
15
19
 
16
20
  def self.error(message)
17
- stderr("ERROR: #{message}")
21
+ message = "ERROR: #{message}"
22
+ stderr(message)
23
+ Helper::Logger.log(message)
18
24
  end
19
25
 
20
26
  def self.success(message)
27
+ message.strip!
21
28
  puts
22
- puts message.strip.green
29
+ puts message.green
30
+ Helper::Logger.log(message)
23
31
  end
24
32
 
25
33
  def self.failure(message)
34
+ message.strip!
26
35
  STDERR.puts
27
- STDERR.puts message.strip.red
36
+ STDERR.puts message.red
37
+ Helper::Logger.log(message)
28
38
  end
29
39
 
30
40
  def self.success_info(message)
31
41
  puts message
42
+ Helper::Logger.log(message)
32
43
  end
33
44
 
34
45
  def self.failure_info(message)
35
46
  STDERR.puts message
47
+ Helper::Logger.log(message)
48
+ end
49
+
50
+ def self.info(message)
51
+ puts message
52
+ Helper::Logger.log(message)
36
53
  end
37
54
 
38
55
  def self.build_output(message)
@@ -40,7 +57,7 @@ module Papa
40
57
  end
41
58
 
42
59
  def self.timestamp
43
- DateTime.now.strftime('%H:%M:%S')
60
+ Time.now.strftime('%I:%M:%S %p')
44
61
  end
45
62
  end
46
63
  end
@@ -0,0 +1,46 @@
1
+ require 'papa/command/git/fetch'
2
+ require 'papa/command/git/checkout'
3
+ require 'papa/runner'
4
+ require 'papa/helper/output'
5
+
6
+ module Papa
7
+ module Task
8
+ class Base
9
+ def run
10
+ perform_task
11
+ result
12
+ end
13
+
14
+ private
15
+
16
+ def perform_task
17
+ runner = Runner.new(queue)
18
+ @success = runner.run
19
+ end
20
+
21
+ def result
22
+ if @success
23
+ success_message
24
+ else
25
+ failure_message
26
+ exit 1
27
+ end
28
+ end
29
+
30
+ def build_branch
31
+ @build_branch ||= "#{@build_type}/#{@version}"
32
+ end
33
+
34
+ def check_if_build_branch_exists
35
+ queue = [
36
+ Command::Git::Fetch.new('origin'),
37
+ Command::Git::Checkout.new(build_branch)
38
+ ]
39
+ runner = Runner.new(queue)
40
+ return if runner.run
41
+ Helper::Output.failure 'Build branch does not exist.'
42
+ exit 1
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,34 +1,36 @@
1
- require 'papa/helper/output'
2
- require 'papa/command/git/fetch'
3
- require 'papa/command/git/checkout'
1
+ require 'papa/task/base'
4
2
  require 'papa/command/git/reset_hard'
5
3
  require 'papa/command/git/rebase'
6
4
  require 'papa/command/git/push_force'
7
5
  require 'papa/command/git/merge'
8
6
  require 'papa/command/git/push'
9
7
  require 'papa/command/git/branch_delete'
10
- require 'papa/runner'
11
8
 
12
9
  module Papa
13
10
  module Task
14
11
  module Common
15
- class Add
16
- def run
17
- @build_branch ||= "#{@build_type}/#{@version}"
18
-
12
+ class Add < Base
13
+ def initialize
19
14
  check_if_build_branch_exists
20
15
  check_if_branches_are_given
21
-
22
- success = true
23
16
  @success_branches = []
24
17
  @failed_branches = []
18
+ end
25
19
 
26
- Helper::Output.stdout "Started adding branches to #{@build_branch.bold}."
20
+ private
27
21
 
22
+ def check_if_branches_are_given
23
+ return unless @branches.empty?
24
+ require 'papa/helper/vi'
25
+ vi_file_helper = Helper::Vi.new
26
+ @branches = vi_file_helper.run
27
+ end
28
+
29
+ def perform_task
30
+ @success = true
28
31
  @branches.each_with_index do |branch, index|
29
32
  Helper::Output.stdout "Adding branch #{branch.bold} (#{index + 1} of #{@branches.count})..."
30
33
  runner = Runner.new(queue(branch))
31
-
32
34
  if runner.run
33
35
  @success_branches << branch
34
36
  else
@@ -37,60 +39,39 @@ module Papa
37
39
  message: runner.last_error
38
40
  }
39
41
  @failed_branches << failed_branch
40
- success = false
42
+ @success = false
41
43
  end
42
44
  end
43
-
44
- success_and_failure_messages
45
-
46
- if !success
47
- exit 1
48
- end
49
- end
50
-
51
- private
52
-
53
- def check_if_build_branch_exists
54
- queue = [
55
- Command::Git::Fetch.new('origin'),
56
- Command::Git::Checkout.new(@build_branch)
57
- ]
58
- runner = Runner.new(queue)
59
- return if runner.run
60
- Helper::Output.failure 'Build branch does not exist.'
61
- exit 1
62
45
  end
63
46
 
64
47
  def queue(branch)
65
48
  [
66
- Command::Git::Checkout.new(@build_branch),
67
- Command::Git::ResetHard.new('origin', @build_branch),
49
+ Command::Git::Checkout.new(build_branch),
50
+ Command::Git::ResetHard.new('origin', build_branch),
68
51
  Command::Git::Checkout.new(branch),
69
52
  Command::Git::ResetHard.new('origin', branch),
70
- Command::Git::Rebase.new(@build_branch),
53
+ Command::Git::Rebase.new(build_branch),
71
54
  Command::Git::PushForce.new('origin', branch),
72
- Command::Git::Checkout.new(@build_branch),
55
+ Command::Git::Checkout.new(build_branch),
73
56
  Command::Git::Merge.new(branch),
74
57
  Command::Git::BranchDelete.new(branch),
75
- Command::Git::Push.new('origin', @build_branch)
58
+ Command::Git::Push.new('origin', build_branch)
76
59
  ]
77
60
  end
78
61
 
79
- def check_if_branches_are_given
80
- return unless @branches.empty?
81
- require 'papa/helper/vi'
82
- vi_file_helper = Helper::Vi.new
83
- @branches = vi_file_helper.run
84
- end
85
-
86
- def success_and_failure_messages
87
- success_message
88
- failure_message
62
+ def result
63
+ if @success_branches.count > 0
64
+ success_message
65
+ end
66
+ if @failed_branches.count > 0
67
+ failure_message
68
+ exit 1
69
+ end
89
70
  end
90
71
 
91
72
  def success_message
92
- return if @success_branches.empty?
93
- Helper::Output.success "Successfully added these branches to #{@build_branch}:\n"
73
+ success_message = "Successfully added these branches to #{build_branch}:\n"
74
+ Helper::Output.success(success_message)
94
75
  info = ''
95
76
  @success_branches.each_with_index do |branch, index|
96
77
  info << " #{index + 1}.) #{branch}\n"
@@ -99,9 +80,7 @@ module Papa
99
80
  end
100
81
 
101
82
  def failure_message
102
- return if @failed_branches.empty?
103
-
104
- Helper::Output.failure "Failed to add these branches to #{@build_branch}:\n"
83
+ Helper::Output.failure "Failed to add these branches to #{build_branch}:\n"
105
84
  info = ''
106
85
  @failed_branches.each_with_index do |failed_branch, index|
107
86
  branch = failed_branch[:branch]
@@ -110,11 +89,9 @@ module Papa
110
89
  info << " - #{message}\n"
111
90
  end
112
91
  info << "\n"
113
-
114
92
  branch_names = @failed_branches.map { |f| f[:branch] }
115
93
  info << "When the above problems are resolved, you can re-run this with:\n"
116
94
  info << " papa #{@build_type} add -v #{@version} -b #{branch_names.join(' ')}"
117
-
118
95
  Helper::Output.failure_info info
119
96
  end
120
97
  end
@@ -1,23 +1,14 @@
1
- require 'papa/helper/output'
1
+ require 'papa/task/base'
2
2
  require 'papa/command/larga/type'
3
3
  require 'papa/command/larga/deploy'
4
- require 'papa/runner'
4
+ require 'papa/command/slack/send_message'
5
5
 
6
6
  module Papa
7
7
  module Task
8
8
  module Common
9
- class Deploy
10
- def run
11
- @build_branch ||= "#{@build_type}/#{@version}"
12
-
13
- runner = Runner.new(queue)
14
-
15
- if runner.run
16
- success_message
17
- else
18
- failure_message
19
- exit 1
20
- end
9
+ class Deploy < Base
10
+ def initialize
11
+ check_if_build_branch_exists
21
12
  end
22
13
 
23
14
  private
@@ -25,13 +16,15 @@ module Papa
25
16
  def queue
26
17
  [
27
18
  Command::Larga::Type.new,
28
- Command::Larga::Deploy.new(deploy_options)
19
+ Command::Slack::SendMessage.new(@build_type, @hostname, 'started'),
20
+ Command::Larga::Deploy.new(deploy_options),
21
+ Command::Slack::SendMessage.new(@build_type, @hostname, 'done')
29
22
  ]
30
23
  end
31
24
 
32
25
  def deploy_options
33
26
  {
34
- branch: @build_branch,
27
+ branch: build_branch,
35
28
  hostname: @hostname
36
29
  }
37
30
  end
@@ -39,7 +32,7 @@ module Papa
39
32
  def success_message
40
33
  Helper::Output.success 'Successfully deployed larga instance.'
41
34
  info = ''
42
- info << " Branch: #{@build_branch}\n"
35
+ info << " Branch: #{build_branch}\n"
43
36
  info << " URL: https://#{@hostname}.indinerocorp.com\n"
44
37
  Helper::Output.success_info info
45
38
  end
@@ -47,7 +40,7 @@ module Papa
47
40
  def failure_message
48
41
  Helper::Output.failure 'There was a problem deploying larga instance.'
49
42
  info = ''
50
- info << " Branch: #{@build_branch}\n"
43
+ info << " Branch: #{build_branch}\n"
51
44
  Helper::Output.failure_info info
52
45
  end
53
46
  end
@@ -1,60 +1,41 @@
1
- require 'papa/command/git/fetch'
2
- require 'papa/command/git/checkout'
1
+ require 'papa/task/base'
3
2
  require 'papa/command/git/merge'
3
+ require 'papa/command/git/reset_hard'
4
4
  require 'papa/command/git/push'
5
5
  require 'papa/command/git/tag'
6
6
  require 'papa/command/git/tag_push'
7
- require 'papa/runner'
8
- require 'papa/helper/output'
9
7
 
10
8
  module Papa
11
9
  module Task
12
10
  module Common
13
- class Finish
14
- def run
15
- @build_branch ||= "#{@build_type}/#{@version}"
16
-
11
+ class Finish < Base
12
+ def initialize
17
13
  check_if_build_branch_exists
18
-
19
- success = true
20
14
  @success_branches = []
15
+ @failed_branches = []
16
+ end
21
17
 
18
+ private
19
+
20
+ def perform_task
21
+ @success = true
22
22
  @base_branches.each do |branch|
23
23
  runner = Runner.new(queue(branch))
24
-
25
24
  if runner.run
26
25
  @success_branches << branch
27
26
  else
28
- success = false
27
+ @failed_branches << branch
28
+ @success = false
29
29
  end
30
30
  end
31
-
32
- if success
33
- success_message
34
- else
35
- failure_message
36
- exit 1
37
- end
38
- end
39
-
40
- private
41
-
42
- def check_if_build_branch_exists
43
- queue = [
44
- Command::Git::Fetch.new('origin'),
45
- Command::Git::Checkout.new(@build_branch)
46
- ]
47
- runner = Runner.new(queue)
48
- return if runner.run
49
- Helper::Output.failure 'Build branch does not exist.'
50
- exit 1
51
31
  end
52
32
 
53
33
  def queue(branch)
54
34
  queue = [
55
- Command::Git::Checkout.new(@build_branch),
35
+ Command::Git::Checkout.new(build_branch),
56
36
  Command::Git::Checkout.new(branch),
57
- Command::Git::Merge.new(@build_branch),
37
+ Command::Git::ResetHard.new('origin', branch),
38
+ Command::Git::Merge.new(build_branch),
58
39
  Command::Git::Push.new('origin', branch)
59
40
  ]
60
41
  if @tag_name && branch == 'master'
@@ -64,8 +45,18 @@ module Papa
64
45
  queue
65
46
  end
66
47
 
48
+ def result
49
+ if @success_branches.count > 0
50
+ success_message
51
+ end
52
+ if @failed_branches.count > 0
53
+ failure_message
54
+ exit 1
55
+ end
56
+ end
57
+
67
58
  def success_message
68
- Helper::Output.success "Successfully merged #{@build_branch} to these branches:\n"
59
+ Helper::Output.success "Successfully merged #{build_branch} to these branches:\n"
69
60
  info = ''
70
61
  @success_branches.each_with_index do |branch, index|
71
62
  info << " #{index + 1}.) #{branch}\n"
@@ -74,10 +65,9 @@ module Papa
74
65
  end
75
66
 
76
67
  def failure_message
77
- failed_branches = @base_branches - @success_branches
78
- Helper::Output.failure "Failed to merge #{@build_branch} to these branches:\n"
68
+ Helper::Output.failure "Failed to merge #{build_branch} to these branches:\n"
79
69
  info = ''
80
- failed_branches.each_with_index do |branch, index|
70
+ @failed_branches.each_with_index do |branch, index|
81
71
  info << " #{index + 1}.) #{branch}\n"
82
72
  end
83
73
  Helper::Output.failure_info info
@@ -1,45 +1,29 @@
1
- require 'papa/command/git/fetch'
2
- require 'papa/command/git/checkout'
1
+ require 'papa/task/base'
3
2
  require 'papa/command/git/branch'
4
3
  require 'papa/command/git/push'
5
- require 'papa/runner'
6
- require 'papa/helper/output'
7
4
 
8
5
  module Papa
9
6
  module Task
10
7
  module Common
11
- class Start
12
- def run
13
- @build_branch ||= "#{@build_type}/#{@version}"
14
-
15
- runner = Runner.new(queue)
16
-
17
- if runner.run
18
- success_message
19
- else
20
- failure_message
21
- exit 1
22
- end
23
- end
24
-
8
+ class Start < Base
25
9
  private
26
10
 
27
11
  def queue
28
12
  [
29
13
  Command::Git::Fetch.new('origin'),
30
14
  Command::Git::Checkout.new(@base_branch),
31
- Command::Git::Branch.new(@build_branch),
32
- Command::Git::Checkout.new(@build_branch),
33
- Command::Git::Push.new('origin', @build_branch)
15
+ Command::Git::Branch.new(build_branch),
16
+ Command::Git::Checkout.new(build_branch),
17
+ Command::Git::Push.new('origin', build_branch)
34
18
  ]
35
19
  end
36
20
 
37
21
  def success_message
38
- Helper::Output.success "Successfully started new #{@build_type} branch #{@build_branch}"
22
+ Helper::Output.success "Successfully started new #{@build_type} branch #{build_branch}"
39
23
  end
40
24
 
41
25
  def failure_message
42
- Helper::Output.failure "There was a problem starting #{@build_type} branch: #{@build_branch}"
26
+ Helper::Output.failure "There was a problem starting #{@build_type} branch: #{build_branch}"
43
27
  end
44
28
  end
45
29
  end
@@ -8,6 +8,7 @@ module Papa
8
8
  @build_type = 'hotfix'
9
9
  @version = version
10
10
  @branches = bugfix_branches
11
+ super()
11
12
  end
12
13
  end
13
14
  end
@@ -8,6 +8,7 @@ module Papa
8
8
  @build_type = 'hotfix'
9
9
  @version = version
10
10
  @hostname = 'hotfix'
11
+ super()
11
12
  end
12
13
  end
13
14
  end
@@ -10,6 +10,7 @@ module Papa
10
10
  additional_branches ||= []
11
11
  @tag_name = version
12
12
  @base_branches = ['develop', 'master'] + additional_branches
13
+ super()
13
14
  end
14
15
  end
15
16
  end
@@ -8,6 +8,7 @@ module Papa
8
8
  @build_type = 'hotfix'
9
9
  @base_branch = 'master'
10
10
  @version = version
11
+ super()
11
12
  end
12
13
  end
13
14
  end
@@ -8,6 +8,7 @@ module Papa
8
8
  @build_type = 'integration'
9
9
  @version = version
10
10
  @branches = branches
11
+ super()
11
12
  end
12
13
 
13
14
  def queue(branch)
@@ -8,6 +8,7 @@ module Papa
8
8
  @build_type = 'integration'
9
9
  @version = version
10
10
  @hostname = 'integration'
11
+ super()
11
12
  end
12
13
  end
13
14
  end
@@ -11,6 +11,7 @@ module Papa
11
11
  @build_type = 'integration'
12
12
  @base_branch = base_branch
13
13
  @build_branch = "#{@build_type}/#{options[:override_branch_name] || generate_integration_timestamp}"
14
+ super()
14
15
  end
15
16
 
16
17
  private
@@ -8,6 +8,7 @@ module Papa
8
8
  @build_type = "release"
9
9
  @version = version
10
10
  @branches = feature_branches
11
+ super()
11
12
  end
12
13
  end
13
14
  end
@@ -9,6 +9,7 @@ module Papa
9
9
  @version = version
10
10
  @tag_name = version
11
11
  @base_branches = ['develop', 'master']
12
+ super()
12
13
  end
13
14
  end
14
15
  end
@@ -8,6 +8,7 @@ module Papa
8
8
  @build_type = 'release'
9
9
  @base_branch = 'develop'
10
10
  @version = version
11
+ super()
11
12
  end
12
13
  end
13
14
  end
data/lib/papa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Papa
2
- VERSION = '0.6.2'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - boggs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-11 00:00:00.000000000 Z
11
+ date: 2018-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
+ - ".papa.config.yml.example"
78
79
  - ".rspec"
79
80
  - ".travis.yml"
80
81
  - CHANGELOG.md
@@ -107,11 +108,15 @@ files:
107
108
  - lib/papa/command/git/tag_push.rb
108
109
  - lib/papa/command/larga/deploy.rb
109
110
  - lib/papa/command/larga/type.rb
111
+ - lib/papa/command/slack/send_message.rb
112
+ - lib/papa/helper/config.rb
113
+ - lib/papa/helper/logger.rb
110
114
  - lib/papa/helper/output.rb
111
115
  - lib/papa/helper/path.rb
112
116
  - lib/papa/helper/vi.rb
113
117
  - lib/papa/runner.rb
114
118
  - lib/papa/string.rb
119
+ - lib/papa/task/base.rb
115
120
  - lib/papa/task/common/add.rb
116
121
  - lib/papa/task/common/deploy.rb
117
122
  - lib/papa/task/common/finish.rb
@@ -159,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
164
  version: '0'
160
165
  requirements: []
161
166
  rubyforge_project:
162
- rubygems_version: 2.6.10
167
+ rubygems_version: 2.7.3
163
168
  signing_key:
164
169
  specification_version: 4
165
170
  summary: Helper gem for inDinero's git workflow