papa 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/exe/papa +6 -0
- data/lib/papa.rb +11 -0
- data/lib/papa/cli.rb +17 -0
- data/lib/papa/command.rb +42 -0
- data/lib/papa/command_queue.rb +34 -0
- data/lib/papa/common.rb +4 -0
- data/lib/papa/common/add.rb +62 -0
- data/lib/papa/common/finish.rb +56 -0
- data/lib/papa/common/start.rb +30 -0
- data/lib/papa/git.rb +62 -0
- data/lib/papa/git/checkout.rb +14 -0
- data/lib/papa/git/merge.rb +27 -0
- data/lib/papa/git/rebase.rb +27 -0
- data/lib/papa/hotfix.rb +37 -0
- data/lib/papa/hotfix/add.rb +9 -0
- data/lib/papa/hotfix/finish.rb +11 -0
- data/lib/papa/hotfix/start.rb +9 -0
- data/lib/papa/output.rb +13 -0
- data/lib/papa/release.rb +47 -0
- data/lib/papa/release/add.rb +9 -0
- data/lib/papa/release/finish.rb +10 -0
- data/lib/papa/release/patch.rb +30 -0
- data/lib/papa/release/start.rb +9 -0
- data/lib/papa/sandbox.rb +12 -0
- data/lib/papa/sandbox/branches/bugfix/4-fix-charmeleon-spelling/Gemfile +24 -0
- data/lib/papa/sandbox/branches/bugfix/5-fix-gem-source/Gemfile +24 -0
- data/lib/papa/sandbox/branches/feature/1-add-butterfree-gem/Gemfile +25 -0
- data/lib/papa/sandbox/branches/feature/2-add-beedrill-gem/Gemfile +25 -0
- data/lib/papa/sandbox/branches/feature/6-add-pidgeotto-gem/Gemfile +26 -0
- data/lib/papa/sandbox/branches/feature/7-add-pidgeot-gem/Gemfile +26 -0
- data/lib/papa/sandbox/branches/master/Gemfile +24 -0
- data/lib/papa/sandbox/branches/patch/17.8.0/3-add-pidgey-gem/Gemfile +26 -0
- data/lib/papa/sandbox/generate.rb +177 -0
- data/lib/papa/thor.rb +5 -0
- data/lib/papa/version.rb +3 -0
- data/papa.gemspec +31 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: baa63ed9a4682f55dff53db355e5af29448bc4ab
|
4
|
+
data.tar.gz: 5513f134da10af2b98048a6c988840ed2668939d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22a55a5b2b748a4eb98662d1be83392fc7826e117297127c6ecc31dabddbbd562b30106b64cc2d0036516aa211abe400f618c18be8b56ed96f40565ae9e744a6
|
7
|
+
data.tar.gz: 272a9e587e4b100ed4418397a49a4ff88429aea3277961756dbd323638d3eff1b09108ff4cb114b66c6cd25501ad5958b89b4d6dcfce66bc868ff5a870f6b0be
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 boggs
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Papa
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/papa`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'papa'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install papa
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/b-ggs/papa.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/exe/papa
ADDED
data/lib/papa.rb
ADDED
data/lib/papa/cli.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'papa/common'
|
2
|
+
require 'papa/release'
|
3
|
+
require 'papa/hotfix'
|
4
|
+
require 'papa/sandbox'
|
5
|
+
|
6
|
+
module Papa
|
7
|
+
class CLI < Thor
|
8
|
+
desc 'release [COMMAND]', 'Perform actions on release branches'
|
9
|
+
subcommand 'release', Release
|
10
|
+
|
11
|
+
desc 'hotfix [COMMAND]', 'Perform actions on hotfix branches'
|
12
|
+
subcommand 'hotfix', Hotfix
|
13
|
+
|
14
|
+
desc 'sandbox [COMMAND]', 'Test out papa in a sandboxed git environment'
|
15
|
+
subcommand 'sandbox', Sandbox
|
16
|
+
end
|
17
|
+
end
|
data/lib/papa/command.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Papa
|
2
|
+
class Command
|
3
|
+
attr_accessor :command, :output, :exit_status
|
4
|
+
|
5
|
+
def initialize(command)
|
6
|
+
@command = command
|
7
|
+
@output = nil
|
8
|
+
@exit_status = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
return if @command.nil?
|
13
|
+
output = `#{@command} #{Output::REDIRECT_TO_NULL}`
|
14
|
+
exit_status = $?.exitstatus
|
15
|
+
@output = output
|
16
|
+
@exit_status = exit_status
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure_message
|
21
|
+
Output.stderr "ERROR: There was a problem running '#{command}'"
|
22
|
+
end
|
23
|
+
|
24
|
+
def cleanup
|
25
|
+
Output.stderr 'Cleaning up...'
|
26
|
+
end
|
27
|
+
|
28
|
+
def success?
|
29
|
+
@exit_status == 0
|
30
|
+
end
|
31
|
+
|
32
|
+
def failed?
|
33
|
+
@exit_status != 0
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def current_branch
|
39
|
+
@current_branch ||= `git symbolic-ref --short HEAD`.chomp
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Papa
|
2
|
+
class CommandQueue
|
3
|
+
attr_accessor :queue
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@queue = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def add(command)
|
10
|
+
@queue.push command
|
11
|
+
end
|
12
|
+
|
13
|
+
def list_queue
|
14
|
+
Output.stdout 'Running:'
|
15
|
+
@queue.each do |command|
|
16
|
+
Output.stdout " #{command.command}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
success = true
|
22
|
+
list_queue
|
23
|
+
@queue.each do |command|
|
24
|
+
if command.run.failed?
|
25
|
+
success = false
|
26
|
+
command.cleanup
|
27
|
+
command.failure_message
|
28
|
+
break
|
29
|
+
end
|
30
|
+
end
|
31
|
+
success
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/papa/common.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
module Papa
|
2
|
+
class Common::Add
|
3
|
+
def run
|
4
|
+
@build_branch ||= "#{@build_type}/#{@version}"
|
5
|
+
|
6
|
+
success = true
|
7
|
+
@success_branches = []
|
8
|
+
|
9
|
+
@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.rebase(base_branch_name: @build_branch)
|
15
|
+
queue.add Git.force_push(remote: 'origin', branch_name: branch)
|
16
|
+
queue.add Git.checkout(branch_name: @build_branch)
|
17
|
+
queue.add Git.merge(branch_name: branch)
|
18
|
+
queue.add Git.push(remote: 'origin', branch_name: @build_branch)
|
19
|
+
if queue.run
|
20
|
+
@success_branches << branch
|
21
|
+
else
|
22
|
+
success = false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
cleanup
|
27
|
+
|
28
|
+
success_message if !@success_branches.empty?
|
29
|
+
|
30
|
+
if !success
|
31
|
+
failure_message
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def success_message
|
39
|
+
Output.stdout "Successfully added these branches to #{@build_branch}:"
|
40
|
+
@success_branches.each do |branch|
|
41
|
+
Output.stdout " #{branch}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def cleanup
|
46
|
+
queue = CommandQueue.new
|
47
|
+
@branches.each { |branch| queue.add Git.delete_branch(branch_name: branch) }
|
48
|
+
queue.run
|
49
|
+
end
|
50
|
+
|
51
|
+
def failure_message
|
52
|
+
failed_branches = @branches - @success_branches
|
53
|
+
|
54
|
+
Output.stderr "Failed to add these branches to #{@build_branch}:"
|
55
|
+
failed_branches.each do |branch|
|
56
|
+
Output.stderr " #{branch}"
|
57
|
+
end
|
58
|
+
Output.stderr 'When the above problems are resolved, you can re-run this with:'
|
59
|
+
Output.stderr " papa #{@build_type} add -v #{@version} -b #{failed_branches.join(' ')}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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
|
@@ -0,0 +1,30 @@
|
|
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
|
+
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 started new #{@build_type} branch #{@build_branch}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def failure_message
|
27
|
+
Output.stderr "There was a problem starting #{@build_type} branch: #{@build_branch}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/papa/git.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
module Papa
|
2
|
+
class Git
|
3
|
+
def self.status
|
4
|
+
Command.new 'git status'
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.fetch(remote:)
|
8
|
+
Command.new "git fetch #{remote}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.checkout(branch_name:)
|
12
|
+
require 'papa/git/checkout'
|
13
|
+
Git::Checkout.new(branch_name)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.branch(branch_name:)
|
17
|
+
Command.new "git branch #{branch_name}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.delete_branch(branch_name:)
|
21
|
+
Command.new "git branch -D #{branch_name}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.merge(branch_name:)
|
25
|
+
require 'papa/git/merge'
|
26
|
+
Git::Merge.new(branch_name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.merge_abort
|
30
|
+
Command.new 'git merge --abort'
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.pull(remote:, branch_name:)
|
34
|
+
Command.new "git pull #{remote} #{branch_name}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.push(remote:, branch_name:)
|
38
|
+
Command.new "git push #{remote} #{branch_name}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.force_push(remote:, branch_name:)
|
42
|
+
Command.new "git push #{remote} #{branch_name} --force-with-lease"
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.rebase(base_branch_name:)
|
46
|
+
require 'papa/git/rebase'
|
47
|
+
Git::Rebase.new(base_branch_name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.rebase_abort
|
51
|
+
Command.new 'git rebase --abort'
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.tag(tag_name:)
|
55
|
+
Command.new "git tag #{tag_name}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.push_tag(remote:, tag_name:)
|
59
|
+
push(remote: remote, branch_name: tag_name)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|