papa 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/papa/{hotfix.rb → cli/hotfix.rb} +0 -0
- data/lib/papa/cli/integration.rb +13 -0
- data/lib/papa/{release.rb → cli/release.rb} +0 -0
- data/lib/papa/{sandbox.rb → cli/sandbox.rb} +0 -0
- data/lib/papa/cli.rb +20 -3
- data/lib/papa/command.rb +10 -4
- data/lib/papa/common/add.rb +1 -0
- data/lib/papa/deploy.rb +48 -0
- data/lib/papa/git/fetch.rb +13 -0
- data/lib/papa/git.rb +10 -1
- data/lib/papa/integration/start.rb +17 -0
- data/lib/papa/larga/deploy.rb +36 -0
- data/lib/papa/larga/type.rb +12 -0
- data/lib/papa/larga.rb +18 -0
- data/lib/papa/sandbox/generate.rb +1 -1
- data/lib/papa/version.rb +1 -1
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71de33eed576744cad1400a5d795616b436d8146
|
4
|
+
data.tar.gz: e2a1e530d112d5c819d487c1804e31d119d76cdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e686d587e3b4d15b6a72da07663e270b97eef6f7bfa5e1c190a4ad234af3a558605005ad9805cb4ad849647f45070de2792fa692ac5cbb35950f56b804e9a76
|
7
|
+
data.tar.gz: f9f40abba6bddd80576d0d8a76b704262415430b712c42a34c207a45fe826d46f8337f7758d3698bec5bcc194eb441fa192047d29fbc1b4e91a7f1a5fb8436c7
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.2.0
|
4
|
+
* Added `integration [start]`
|
5
|
+
* Added `deploy` via larga
|
6
|
+
* Hard reset local feature and bugfix branches to remote versions before adding
|
7
|
+
|
8
|
+
## 0.1.0
|
9
|
+
* Initial release
|
10
|
+
* Added `release [start, add, finish]`, `hotfix [start, add, finish]` and `sandbox [generate]` commands
|
11
|
+
* Added simple error handling for some git commands for when they fail
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Papa
|
2
|
+
class Integration < Thor
|
3
|
+
desc 'start', 'Start an integration branch'
|
4
|
+
option :base_branch, aliases: '-b', required: true
|
5
|
+
def start
|
6
|
+
base_branch = options[:base_branch]
|
7
|
+
|
8
|
+
require 'papa/common/start'
|
9
|
+
require 'papa/integration/start'
|
10
|
+
Integration::Start.new(base_branch: base_branch).run
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
File without changes
|
File without changes
|
data/lib/papa/cli.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'papa/common'
|
2
|
-
require 'papa/release'
|
3
|
-
require 'papa/hotfix'
|
4
|
-
require 'papa/
|
2
|
+
require 'papa/cli/release'
|
3
|
+
require 'papa/cli/hotfix'
|
4
|
+
require 'papa/cli/integration'
|
5
|
+
require 'papa/cli/sandbox'
|
5
6
|
|
6
7
|
module Papa
|
7
8
|
class CLI < Thor
|
@@ -11,6 +12,22 @@ module Papa
|
|
11
12
|
desc 'hotfix [COMMAND]', 'Perform actions on hotfix branches'
|
12
13
|
subcommand 'hotfix', Hotfix
|
13
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
|
+
|
14
31
|
desc 'sandbox [COMMAND]', 'Test out papa in a sandboxed git environment'
|
15
32
|
subcommand 'sandbox', Sandbox
|
16
33
|
end
|
data/lib/papa/command.rb
CHANGED
@@ -2,15 +2,21 @@ module Papa
|
|
2
2
|
class Command
|
3
3
|
attr_accessor :command, :output, :exit_status
|
4
4
|
|
5
|
-
def initialize(command)
|
5
|
+
def initialize(command, options = {})
|
6
6
|
@command = command
|
7
7
|
@output = nil
|
8
8
|
@exit_status = nil
|
9
|
+
@output_redirect =
|
10
|
+
if options[:silent]
|
11
|
+
Output::REDIRECT_TO_NULL
|
12
|
+
else
|
13
|
+
''
|
14
|
+
end
|
9
15
|
end
|
10
16
|
|
11
17
|
def run
|
12
18
|
return if @command.nil?
|
13
|
-
output = `#{@command} #{
|
19
|
+
output = `#{@command} #{@output_redirect}`
|
14
20
|
exit_status = $?.exitstatus
|
15
21
|
@output = output
|
16
22
|
@exit_status = exit_status
|
@@ -22,11 +28,11 @@ module Papa
|
|
22
28
|
end
|
23
29
|
|
24
30
|
def cleanup
|
25
|
-
|
31
|
+
# Override me
|
26
32
|
end
|
27
33
|
|
28
34
|
def success?
|
29
|
-
|
35
|
+
!failed?
|
30
36
|
end
|
31
37
|
|
32
38
|
def failed?
|
data/lib/papa/common/add.rb
CHANGED
@@ -11,6 +11,7 @@ module Papa
|
|
11
11
|
queue.add Git.fetch(remote: 'origin')
|
12
12
|
queue.add Git.checkout(branch_name: @build_branch)
|
13
13
|
queue.add Git.checkout(branch_name: branch)
|
14
|
+
queue.add Git.hard_reset(remote: 'origin', branch_name: branch)
|
14
15
|
queue.add Git.rebase(base_branch_name: @build_branch)
|
15
16
|
queue.add Git.force_push(remote: 'origin', branch_name: branch)
|
16
17
|
queue.add Git.checkout(branch_name: @build_branch)
|
data/lib/papa/deploy.rb
ADDED
@@ -0,0 +1,48 @@
|
|
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
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Papa
|
2
|
+
class Git::Fetch < Command
|
3
|
+
def initialize(remote)
|
4
|
+
command = "git fetch #{remote}"
|
5
|
+
super(command)
|
6
|
+
end
|
7
|
+
|
8
|
+
def failure_message
|
9
|
+
super
|
10
|
+
Output.stderr 'ERROR: Make sure origin exists and you have a working Internet connection'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/papa/git.rb
CHANGED
@@ -5,11 +5,14 @@ module Papa
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.fetch(remote:)
|
8
|
-
|
8
|
+
require 'papa/git/fetch'
|
9
|
+
|
10
|
+
Git::Fetch.new(remote)
|
9
11
|
end
|
10
12
|
|
11
13
|
def self.checkout(branch_name:)
|
12
14
|
require 'papa/git/checkout'
|
15
|
+
|
13
16
|
Git::Checkout.new(branch_name)
|
14
17
|
end
|
15
18
|
|
@@ -23,6 +26,7 @@ module Papa
|
|
23
26
|
|
24
27
|
def self.merge(branch_name:)
|
25
28
|
require 'papa/git/merge'
|
29
|
+
|
26
30
|
Git::Merge.new(branch_name)
|
27
31
|
end
|
28
32
|
|
@@ -44,6 +48,7 @@ module Papa
|
|
44
48
|
|
45
49
|
def self.rebase(base_branch_name:)
|
46
50
|
require 'papa/git/rebase'
|
51
|
+
|
47
52
|
Git::Rebase.new(base_branch_name)
|
48
53
|
end
|
49
54
|
|
@@ -58,5 +63,9 @@ module Papa
|
|
58
63
|
def self.push_tag(remote:, tag_name:)
|
59
64
|
push(remote: remote, branch_name: tag_name)
|
60
65
|
end
|
66
|
+
|
67
|
+
def self.hard_reset(remote:, branch_name:)
|
68
|
+
Command.new "git reset --hard #{remote}/#{branch_name}"
|
69
|
+
end
|
61
70
|
end
|
62
71
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Papa
|
4
|
+
class Integration::Start < Common::Start
|
5
|
+
def initialize(base_branch:)
|
6
|
+
@build_type = 'integration'
|
7
|
+
@base_branch = base_branch
|
8
|
+
@build_branch = generate_integration_branch_name
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def generate_integration_branch_name
|
14
|
+
"integration/#{DateTime.now.strftime('%y.%m.%d.%H.%M').gsub('.0', '.')}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Papa
|
2
|
+
class Larga::Deploy < Command
|
3
|
+
def initialize(branch, lifespan, protection, hostname)
|
4
|
+
@branch = branch
|
5
|
+
@lifespan = lifespan
|
6
|
+
@protection = protection
|
7
|
+
@hostname = hostname
|
8
|
+
|
9
|
+
command = "larga #{build_options.join(' ')}"
|
10
|
+
super(command, silent: false)
|
11
|
+
end
|
12
|
+
|
13
|
+
def failed?
|
14
|
+
@output.include? 'Cowardly refusing'
|
15
|
+
end
|
16
|
+
|
17
|
+
def failure_message
|
18
|
+
super
|
19
|
+
Output.stderr 'ERROR: Ensure that the branch exists before trying again'
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def build_options()
|
25
|
+
options = []
|
26
|
+
options << '-action deploy'
|
27
|
+
options << "-branch #{@branch}"
|
28
|
+
options << "-lifespan #{@lifespan}"
|
29
|
+
options << "-protection #{@protection}"
|
30
|
+
if @hostname
|
31
|
+
options << "-hostname #{@hostname}"
|
32
|
+
end
|
33
|
+
options
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/papa/larga.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Papa
|
2
|
+
class Larga
|
3
|
+
RELEASE_OR_HOTFIX_LIFESPAN = '3d'
|
4
|
+
DEFAULT_LIFESPAN = '4h'
|
5
|
+
RELEASE_OR_HOTFIX_PROTECTION = 'off'
|
6
|
+
DEFAULT_PROTECTION = 'on'
|
7
|
+
|
8
|
+
def self.type
|
9
|
+
Larga::Type.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.deploy(branch:, lifespan: DEFAULT_LIFESPAN, protection: DEFAULT_PROTECTION, hostname: nil)
|
13
|
+
require 'papa/larga/deploy'
|
14
|
+
|
15
|
+
Larga::Deploy.new(branch, lifespan, protection, hostname)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -99,7 +99,7 @@ module Papa
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def clone_remote_repository
|
102
|
-
Command.new("git clone #{@remote_repository_directory} #{@local_repository_directory}").run
|
102
|
+
Command.new("git clone #{@remote_repository_directory} #{@local_repository_directory}", silent: true).run
|
103
103
|
Dir.chdir @local_repository_directory
|
104
104
|
end
|
105
105
|
|
data/lib/papa/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.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-09-
|
11
|
+
date: 2017-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -85,27 +85,34 @@ files:
|
|
85
85
|
- exe/papa
|
86
86
|
- lib/papa.rb
|
87
87
|
- lib/papa/cli.rb
|
88
|
+
- lib/papa/cli/hotfix.rb
|
89
|
+
- lib/papa/cli/integration.rb
|
90
|
+
- lib/papa/cli/release.rb
|
91
|
+
- lib/papa/cli/sandbox.rb
|
88
92
|
- lib/papa/command.rb
|
89
93
|
- lib/papa/command_queue.rb
|
90
94
|
- lib/papa/common.rb
|
91
95
|
- lib/papa/common/add.rb
|
92
96
|
- lib/papa/common/finish.rb
|
93
97
|
- lib/papa/common/start.rb
|
98
|
+
- lib/papa/deploy.rb
|
94
99
|
- lib/papa/git.rb
|
95
100
|
- lib/papa/git/checkout.rb
|
101
|
+
- lib/papa/git/fetch.rb
|
96
102
|
- lib/papa/git/merge.rb
|
97
103
|
- lib/papa/git/rebase.rb
|
98
|
-
- lib/papa/hotfix.rb
|
99
104
|
- lib/papa/hotfix/add.rb
|
100
105
|
- lib/papa/hotfix/finish.rb
|
101
106
|
- lib/papa/hotfix/start.rb
|
107
|
+
- lib/papa/integration/start.rb
|
108
|
+
- lib/papa/larga.rb
|
109
|
+
- lib/papa/larga/deploy.rb
|
110
|
+
- lib/papa/larga/type.rb
|
102
111
|
- lib/papa/output.rb
|
103
|
-
- lib/papa/release.rb
|
104
112
|
- lib/papa/release/add.rb
|
105
113
|
- lib/papa/release/finish.rb
|
106
114
|
- lib/papa/release/patch.rb
|
107
115
|
- lib/papa/release/start.rb
|
108
|
-
- lib/papa/sandbox.rb
|
109
116
|
- lib/papa/sandbox/branches/bugfix/4-fix-charmeleon-spelling/Gemfile
|
110
117
|
- lib/papa/sandbox/branches/bugfix/5-fix-gem-source/Gemfile
|
111
118
|
- lib/papa/sandbox/branches/feature/1-add-butterfree-gem/Gemfile
|