papa 0.3.0 → 0.4.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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +22 -2
  5. data/exe/papa +1 -1
  6. data/lib/papa/cli/hotfix.rb +27 -28
  7. data/lib/papa/cli/integration.rb +10 -9
  8. data/lib/papa/cli/main.rb +34 -0
  9. data/lib/papa/cli/release.rb +25 -38
  10. data/lib/papa/cli/sandbox.rb +14 -12
  11. data/lib/papa/command/base.rb +48 -0
  12. data/lib/papa/command/git/branch.rb +15 -0
  13. data/lib/papa/command/git/branch_delete.rb +14 -0
  14. data/lib/papa/command/git/checkout.rb +22 -0
  15. data/lib/papa/command/git/fetch.rb +22 -0
  16. data/lib/papa/command/git/merge.rb +33 -0
  17. data/lib/papa/command/git/merge_abort.rb +14 -0
  18. data/lib/papa/command/git/pull.rb +14 -0
  19. data/lib/papa/command/git/push.rb +14 -0
  20. data/lib/papa/command/git/push_force.rb +14 -0
  21. data/lib/papa/command/git/rebase.rb +39 -0
  22. data/lib/papa/command/git/rebase_abort.rb +14 -0
  23. data/lib/papa/command/git/reset_hard.rb +14 -0
  24. data/lib/papa/command/git/tag.rb +14 -0
  25. data/lib/papa/command/git/tag_push.rb +14 -0
  26. data/lib/papa/command/larga/deploy.rb +63 -0
  27. data/lib/papa/command/larga/type.rb +19 -0
  28. data/lib/papa/helper/output.rb +45 -0
  29. data/lib/papa/helper/path.rb +29 -0
  30. data/lib/papa/helper/vi.rb +63 -0
  31. data/lib/papa/{command_queue.rb → runner.rb} +3 -7
  32. data/lib/papa/task/common/add.rb +117 -0
  33. data/lib/papa/task/common/finish.rb +72 -0
  34. data/lib/papa/task/common/start.rb +44 -0
  35. data/lib/papa/task/deploy.rb +38 -0
  36. data/lib/papa/task/hotfix/add.rb +15 -0
  37. data/lib/papa/task/hotfix/finish.rb +17 -0
  38. data/lib/papa/task/hotfix/start.rb +15 -0
  39. data/lib/papa/task/integration/start.rb +22 -0
  40. data/lib/papa/task/release/add.rb +15 -0
  41. data/lib/papa/task/release/finish.rb +16 -0
  42. data/lib/papa/task/release/start.rb +15 -0
  43. data/lib/papa/{sandbox → task/sandbox}/branches/bugfix/4-fix-charmeleon-spelling/Gemfile +0 -0
  44. data/lib/papa/{sandbox → task/sandbox}/branches/bugfix/5-fix-gem-source/Gemfile +0 -0
  45. data/lib/papa/{sandbox → task/sandbox}/branches/feature/1-add-butterfree-gem/Gemfile +0 -0
  46. data/lib/papa/{sandbox → task/sandbox}/branches/feature/2-add-beedrill-gem/Gemfile +0 -0
  47. data/lib/papa/{sandbox → task/sandbox}/branches/feature/6-add-pidgeotto-gem/Gemfile +0 -0
  48. data/lib/papa/{sandbox → task/sandbox}/branches/feature/7-add-pidgeot-gem/Gemfile +0 -0
  49. data/lib/papa/{sandbox → task/sandbox}/branches/master/Gemfile +0 -0
  50. data/lib/papa/{sandbox → task/sandbox}/branches/patch/17.8.0/3-add-pidgey-gem/Gemfile +0 -0
  51. data/lib/papa/task/sandbox/clean.rb +23 -0
  52. data/lib/papa/task/sandbox/generate.rb +182 -0
  53. data/lib/papa/version.rb +1 -1
  54. data/lib/papa.rb +1 -9
  55. metadata +45 -40
  56. data/lib/papa/cli.rb +0 -34
  57. data/lib/papa/command.rb +0 -45
  58. data/lib/papa/common/add.rb +0 -101
  59. data/lib/papa/common/finish.rb +0 -56
  60. data/lib/papa/common/start.rb +0 -31
  61. data/lib/papa/common.rb +0 -4
  62. data/lib/papa/deploy.rb +0 -48
  63. data/lib/papa/git/checkout.rb +0 -16
  64. data/lib/papa/git/fetch.rb +0 -16
  65. data/lib/papa/git/merge.rb +0 -29
  66. data/lib/papa/git/rebase.rb +0 -29
  67. data/lib/papa/git.rb +0 -71
  68. data/lib/papa/helpers/path.rb +0 -27
  69. data/lib/papa/helpers/vi.rb +0 -60
  70. data/lib/papa/helpers.rb +0 -4
  71. data/lib/papa/hotfix/add.rb +0 -9
  72. data/lib/papa/hotfix/finish.rb +0 -11
  73. data/lib/papa/hotfix/start.rb +0 -9
  74. data/lib/papa/integration/start.rb +0 -17
  75. data/lib/papa/larga/deploy.rb +0 -36
  76. data/lib/papa/larga/type.rb +0 -12
  77. data/lib/papa/larga.rb +0 -18
  78. data/lib/papa/output.rb +0 -43
  79. data/lib/papa/release/add.rb +0 -9
  80. data/lib/papa/release/finish.rb +0 -10
  81. data/lib/papa/release/patch.rb +0 -30
  82. data/lib/papa/release/start.rb +0 -9
  83. data/lib/papa/sandbox/clean.rb +0 -17
  84. data/lib/papa/sandbox/generate.rb +0 -176
