thegarage-gitx 2.5.0.beta4 → 2.5.0.beta5
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d5196e1b3d1162c4351b5c71e3ca2226e144a93
|
|
4
|
+
data.tar.gz: d6583c146149d2aa3413b0822ef3df6ab344aca8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61bad6585e96efa1a0b541260b06f8a1bdcb545eb1cdecfda58c8f01310d45a3d0cce465c19585029e865e6b24df79aa01bbb24a36b59fd51e169a63b38f8c55
|
|
7
|
+
data.tar.gz: 4b79dc87ec890790a663aef886ab4043d521ccd01721682b903d146a248b7c8fae18636c6c8ada5c76a0afa179201a5ac6897a5f2c5c1cf0c09127e9d9f2c0d3
|
|
@@ -9,63 +9,62 @@ module Thegarage
|
|
|
9
9
|
class IntegrateCommand < BaseCommand
|
|
10
10
|
desc 'integrate', 'integrate the current branch into one of the aggregate development branches (default = staging)'
|
|
11
11
|
method_option :resume, :type => :string, :aliases => '-r', :desc => 'resume merging of feature-branch'
|
|
12
|
-
def integrate(
|
|
13
|
-
|
|
14
|
-
if options[:resume]
|
|
15
|
-
resume
|
|
16
|
-
else
|
|
17
|
-
assert_aggregate_branch!(target_branch)
|
|
12
|
+
def integrate(integration_branch = 'staging')
|
|
13
|
+
assert_aggregate_branch!(integration_branch)
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
branch = feature_branch_name
|
|
16
|
+
print_message(branch, integration_branch)
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
say "#{branch} ", :green
|
|
23
|
-
say "into "
|
|
24
|
-
say target_branch, :green
|
|
18
|
+
UpdateCommand.new.update
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
merge_feature_branch branch
|
|
29
|
-
run_cmd "git push origin HEAD"
|
|
30
|
-
checkout_branch branch
|
|
31
|
-
end
|
|
20
|
+
integrate_branch(branch, integration_branch) unless options[:resume]
|
|
21
|
+
checkout_branch branch
|
|
32
22
|
end
|
|
33
23
|
|
|
34
24
|
private
|
|
35
25
|
|
|
36
|
-
def
|
|
37
|
-
|
|
26
|
+
def print_message(branch, integration_branch)
|
|
27
|
+
message = options[:resume] ? 'Resuming integration of' : 'Integrating'
|
|
28
|
+
say "#{message} "
|
|
29
|
+
say "#{branch} ", :green
|
|
30
|
+
say "into "
|
|
31
|
+
say integration_branch, :green
|
|
38
32
|
end
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
run_cmd "git fetch origin"
|
|
43
|
-
run_cmd "git branch -D #{target_branch}", :allow_failure => true
|
|
44
|
-
checkout_branch target_branch
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def merge_feature_branch(branch)
|
|
34
|
+
def integrate_branch(branch, integration_branch)
|
|
35
|
+
fetch_remote_branch(integration_branch)
|
|
48
36
|
begin
|
|
49
37
|
run_cmd "git merge #{branch}"
|
|
50
38
|
rescue
|
|
51
39
|
say "Merge Conflict Occurred. Please fix merge conflict and rerun command with --resume #{branch} flag", :red
|
|
52
40
|
exit
|
|
53
41
|
end
|
|
42
|
+
run_cmd "git push origin HEAD"
|
|
54
43
|
end
|
|
55
44
|
|
|
56
|
-
def
|
|
57
|
-
feature_branch
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
feature_branch = ask("#{feature_branch} does not exist please enter the correct branch from this list #{local_branches}")
|
|
45
|
+
def feature_branch_name
|
|
46
|
+
@feature_branch ||= begin
|
|
47
|
+
feature_branch = options[:resume] || current_branch.name
|
|
48
|
+
until local_branch_exists?(feature_branch)
|
|
49
|
+
feature_branch = ask("#{feature_branch} does not exist. Please select one of the available local branches: #{local_branches}")
|
|
50
|
+
end
|
|
51
|
+
feature_branch
|
|
64
52
|
end
|
|
65
|
-
checkout_branch feature_branch
|
|
66
53
|
end
|
|
67
54
|
|
|
68
|
-
def
|
|
55
|
+
def assert_aggregate_branch!(target_branch)
|
|
56
|
+
fail "Invalid aggregate branch: #{target_branch} must be one of supported aggregate branches #{AGGREGATE_BRANCHES}" unless aggregate_branch?(target_branch)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# nuke local branch and pull fresh version from remote repo
|
|
60
|
+
def fetch_remote_branch(target_branch)
|
|
61
|
+
create_remote_branch(target_branch) unless remote_branch_exists?(target_branch)
|
|
62
|
+
run_cmd "git fetch origin"
|
|
63
|
+
run_cmd "git branch -D #{target_branch}", :allow_failure => true
|
|
64
|
+
checkout_branch target_branch
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def local_branch_exists?(branch)
|
|
69
68
|
local_branches.include?(branch)
|
|
70
69
|
end
|
|
71
70
|
|
|
@@ -12,11 +12,15 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
|
|
|
12
12
|
let(:cli) { Thegarage::Gitx::Cli::IntegrateCommand.new(args, options, config) }
|
|
13
13
|
let(:current_branch) { double('fake branch', name: 'feature-branch', head?: true) }
|
|
14
14
|
let(:repo) { cli.send(:repo) }
|
|
15
|
-
let(:remote_branch_names) { [] }
|
|
15
|
+
let(:remote_branch_names) { ['origin/staging', 'origin/prototype'] }
|
|
16
|
+
let(:local_branch_names) { ['feature-branch'] }
|
|
16
17
|
|
|
17
18
|
before do
|
|
18
19
|
allow(cli).to receive(:current_branch).and_return(current_branch)
|
|
19
|
-
|
|
20
|
+
branches = double('fake branches')
|
|
21
|
+
allow(branches).to receive(:each_name).with(:local).and_return(local_branch_names)
|
|
22
|
+
allow(branches).to receive(:each_name).with(:remote).and_return(remote_branch_names)
|
|
23
|
+
allow(repo).to receive(:branches).and_return(branches)
|
|
20
24
|
end
|
|
21
25
|
|
|
22
26
|
describe '#integrate' do
|
|
@@ -24,7 +28,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
|
|
|
24
28
|
before do
|
|
25
29
|
allow(Thegarage::Gitx::Cli::UpdateCommand).to receive(:new).and_return(fake_update_command)
|
|
26
30
|
end
|
|
27
|
-
context 'when
|
|
31
|
+
context 'when integration branch is ommitted and remote branch exists' do
|
|
28
32
|
let(:remote_branch_names) { ['origin/staging'] }
|
|
29
33
|
before do
|
|
30
34
|
expect(fake_update_command).to receive(:update)
|
|
@@ -64,7 +68,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
|
|
|
64
68
|
should meet_expectations
|
|
65
69
|
end
|
|
66
70
|
end
|
|
67
|
-
context 'when
|
|
71
|
+
context 'when integration branch == prototype and remote branch exists' do
|
|
68
72
|
let(:remote_branch_names) { ['origin/prototype'] }
|
|
69
73
|
before do
|
|
70
74
|
expect(fake_update_command).to receive(:update)
|
|
@@ -82,7 +86,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
|
|
|
82
86
|
should meet_expectations
|
|
83
87
|
end
|
|
84
88
|
end
|
|
85
|
-
context 'when
|
|
89
|
+
context 'when integration branch is not an aggregate branch' do
|
|
86
90
|
it 'raises an error' do
|
|
87
91
|
expect { cli.integrate('some-other-branch') }.to raise_error(/Invalid aggregate branch: some-other-branch must be one of supported aggregate branches/)
|
|
88
92
|
end
|
|
@@ -111,13 +115,11 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
|
|
|
111
115
|
}
|
|
112
116
|
end
|
|
113
117
|
let(:repo) { cli.send(:repo) }
|
|
114
|
-
let(:branches) { double(each_name: ['feature-branch']) }
|
|
115
118
|
before do
|
|
116
|
-
expect(
|
|
119
|
+
expect(fake_update_command).to receive(:update)
|
|
117
120
|
|
|
118
121
|
expect(cli).not_to receive(:run_cmd).with("git branch -D staging")
|
|
119
|
-
expect(cli).
|
|
120
|
-
expect(options[:resume]).to match("feature-branch")
|
|
122
|
+
expect(cli).not_to receive(:run_cmd).with("git push origin HEAD")
|
|
121
123
|
expect(cli).to receive(:run_cmd).with("git checkout feature-branch")
|
|
122
124
|
|
|
123
125
|
cli.integrate
|
|
@@ -134,14 +136,14 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
|
|
|
134
136
|
end
|
|
135
137
|
let(:repo) { cli.send(:repo) }
|
|
136
138
|
let(:branches) { double(each_name: ['my-feature-branch'])}
|
|
139
|
+
let(:local_branch_names) { ['another-feature-branch'] }
|
|
137
140
|
before do
|
|
138
|
-
expect(
|
|
139
|
-
|
|
140
|
-
expect(cli).to receive(:ask).and_return('my-feature-branch')
|
|
141
|
+
expect(fake_update_command).to receive(:update)
|
|
142
|
+
expect(cli).to receive(:ask).and_return('another-feature-branch')
|
|
141
143
|
|
|
142
144
|
expect(cli).not_to receive(:run_cmd).with("git branch -D staging")
|
|
143
|
-
expect(cli).
|
|
144
|
-
expect(cli).to receive(:run_cmd).with("git checkout
|
|
145
|
+
expect(cli).not_to receive(:run_cmd).with("git push origin HEAD")
|
|
146
|
+
expect(cli).to receive(:run_cmd).with("git checkout another-feature-branch").ordered
|
|
145
147
|
|
|
146
148
|
cli.integrate
|
|
147
149
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: thegarage-gitx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.5.0.
|
|
4
|
+
version: 2.5.0.beta5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Sonnek
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-09-
|
|
11
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rugged
|