@@ -0,0 +1,182 @@
1
+ require 'papa/helper/path'
2
+ require 'papa/helper/output'
3
+ require 'papa/command/base'
4
+
5
+ module Papa
6
+ module Task
7
+ module Sandbox
8
+ class Generate
9
+ attr_accessor :remote_path, :local_path, :git_details, :options
10
+
11
+ def initialize(options = {})
12
+ @options = options
13
+ @remote_path = Helper::Path.generate_sandbox_path('remote', options)
14
+ @local_path = Helper::Path.generate_sandbox_path('local', options)
15
+ @git_details = [
16
+ {
17
+ commit: 'APP-1 - Add butterfree gem',
18
+ branch: 'feature/1-add-butterfree-gem',
19
+ base_branch: 'develop'
20
+ },
21
+ {
22
+ commit: 'APP-2 - Add beedrill gem',
23
+ branch: 'feature/2-add-beedrill-gem',
24
+ base_branch: 'develop'
25
+ },
26
+ {
27
+ commit: 'APP-3 - Add pidgey gem',
28
+ branch: 'patch/17.8.0/3-add-pidgey-gem',
29
+ base_branch: 'develop'
30
+ },
31
+ {
32
+ commit: 'APP-4 - Fix charmeleon spelling',
33
+ branch: 'bugfix/4-fix-charmeleon-spelling',
34
+ base_branch: 'master'
35
+ },
36
+ {
37
+ commit: 'APP-5 - Fix gem source',
38
+ branch: 'bugfix/5-fix-gem-source',
39
+ base_branch: 'master'
40
+ },
41
+ {
42
+ commit: 'APP-6 - Add pidgeotto gem',
43
+ branch: 'feature/6-add-pidgeotto-gem',
44
+ base_branch: 'develop'
45
+ },
46
+ {
47
+ commit: 'APP-7 - Add pidgeot gem',
48
+ branch: 'feature/7-add-pidgeot-gem',
49
+ base_branch: 'develop'
50
+ }
51
+ ]
52
+ end
53
+
54
+ def run
55
+ Helper::Output.stdout('Started generation of sandbox...') unless options[:silent]
56
+ task_directory = File.expand_path(File.dirname(__dir__))
57
+ @branches_directory = File.join(task_directory, 'sandbox', 'branches')
58
+ setup_remote_repository
59
+ setup_local_repository
60
+ success_message unless options[:silent]
61
+ end
62
+
63
+ private
64
+
65
+ def gemfile_path(branch)
66
+ File.join @branches_directory, branch, 'Gemfile'
67
+ end
68
+
69
+ def temp_gemfile_path
70
+ File.join @local_path, 'Gemfile'
71
+ end
72
+
73
+ def setup_remote_repository
74
+ if options[:override_origin]
75
+ create_local_path
76
+ initialize_local_repository
77
+ remove_old_branches_from_origin
78
+ else
79
+ create_remote_path
80
+ initialize_remote_repository
81
+ create_local_path
82
+ clone_remote_repository
83
+ end
84
+ end
85
+
86
+ def create_local_path
87
+ Command::Base.new("rm -rf #{@local_path}", options).run
88
+ Dir.mkdir @local_path
89
+ end
90
+
91
+ def initialize_local_repository
92
+ Dir.chdir @local_path
93
+ Command::Base.new('git init', options).run
94
+ Command::Base.new("git remote add origin #{options[:override_origin]}", options).run
95
+ end
96
+
97
+ def create_remote_path
98
+ Command::Base.new("rm -rf #{@remote_path}", options).run
99
+ Dir.mkdir @remote_path
100
+ end
101
+
102
+ def initialize_remote_repository
103
+ Dir.chdir @remote_path
104
+ Command::Base.new('git init --bare', options).run
105
+ end
106
+
107
+ def clone_remote_repository
108
+ Command::Base.new("git clone #{@remote_path} #{@local_path}", options).run
109
+ Dir.chdir @local_path
110
+ end
111
+
112
+ def setup_local_repository
113
+ initialize_master_and_develop
114
+ initialize_branches
115
+ cleanup
116
+ end
117
+
118
+ def remove_old_branches_from_origin
119
+ `git fetch #{Helper::Output::REDIRECT_TO_NULL}`
120
+ ['hotfix', 'release'].each do |branch|
121
+ `git branch -r | grep #{branch}`.split("\n").each do |branch|
122
+ branch = branch.strip.split('origin/').last
123
+ `git push -d origin #{branch}`
124
+ end
125
+ end
126
+ end
127
+
128
+ def initialize_master_and_develop
129
+ [
130
+ "cp #{gemfile_path('master')} #{@local_path}",
131
+ 'git add .',
132
+ 'git commit -m "Initial commit"',
133
+ 'git push origin master --force',
134
+ 'git checkout -b develop',
135
+ 'git push origin develop --force'
136
+ ].each do |command|
137
+ `#{command} #{Helper::Output::REDIRECT_TO_NULL}`
138
+ end
139
+ end
140
+
141
+ def initialize_branches
142
+ @git_details.each do |detail|
143
+ commit = detail[:commit]
144
+ branch = detail[:branch]
145
+ base_branch = detail[:base_branch]
146
+ [
147
+ "git checkout #{base_branch}",
148
+ "git checkout -b #{branch}",
149
+ "rm #{temp_gemfile_path}",
150
+ "cp #{gemfile_path(branch)} #{@local_path}",
151
+ "git add .",
152
+ "git commit -m \"#{commit}\"",
153
+ "git push origin #{branch} --force"
154
+ ].each do |command|
155
+ `#{command} #{Helper::Output::REDIRECT_TO_NULL}`
156
+ end
157
+ end
158
+ end
159
+
160
+ def cleanup
161
+ `git checkout develop #{Helper::Output::REDIRECT_TO_NULL}`
162
+ @git_details.each do |detail|
163
+ `git branch -D #{detail[:branch]} #{Helper::Output::REDIRECT_TO_NULL}`
164
+ end
165
+ end
166
+
167
+ def success_message
168
+ Helper::Output.success "Your sandbox is now available at:\n #{@local_path}"
169
+ end
170
+
171
+ def override_origin(origin)
172
+ [
173
+ 'git remote remove origin',
174
+ 'git remote add origin #{origin}'
175
+ ].each do |command|
176
+ `#{command} #{Helper::Output::REDIRECT_TO_NULL}`
177
+ end
178
+ end
179
+ end
180
+ end
181
+ end
182
+ end
data/lib/papa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Papa
2
- VERSION = "0.3.0"
2
+ VERSION = '0.4.0'
3
3
  end
data/lib/papa.rb CHANGED
@@ -2,12 +2,4 @@ require 'thor'
2
2
  require 'papa/thor'
3
3
  require 'papa/string'
4
4
  require 'papa/version'
5
- require 'papa/cli'
6
- require 'papa/command'
7
- require 'papa/command_queue'
8
- require 'papa/git'
9
- require 'papa/output'
10
- require 'papa/helpers'
11
-
12
- module Papa
13
- end
5
+ require 'papa/cli/main'
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.3.0
4
+ version: 0.4.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-11-24 00:00:00.000000000 Z
11
+ date: 2017-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -84,49 +84,54 @@ files:
84
84
  - Rakefile
85
85
  - exe/papa
86
86
  - lib/papa.rb
87
- - lib/papa/cli.rb
88
87
  - lib/papa/cli/hotfix.rb
89
88
  - lib/papa/cli/integration.rb
89
+ - lib/papa/cli/main.rb
90
90
  - lib/papa/cli/release.rb
91
91
  - lib/papa/cli/sandbox.rb
92
- - lib/papa/command.rb
93
- - lib/papa/command_queue.rb
94
- - lib/papa/common.rb
95
- - lib/papa/common/add.rb
96
- - lib/papa/common/finish.rb
97
- - lib/papa/common/start.rb
98
- - lib/papa/deploy.rb
99
- - lib/papa/git.rb
100
- - lib/papa/git/checkout.rb
101
- - lib/papa/git/fetch.rb
102
- - lib/papa/git/merge.rb
103
- - lib/papa/git/rebase.rb
104
- - lib/papa/helpers.rb
105
- - lib/papa/helpers/path.rb
106
- - lib/papa/helpers/vi.rb
107
- - lib/papa/hotfix/add.rb
108
- - lib/papa/hotfix/finish.rb
109
- - lib/papa/hotfix/start.rb
110
- - lib/papa/integration/start.rb
111
- - lib/papa/larga.rb
112
- - lib/papa/larga/deploy.rb
113
- - lib/papa/larga/type.rb
114
- - lib/papa/output.rb
115
- - lib/papa/release/add.rb
116
- - lib/papa/release/finish.rb
117
- - lib/papa/release/patch.rb
118
- - lib/papa/release/start.rb
119
- - lib/papa/sandbox/branches/bugfix/4-fix-charmeleon-spelling/Gemfile
120
- - lib/papa/sandbox/branches/bugfix/5-fix-gem-source/Gemfile
121
- - lib/papa/sandbox/branches/feature/1-add-butterfree-gem/Gemfile
122
- - lib/papa/sandbox/branches/feature/2-add-beedrill-gem/Gemfile
123
- - lib/papa/sandbox/branches/feature/6-add-pidgeotto-gem/Gemfile
124
- - lib/papa/sandbox/branches/feature/7-add-pidgeot-gem/Gemfile
125
- - lib/papa/sandbox/branches/master/Gemfile
126
- - lib/papa/sandbox/branches/patch/17.8.0/3-add-pidgey-gem/Gemfile
127
- - lib/papa/sandbox/clean.rb
128
- - lib/papa/sandbox/generate.rb
92
+ - lib/papa/command/base.rb
93
+ - lib/papa/command/git/branch.rb
94
+ - lib/papa/command/git/branch_delete.rb
95
+ - lib/papa/command/git/checkout.rb
96
+ - lib/papa/command/git/fetch.rb
97
+ - lib/papa/command/git/merge.rb
98
+ - lib/papa/command/git/merge_abort.rb
99
+ - lib/papa/command/git/pull.rb
100
+ - lib/papa/command/git/push.rb
101
+ - lib/papa/command/git/push_force.rb
102
+ - lib/papa/command/git/rebase.rb
103
+ - lib/papa/command/git/rebase_abort.rb
104
+ - lib/papa/command/git/reset_hard.rb
105
+ - lib/papa/command/git/tag.rb
106
+ - lib/papa/command/git/tag_push.rb
107
+ - lib/papa/command/larga/deploy.rb
108
+ - lib/papa/command/larga/type.rb
109
+ - lib/papa/helper/output.rb
110
+ - lib/papa/helper/path.rb
111
+ - lib/papa/helper/vi.rb
112
+ - lib/papa/runner.rb
129
113
  - lib/papa/string.rb
114
+ - lib/papa/task/common/add.rb
115
+ - lib/papa/task/common/finish.rb
116
+ - lib/papa/task/common/start.rb
117
+ - lib/papa/task/deploy.rb
118
+ - lib/papa/task/hotfix/add.rb
119
+ - lib/papa/task/hotfix/finish.rb
120
+ - lib/papa/task/hotfix/start.rb
121
+ - lib/papa/task/integration/start.rb
122
+ - lib/papa/task/release/add.rb
123
+ - lib/papa/task/release/finish.rb
124
+ - lib/papa/task/release/start.rb
125
+ - lib/papa/task/sandbox/branches/bugfix/4-fix-charmeleon-spelling/Gemfile
126
+ - lib/papa/task/sandbox/branches/bugfix/5-fix-gem-source/Gemfile
127
+ - lib/papa/task/sandbox/branches/feature/1-add-butterfree-gem/Gemfile
128
+ - lib/papa/task/sandbox/branches/feature/2-add-beedrill-gem/Gemfile
129
+ - lib/papa/task/sandbox/branches/feature/6-add-pidgeotto-gem/Gemfile
130
+ - lib/papa/task/sandbox/branches/feature/7-add-pidgeot-gem/Gemfile
131
+ - lib/papa/task/sandbox/branches/master/Gemfile
132
+ - lib/papa/task/sandbox/branches/patch/17.8.0/3-add-pidgey-gem/Gemfile
133
+ - lib/papa/task/sandbox/clean.rb
134
+ - lib/papa/task/sandbox/generate.rb
130
135
  - lib/papa/thor.rb
131
136
  - lib/papa/version.rb
132
137
  - papa.gemspec
data/lib/papa/cli.rb DELETED
@@ -1,34 +0,0 @@
1
- require 'papa/common'
2
- require 'papa/cli/release'
3
- require 'papa/cli/hotfix'
4
- require 'papa/cli/integration'
5
- require 'papa/cli/sandbox'
6
-
7
- module Papa
8
- class CLI < Thor
9
- desc 'release [COMMAND]', 'Perform actions on release branches'
10
- subcommand 'release', Release
11
-
12
- desc 'hotfix [COMMAND]', 'Perform actions on hotfix branches'
13
- subcommand 'hotfix', Hotfix
14
-
15
- desc 'integration [COMMAND]', 'Perform actions on integration branches'
16
- subcommand 'integration', Integration
17
-
18
- desc 'deploy', 'Deploy a branch with larga'
19
- option :branch, aliases: '-b', required: true
20
- option :hostname, aliases: '-h'
21
- def deploy
22
- require 'papa/deploy'
23
- require 'papa/larga'
24
-
25
- branch = options[:branch]
26
- hostname = options[:hostname]
27
-
28
- Deploy.new(branch: branch, hostname: hostname).run
29
- end
30
-
31
- desc 'sandbox [COMMAND]', 'Test out papa in a sandboxed git environment'
32
- subcommand 'sandbox', Sandbox
33
- end
34
- end
data/lib/papa/command.rb DELETED
@@ -1,45 +0,0 @@
1
- require 'open3'
2
-
3
- module Papa
4
- class Command
5
- attr_accessor :command, :stdout, :stderr, :exit_status, :silent
6
-
7
- def initialize(command, options = {})
8
- @command = command
9
- @silent = options.has_key?(:silent) ? options[:silent] : false
10
- end
11
-
12
- def run
13
- return if command.nil?
14
- Output.stdout "Running #{command.bold}..." unless silent
15
- @stdout, @stderr, status = Open3.capture3(command)
16
- @exit_status = status.exitstatus
17
- self
18
- end
19
-
20
- def failure_message
21
- message = "Error while running #{command.bold}"
22
- Output.error message
23
- Output.error stderr
24
- message
25
- end
26
-
27
- def cleanup
28
- # Override me
29
- end
30
-
31
- def success?
32
- !failed?
33
- end
34
-
35
- def failed?
36
- exit_status != 0
37
- end
38
-
39
- private
40
-
41
- def current_branch
42
- @current_branch ||= `git symbolic-ref --short HEAD`.chomp
43
- end
44
- end
45
- end
@@ -1,101 +0,0 @@
1
- module Papa
2
- class Common::Add
3
- def run
4
- check_branches
5
-
6
- @build_branch ||= "#{@build_type}/#{@version}"
7
-
8
- success = true
9
- @success_branches = []
10
- @failed_branches = []
11
-
12
- Output.stdout "Started adding branches to #{@build_branch.bold}."
13
-
14
- @branches.each_with_index do |branch, index|
15
- Output.stdout "Adding branch #{branch.bold} (#{index + 1} of #{@branches.count})..."
16
- queue = CommandQueue.new
17
- queue.add Git.fetch(remote: 'origin')
18
- queue.add Git.checkout(branch_name: @build_branch)
19
- queue.add Git.checkout(branch_name: branch)
20
- queue.add Git.hard_reset(remote: 'origin', branch_name: branch)
21
- queue.add Git.rebase(base_branch_name: @build_branch)
22
- queue.add Git.force_push(remote: 'origin', branch_name: branch)
23
- queue.add Git.checkout(branch_name: @build_branch)
24
- queue.add Git.merge(branch_name: branch)
25
- queue.add Git.push(remote: 'origin', branch_name: @build_branch)
26
-
27
- if queue.run
28
- @success_branches << branch
29
- else
30
- failed_branch = {
31
- branch: branch,
32
- message: queue.last_error
33
- }
34
- @failed_branches << failed_branch
35
- success = false
36
- end
37
- end
38
-
39
- success_message
40
- failure_message
41
-
42
- if success
43
- success_cleanup
44
- else
45
- failure_cleanup
46
- exit 1
47
- end
48
- end
49
-
50
- private
51
-
52
- def check_branches
53
- return unless @branches.empty?
54
- require 'papa/helpers/vi'
55
- vi_file_helper = Helpers::Vi.new
56
- @branches = vi_file_helper.run
57
- end
58
-
59
- def success_cleanup
60
- queue = CommandQueue.new
61
- @branches.each { |branch| queue.add Git.delete_branch(branch_name: branch) }
62
- queue.run
63
- end
64
-
65
- def success_message
66
- return if @success_branches.empty?
67
- output = ''
68
- output << "Successfully added these branches to #{@build_branch}:\n"
69
- @success_branches.each_with_index do |branch, index|
70
- output << " #{index + 1}.) #{branch}\n"
71
- end
72
- Output.success output
73
- end
74
-
75
- def failure_cleanup
76
- end
77
-
78
- def failure_message
79
- return if @failed_branches.empty?
80
-
81
- output = ''
82
-
83
- output << "Failed to add these branches to #{@build_branch}:\n"
84
- @failed_branches.each_with_index do |failed_branch, index|
85
- branch = failed_branch[:branch]
86
- message = failed_branch[:message]
87
- output << " #{index + 1}.) #{branch}\n"
88
- output << " - #{message}\n"
89
- end
90
-
91
- output << "\n"
92
-
93
- branch_names = @failed_branches.map { |f| f[:branch] }
94
-
95
- output << "When the above problems are resolved, you can re-run this with:\n"
96
- output << " papa #{@build_type} add -v #{@version} -b #{branch_names.join(' ')}"
97
-
98
- Output.failure output
99
- end
100
- end
101
- end
@@ -1,56 +0,0 @@
1
- module Papa
2
- class Common::Finish
3
- def run
4
- @build_branch ||= "#{@build_type}/#{@version}"
5
-
6
- success = true
7
- @success_branches = []
8
-
9
- @base_branches.each do |branch|
10
- queue = CommandQueue.new
11
- queue.add Git.fetch(remote: 'origin')
12
- queue.add Git.checkout(branch_name: @build_branch)
13
- queue.add Git.checkout(branch_name: branch)
14
- queue.add Git.merge(branch_name: @build_branch)
15
- queue.add Git.push(remote: 'origin', branch_name: branch)
16
- if @tag_name && branch == 'master'
17
- queue.add Git.tag(tag_name: @tag_name)
18
- queue.add Git.push_tag(remote: 'origin', tag_name: @tag_name)
19
- end
20
- if queue.run
21
- @success_branches << branch
22
- else
23
- success = false
24
- end
25
- end
26
-
27
- success_message if !@success_branches.empty?
28
-
29
- if !success
30
- failure_message
31
- exit 1
32
- end
33
- end
34
-
35
- private
36
-
37
- def success_message
38
- Output.stdout "Successfully merged #{@build_branch} to these branches:"
39
- @success_branches.each do |branch|
40
- Output.stdout " #{branch}"
41
- end
42
- end
43
-
44
- def failure_message
45
- failed_branches = @base_branches - @success_branches
46
-
47
- Output.stderr "Failed to merge #{@build_branch} to these branches:"
48
- failed_branches.each do |branch|
49
- Output.stderr " #{branch}"
50
- end
51
- # TODO: Handle master or develop failure
52
- # Output.stderr "When the above problems are resolved, you can re-run this with:"
53
- # Output.stderr " papa #{@build_type} finish -v #{@version} -b #{failed_branches.join(' ')}"
54
- end
55
- end
56
- end
@@ -1,31 +0,0 @@
1
- module Papa
2
- class Common::Start
3
- def run
4
- @build_branch ||= "#{@build_type}/#{@version}"
5
-
6
- @queue = CommandQueue.new
7
- @queue.add Git.fetch(remote: 'origin')
8
- @queue.add Git.checkout(branch_name: @base_branch)
9
- @queue.add Git.branch(branch_name: @build_branch)
10
- @queue.add Git.checkout(branch_name: @build_branch)
11
- @queue.add Git.push(remote: 'origin', branch_name: @build_branch)
12
-
13
- if @queue.run
14
- success_message
15
- else
16
- failure_message
17
- exit 1
18
- end
19
- end
20
-
21
- private
22
-
23
- def success_message
24
- Output.success "Successfully started new #{@build_type} branch #{@build_branch}"
25
- end
26
-
27
- def failure_message
28
- Output.failure "There was a problem starting #{@build_type} branch: #{@build_branch}"
29
- end
30
- end
31
- end
data/lib/papa/common.rb DELETED
@@ -1,4 +0,0 @@
1
- module Papa
2
- class Common
3
- end
4
- end
data/lib/papa/deploy.rb DELETED
@@ -1,48 +0,0 @@
1
- module Papa
2
- class Deploy
3
- def initialize(options = {})
4
- @options = options
5
- build_options
6
- end
7
-
8
- def run
9
- queue = CommandQueue.new
10
- queue.add Larga.type
11
- queue.add Larga.deploy(@options)
12
- if queue.run
13
- success_message
14
- else
15
- failure_message
16
- exit 1
17
- end
18
- end
19
-
20
- private
21
-
22
- def success_message
23
- Output.stdout 'Successfully deployed larga instance.'
24
- end
25
-
26
- def failure_message
27
- # TODO
28
- end
29
-
30
- def build_options
31
- return if !branch_is_release_or_hotfix?
32
- @options[:lifespan] = Larga::RELEASE_OR_HOTFIX_LIFESPAN
33
- @options[:protection] = Larga::RELEASE_OR_HOTFIX_PROTECTION
34
- end
35
-
36
- def branch_is_release_or_hotfix?
37
- branch_is_release? || branch_is_hotfix?
38
- end
39
-
40
- def branch_is_release?
41
- @options[:branch].include? 'release'
42
- end
43
-
44
- def branch_is_hotfix?
45
- @options[:branch].include? 'hotfix'
46
- end
47
- end
48
- end
@@ -1,16 +0,0 @@
1
- module Papa
2
- class Git::Checkout < Command
3
- def initialize(branch_name)
4
- @branch_name = branch_name
5
- command = "git checkout #{@branch_name}"
6
- super(command)
7
- end
8
-
9
- def failure_message
10
- super
11
- message = "Failed to checkout #{@branch_name.bold}. Check whether this branch exists."
12
- Output.error message
13
- message
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Papa
2
- class Git::Fetch < Command
3
- def initialize(remote)
4
- @remote = remote
5
- command = "git fetch #{remote}"
6
- super(command)
7
- end
8
-
9
- def failure_message
10
- super
11
- message = "Failed to fetch from #{@remote}. Please check your internet connection and try again."
12
- Output.stderr message
13
- message
14
- end
15
- end
16
- end