thegarage-gitx 1.1.0 → 1.2.0.beta1
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 +4 -4
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/README.md +7 -0
- data/bin/git-buildtag +4 -0
- data/lib/thegarage/gitx/cli.rb +39 -0
- data/lib/thegarage/gitx/version.rb +1 -1
- data/lib/thegarage/gitx.rb +0 -13
- data/spec/spec_helper.rb +13 -28
- data/spec/support/meet_expectations_matcher.rb +7 -0
- data/spec/thegarage/gitx/cli_spec.rb +254 -146
- data/thegarage-gitx.gemspec +1 -0
- metadata +25 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f48eab04a8576c7f4757294009f53818b01f3cc
|
4
|
+
data.tar.gz: ac2707ffbe75737ebb5fcfa8908008468803f31c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43d0831356ca1cafa085e85705568d2409c8ca62aa325a4bfbb63b45113c75c75333ce59bfb91d3dfd0278d90466334a45ee66d3b411f1c19d13dd890a91338f
|
7
|
+
data.tar.gz: e44c8876673101a8da4c5c830929ca1a58b4384bbfd53ba60392260df7330eae914312668b156182b4edf77231d2f7fcdac2a5e659b3bcfacfd3c791301d713f
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# thegarage-gitx
|
2
2
|
|
3
|
+
[](https://travis-ci.org/thegarage/thegarage-gitx)
|
4
|
+
|
3
5
|
Useful Git eXtensions for Development workflow at The Garage.
|
4
6
|
|
5
7
|
Inspired by the [socialcast-git-extensions gem](https://github.com/socialcast/socialcast-git-extensions)
|
@@ -28,6 +30,7 @@ create a pull request on github for peer review of the current branch.
|
|
28
30
|
## git release
|
29
31
|
|
30
32
|
release the current feature branch to master. This operation will perform the following:
|
33
|
+
|
31
34
|
* pull in latest code from remote branch
|
32
35
|
* merge in latest code from master branch
|
33
36
|
* prompt user to confirm they actually want to perform the release
|
@@ -44,6 +47,10 @@ delete released branches after they have been merged into master.
|
|
44
47
|
|
45
48
|
reset an aggregate branch (ex: prototype, staging) back to a known good state.
|
46
49
|
|
50
|
+
## git buildtag
|
51
|
+
|
52
|
+
create a build tag for the current Travis-CI build and push it back to origin
|
53
|
+
|
47
54
|
|
48
55
|
## Note on Patches/Pull Requests
|
49
56
|
|
data/bin/git-buildtag
ADDED
data/lib/thegarage/gitx/cli.rb
CHANGED
@@ -5,6 +5,9 @@ require 'thegarage/gitx'
|
|
5
5
|
module Thegarage
|
6
6
|
module Gitx
|
7
7
|
class CLI < Thor
|
8
|
+
include Thor::Actions
|
9
|
+
add_runtime_options!
|
10
|
+
|
8
11
|
include Thegarage::Gitx
|
9
12
|
include Thegarage::Gitx::Git
|
10
13
|
include Thegarage::Gitx::Github
|
@@ -15,6 +18,7 @@ module Thegarage
|
|
15
18
|
# Link to ticket describing feature/bug (plantain, JIRA, bugzilla). Format is [title](url).
|
16
19
|
# Brief description of the change, and how it accomplishes the task they set out to do.
|
17
20
|
EOS
|
21
|
+
TAGGABLE_BRANCHES = %w(master staging)
|
18
22
|
|
19
23
|
method_option :trace, :type => :boolean, :aliases => '-v'
|
20
24
|
def initialize(*args)
|
@@ -136,6 +140,41 @@ module Thegarage
|
|
136
140
|
integrate_branch('master', 'staging')
|
137
141
|
cleanup
|
138
142
|
end
|
143
|
+
|
144
|
+
desc 'buildtag', 'create a tag for the current Travis-CI build and push it back to origin'
|
145
|
+
def buildtag
|
146
|
+
travis_branch = ENV['TRAVIS_BRANCH']
|
147
|
+
pull_request = ENV['TRAVIS_PULL_REQUEST']
|
148
|
+
|
149
|
+
raise "Unknown branch. ENV['TRAVIS_BRANCH'] is required." unless travis_branch
|
150
|
+
|
151
|
+
if pull_request != 'false'
|
152
|
+
say "Skipping creation of tag for pull request: #{pull_request}"
|
153
|
+
elsif !TAGGABLE_BRANCHES.include?(travis_branch)
|
154
|
+
say "Cannot create build tag for branch: #{travis_branch}. Only #{TAGGABLE_BRANCHES} are supported."
|
155
|
+
else
|
156
|
+
timestamp = Time.now.utc.strftime '%Y-%m-%d-%H-%M-%S'
|
157
|
+
git_tag = "build-#{travis_branch}-#{timestamp}"
|
158
|
+
run_cmd "git tag #{git_tag} -a -m 'Generated tag from TravisCI build #{ENV['TRAVIS_BUILD_NUMBER']}'"
|
159
|
+
run_cmd "git push origin #{git_tag}"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
# execute a shell command and raise an error if non-zero exit code is returned
|
166
|
+
# return the string output from the command
|
167
|
+
def run_cmd(cmd, options = {})
|
168
|
+
output = run(cmd, capture: true)
|
169
|
+
success = $CHILD_STATUS.to_i == 0
|
170
|
+
fail "#{cmd} failed" unless success || options[:allow_failure]
|
171
|
+
output
|
172
|
+
end
|
173
|
+
|
174
|
+
# check if --pretend or -p flag passed to CLI
|
175
|
+
def pretend?
|
176
|
+
options[:pretend]
|
177
|
+
end
|
139
178
|
end
|
140
179
|
end
|
141
180
|
end
|
data/lib/thegarage/gitx.rb
CHANGED
@@ -8,18 +8,5 @@ require 'English'
|
|
8
8
|
module Thegarage
|
9
9
|
module Gitx
|
10
10
|
BASE_BRANCH = 'master'
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
# execute a shell command and raise an error if non-zero exit code is returned
|
15
|
-
# return the string output from the command
|
16
|
-
def run_cmd(cmd, options = {})
|
17
|
-
say "\n$ "
|
18
|
-
say cmd.gsub("'", ''), :red
|
19
|
-
output = `#{cmd}`
|
20
|
-
success = $CHILD_STATUS.to_i == 0
|
21
|
-
raise "#{cmd} failed" unless success || options[:allow_failure]
|
22
|
-
output
|
23
|
-
end
|
24
11
|
end
|
25
12
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,36 +1,21 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
|
-
require 'rspec/mocks'
|
4
|
-
require 'webmock/rspec'
|
5
3
|
require 'pry'
|
6
|
-
|
7
|
-
|
4
|
+
require 'webmock/rspec'
|
8
5
|
require 'thegarage/gitx/cli'
|
9
6
|
|
10
|
-
|
11
|
-
|
7
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
8
|
+
# in spec/support/ and its subdirectories.
|
9
|
+
Dir[File.join(__dir__, "support/**/*.rb")].each { |f| require f }
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
eval "$#{stream} = StringIO.new"
|
18
|
-
begin
|
19
|
-
yield
|
20
|
-
rescue SystemExit => system_exit # catch any exit calls
|
21
|
-
exit_status = system_exit.status
|
22
|
-
end
|
23
|
-
result = eval("$#{stream}").string
|
24
|
-
ensure
|
25
|
-
eval("$#{stream} = #{stream.upcase}")
|
26
|
-
end
|
27
|
-
return result, exit_status
|
28
|
-
end
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
config.filter_run :focus
|
29
15
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
16
|
+
# Run specs in random order to surface order dependencies. If you find an
|
17
|
+
# order dependency and want to debug it, you can fix the order by providing
|
18
|
+
# the seed, which is printed after each run.
|
19
|
+
# --seed 1234
|
20
|
+
config.order = 'random'
|
36
21
|
end
|
@@ -1,87 +1,82 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'timecop'
|
2
3
|
|
3
4
|
describe Thegarage::Gitx::CLI do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# stub out command execution and record commands for test inspection
|
11
|
-
def run_cmd(cmd, options={})
|
12
|
-
self.class.stubbed_executed_commands << cmd
|
13
|
-
''
|
14
|
-
end
|
15
|
-
# stub branch to always be a known branch
|
16
|
-
def current_branch
|
17
|
-
'FOO'
|
18
|
-
end
|
19
|
-
# stub current user to always be known
|
20
|
-
def current_user
|
21
|
-
'wireframe'
|
22
|
-
end
|
5
|
+
let(:args) { [] }
|
6
|
+
let(:options) { {} }
|
7
|
+
let(:config) do
|
8
|
+
{
|
9
|
+
pretend: true
|
10
|
+
}
|
23
11
|
end
|
12
|
+
let(:cli) { Thegarage::Gitx::CLI.new(args, options, config) }
|
24
13
|
|
25
14
|
before do
|
26
|
-
|
15
|
+
# default current branch to: feature-branch
|
16
|
+
allow(cli).to receive(:current_branch).and_return('feature-branch')
|
27
17
|
end
|
28
18
|
|
19
|
+
|
29
20
|
describe '#update' do
|
30
21
|
before do
|
31
|
-
|
22
|
+
expect(cli).to receive(:run).with('git pull origin feature-branch', capture: true).ordered
|
23
|
+
expect(cli).to receive(:run).with('git pull origin master', capture: true).ordered
|
24
|
+
expect(cli).to receive(:run).with('git push origin HEAD', capture: true).ordered
|
25
|
+
|
26
|
+
cli.update
|
32
27
|
end
|
33
28
|
it 'should run expected commands' do
|
34
|
-
|
35
|
-
'git pull origin FOO',
|
36
|
-
'git pull origin master',
|
37
|
-
'git push origin HEAD'
|
38
|
-
]
|
29
|
+
should meet_expectations
|
39
30
|
end
|
40
31
|
end
|
41
32
|
|
42
33
|
describe '#integrate' do
|
43
34
|
context 'when target branch is ommitted' do
|
44
35
|
before do
|
45
|
-
|
36
|
+
expect(cli).to receive(:run).with("git pull origin feature-branch", capture: true).ordered
|
37
|
+
expect(cli).to receive(:run).with("git pull origin master", capture: true).ordered
|
38
|
+
expect(cli).to receive(:run).with("git push origin HEAD", capture: true).ordered
|
39
|
+
expect(cli).to receive(:run).with("git branch -D staging", capture: true).ordered
|
40
|
+
expect(cli).to receive(:run).with("git fetch origin", capture: true).ordered
|
41
|
+
expect(cli).to receive(:run).with("git checkout staging", capture: true).ordered
|
42
|
+
expect(cli).to receive(:run).with("git pull . feature-branch", capture: true).ordered
|
43
|
+
expect(cli).to receive(:run).with("git push origin HEAD", capture: true).ordered
|
44
|
+
expect(cli).to receive(:run).with("git checkout feature-branch", capture: true).ordered
|
45
|
+
expect(cli).to receive(:run).with("git checkout feature-branch", capture: true).ordered
|
46
|
+
|
47
|
+
cli.integrate
|
46
48
|
end
|
47
49
|
it 'should default to staging' do
|
48
|
-
|
49
|
-
"git pull origin FOO",
|
50
|
-
"git pull origin master",
|
51
|
-
"git push origin HEAD",
|
52
|
-
"git branch -D staging",
|
53
|
-
"git fetch origin",
|
54
|
-
"git checkout staging",
|
55
|
-
"git pull . FOO",
|
56
|
-
"git push origin HEAD",
|
57
|
-
"git checkout FOO",
|
58
|
-
"git checkout FOO"
|
59
|
-
]
|
50
|
+
should meet_expectations
|
60
51
|
end
|
61
52
|
end
|
62
53
|
context 'when target branch == prototype' do
|
63
54
|
before do
|
64
|
-
|
55
|
+
expect(cli).to receive(:run).with("git pull origin feature-branch", capture: true).ordered
|
56
|
+
expect(cli).to receive(:run).with("git pull origin master", capture: true).ordered
|
57
|
+
expect(cli).to receive(:run).with("git push origin HEAD", capture: true).ordered
|
58
|
+
expect(cli).to receive(:run).with("git branch -D prototype", capture: true).ordered
|
59
|
+
expect(cli).to receive(:run).with("git fetch origin", capture: true).ordered
|
60
|
+
expect(cli).to receive(:run).with("git checkout prototype", capture: true).ordered
|
61
|
+
expect(cli).to receive(:run).with("git pull . feature-branch", capture: true).ordered
|
62
|
+
expect(cli).to receive(:run).with("git push origin HEAD", capture: true).ordered
|
63
|
+
expect(cli).to receive(:run).with("git checkout feature-branch", capture: true).ordered
|
64
|
+
expect(cli).to receive(:run).with("git checkout feature-branch", capture: true).ordered
|
65
|
+
|
66
|
+
cli.integrate 'prototype'
|
65
67
|
end
|
66
68
|
it 'should run expected commands' do
|
67
|
-
|
68
|
-
"git pull origin FOO",
|
69
|
-
"git pull origin master",
|
70
|
-
"git push origin HEAD",
|
71
|
-
"git branch -D prototype",
|
72
|
-
"git fetch origin",
|
73
|
-
"git checkout prototype",
|
74
|
-
"git pull . FOO",
|
75
|
-
"git push origin HEAD",
|
76
|
-
"git checkout FOO",
|
77
|
-
"git checkout FOO"
|
78
|
-
]
|
69
|
+
should meet_expectations
|
79
70
|
end
|
80
71
|
end
|
81
72
|
context 'when target branch != staging || prototype' do
|
82
73
|
it 'should raise an error' do
|
74
|
+
expect(cli).to receive(:run).with("git pull origin feature-branch", capture: true).ordered
|
75
|
+
expect(cli).to receive(:run).with("git pull origin master", capture: true).ordered
|
76
|
+
expect(cli).to receive(:run).with("git push origin HEAD", capture: true).ordered
|
77
|
+
|
83
78
|
lambda {
|
84
|
-
|
79
|
+
cli.integrate 'some-other-branch'
|
85
80
|
}.should raise_error(/Only aggregate branches are allowed for integration/)
|
86
81
|
end
|
87
82
|
end
|
@@ -90,157 +85,270 @@ describe Thegarage::Gitx::CLI do
|
|
90
85
|
describe '#release' do
|
91
86
|
context 'when user rejects release' do
|
92
87
|
before do
|
93
|
-
|
94
|
-
|
88
|
+
expect(cli).to receive(:yes?).and_return(false)
|
89
|
+
|
90
|
+
expect(cli).to receive(:run).with("git pull origin feature-branch", capture: true).ordered
|
91
|
+
expect(cli).to receive(:run).with("git pull origin master", capture: true).ordered
|
92
|
+
expect(cli).to receive(:run).with("git push origin HEAD", capture: true).ordered
|
93
|
+
|
94
|
+
cli.release
|
95
95
|
end
|
96
96
|
it 'should only run update commands' do
|
97
|
-
|
98
|
-
"git pull origin FOO",
|
99
|
-
"git pull origin master",
|
100
|
-
"git push origin HEAD"
|
101
|
-
]
|
97
|
+
should meet_expectations
|
102
98
|
end
|
103
99
|
end
|
104
100
|
context 'when user confirms release' do
|
105
101
|
before do
|
106
|
-
|
107
|
-
|
102
|
+
expect(cli).to receive(:yes?).and_return(true)
|
103
|
+
expect(cli).to receive(:branches).and_return(%w( old-merged-feature )).twice
|
104
|
+
|
105
|
+
expect(cli).to receive(:run).with("git pull origin feature-branch", capture: true).ordered
|
106
|
+
expect(cli).to receive(:run).with("git pull origin master", capture: true).ordered
|
107
|
+
expect(cli).to receive(:run).with("git push origin HEAD", capture: true).ordered
|
108
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
109
|
+
expect(cli).to receive(:run).with("git pull origin master", capture: true).ordered
|
110
|
+
expect(cli).to receive(:run).with("git pull . feature-branch", capture: true).ordered
|
111
|
+
expect(cli).to receive(:run).with("git push origin HEAD", capture: true).ordered
|
112
|
+
expect(cli).to receive(:run).with("git branch -D staging", capture: true).ordered
|
113
|
+
expect(cli).to receive(:run).with("git fetch origin", capture: true).ordered
|
114
|
+
expect(cli).to receive(:run).with("git checkout staging", capture: true).ordered
|
115
|
+
expect(cli).to receive(:run).with("git pull . master", capture: true).ordered
|
116
|
+
expect(cli).to receive(:run).with("git push origin HEAD", capture: true).ordered
|
117
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
118
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
119
|
+
expect(cli).to receive(:run).with("git pull", capture: true).ordered
|
120
|
+
expect(cli).to receive(:run).with("git remote prune origin", capture: true).ordered
|
121
|
+
expect(cli).to receive(:run).with("git push origin --delete old-merged-feature", capture: true).ordered
|
122
|
+
expect(cli).to receive(:run).with("git branch -d old-merged-feature", capture: true).ordered
|
123
|
+
|
124
|
+
cli.release
|
108
125
|
end
|
109
126
|
it 'should run expected commands' do
|
110
|
-
|
111
|
-
"git pull origin FOO",
|
112
|
-
"git pull origin master",
|
113
|
-
"git push origin HEAD",
|
114
|
-
"git checkout master",
|
115
|
-
"git pull origin master",
|
116
|
-
"git pull . FOO",
|
117
|
-
"git push origin HEAD",
|
118
|
-
"git branch -D staging",
|
119
|
-
"git fetch origin",
|
120
|
-
"git checkout staging",
|
121
|
-
"git pull . master",
|
122
|
-
"git push origin HEAD",
|
123
|
-
"git checkout master",
|
124
|
-
"git checkout master",
|
125
|
-
"git pull",
|
126
|
-
"git remote prune origin"
|
127
|
-
]
|
127
|
+
should meet_expectations
|
128
128
|
end
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
132
|
describe '#nuke' do
|
133
133
|
context 'when target branch == prototype and --destination == master' do
|
134
|
+
let(:options) do
|
135
|
+
{
|
136
|
+
destination: 'master'
|
137
|
+
}
|
138
|
+
end
|
139
|
+
let(:buildtags) do
|
140
|
+
%w( build-master-2013-10-01-01 ).join("\n")
|
141
|
+
end
|
134
142
|
before do
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
143
|
+
expect(cli).to receive(:yes?).and_return(true)
|
144
|
+
|
145
|
+
expect(cli).to receive(:run).with("git fetch --tags", capture: true).ordered
|
146
|
+
expect(cli).to receive(:run).with("git tag -l 'build-master-*'", capture: true).and_return(buildtags).ordered
|
147
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
148
|
+
expect(cli).to receive(:run).with("git branch -D prototype", capture: true).ordered
|
149
|
+
expect(cli).to receive(:run).with("git push origin --delete prototype", capture: true).ordered
|
150
|
+
expect(cli).to receive(:run).with("git checkout -b prototype build-master-2013-10-01-01", capture: true).ordered
|
151
|
+
expect(cli).to receive(:run).with("git push origin prototype", capture: true).ordered
|
152
|
+
expect(cli).to receive(:run).with("git branch --set-upstream-to origin/prototype", capture: true).ordered
|
153
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
154
|
+
|
155
|
+
cli.nuke 'prototype'
|
140
156
|
end
|
141
157
|
it 'should run expected commands' do
|
142
|
-
|
143
|
-
"git checkout master",
|
144
|
-
"git branch -D prototype",
|
145
|
-
"git push origin --delete prototype",
|
146
|
-
"git checkout -b prototype build-master-2013-10-01-01",
|
147
|
-
"git push origin prototype",
|
148
|
-
"git branch --set-upstream prototype origin/prototype",
|
149
|
-
"git checkout master"
|
150
|
-
]
|
158
|
+
should meet_expectations
|
151
159
|
end
|
152
160
|
end
|
153
161
|
context 'when target branch == staging and --destination == staging' do
|
162
|
+
let(:options) do
|
163
|
+
{
|
164
|
+
destination: 'staging'
|
165
|
+
}
|
166
|
+
end
|
167
|
+
let(:buildtags) do
|
168
|
+
%w( build-staging-2013-10-02-02 ).join("\n")
|
169
|
+
end
|
154
170
|
before do
|
155
|
-
|
156
|
-
|
171
|
+
expect(cli).to receive(:yes?).and_return(true)
|
172
|
+
|
173
|
+
expect(cli).to receive(:run).with("git fetch --tags", capture: true).ordered
|
174
|
+
expect(cli).to receive(:run).with("git tag -l 'build-staging-*'", capture: true).and_return(buildtags).ordered
|
175
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
176
|
+
expect(cli).to receive(:run).with("git branch -D staging", capture: true).ordered
|
177
|
+
expect(cli).to receive(:run).with("git push origin --delete staging", capture: true).ordered
|
178
|
+
expect(cli).to receive(:run).with("git checkout -b staging build-staging-2013-10-02-02", capture: true).ordered
|
179
|
+
expect(cli).to receive(:run).with("git push origin staging", capture: true).ordered
|
180
|
+
expect(cli).to receive(:run).with("git branch --set-upstream-to origin/staging", capture: true).ordered
|
181
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
182
|
+
|
183
|
+
cli.nuke 'staging'
|
157
184
|
end
|
158
185
|
it 'should run expected commands' do
|
159
|
-
|
160
|
-
"git checkout master",
|
161
|
-
"git branch -D staging",
|
162
|
-
"git push origin --delete staging",
|
163
|
-
"git checkout -b staging build-staging-2013-10-02-02",
|
164
|
-
"git push origin staging",
|
165
|
-
"git branch --set-upstream staging origin/staging",
|
166
|
-
"git checkout master"
|
167
|
-
]
|
186
|
+
should meet_expectations
|
168
187
|
end
|
169
188
|
end
|
170
189
|
context 'when target branch == prototype and destination prompt == nil' do
|
190
|
+
let(:buildtags) do
|
191
|
+
%w( build-prototype-2013-10-03-03 ).join("\n")
|
192
|
+
end
|
171
193
|
before do
|
172
|
-
|
173
|
-
|
174
|
-
|
194
|
+
expect(cli).to receive(:ask).and_return('')
|
195
|
+
expect(cli).to receive(:yes?).and_return(true)
|
196
|
+
|
197
|
+
expect(cli).to receive(:run).with("git fetch --tags", capture: true).ordered
|
198
|
+
expect(cli).to receive(:run).with("git tag -l 'build-prototype-*'", capture: true).and_return(buildtags).ordered
|
199
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
200
|
+
expect(cli).to receive(:run).with("git branch -D prototype", capture: true).ordered
|
201
|
+
expect(cli).to receive(:run).with("git push origin --delete prototype", capture: true).ordered
|
202
|
+
expect(cli).to receive(:run).with("git checkout -b prototype build-prototype-2013-10-03-03", capture: true).ordered
|
203
|
+
expect(cli).to receive(:run).with("git push origin prototype", capture: true).ordered
|
204
|
+
expect(cli).to receive(:run).with("git branch --set-upstream-to origin/prototype", capture: true).ordered
|
205
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
206
|
+
|
207
|
+
cli.nuke 'prototype'
|
175
208
|
end
|
176
209
|
it 'defaults to prototype and should run expected commands' do
|
177
|
-
|
178
|
-
"git checkout master",
|
179
|
-
"git branch -D prototype",
|
180
|
-
"git push origin --delete prototype",
|
181
|
-
"git checkout -b prototype build-prototype-2013-10-02-03",
|
182
|
-
"git push origin prototype",
|
183
|
-
"git branch --set-upstream prototype origin/prototype",
|
184
|
-
"git checkout master"
|
185
|
-
]
|
210
|
+
should meet_expectations
|
186
211
|
end
|
187
212
|
end
|
188
213
|
context 'when target branch == prototype and destination prompt = master' do
|
214
|
+
let(:buildtags) do
|
215
|
+
%w( build-master-2013-10-01-01 ).join("\n")
|
216
|
+
end
|
189
217
|
before do
|
190
|
-
|
191
|
-
|
192
|
-
|
218
|
+
expect(cli).to receive(:ask).and_return('master')
|
219
|
+
expect(cli).to receive(:yes?).and_return(true)
|
220
|
+
|
221
|
+
expect(cli).to receive(:run).with("git fetch --tags", capture: true).ordered
|
222
|
+
expect(cli).to receive(:run).with("git tag -l 'build-master-*'", capture: true).and_return(buildtags).ordered
|
223
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
224
|
+
expect(cli).to receive(:run).with("git branch -D prototype", capture: true).ordered
|
225
|
+
expect(cli).to receive(:run).with("git push origin --delete prototype", capture: true).ordered
|
226
|
+
expect(cli).to receive(:run).with("git checkout -b prototype build-master-2013-10-01-01", capture: true).ordered
|
227
|
+
expect(cli).to receive(:run).with("git push origin prototype", capture: true).ordered
|
228
|
+
expect(cli).to receive(:run).with("git branch --set-upstream-to origin/prototype", capture: true).ordered
|
229
|
+
expect(cli).to receive(:run).with("git checkout master", capture: true).ordered
|
230
|
+
|
231
|
+
cli.nuke 'prototype'
|
193
232
|
end
|
194
233
|
it 'should run expected commands' do
|
195
|
-
|
196
|
-
"git checkout master",
|
197
|
-
"git branch -D prototype",
|
198
|
-
"git push origin --delete prototype",
|
199
|
-
"git checkout -b prototype build-master-2013-10-01-01",
|
200
|
-
"git push origin prototype",
|
201
|
-
"git branch --set-upstream prototype origin/prototype",
|
202
|
-
"git checkout master"
|
203
|
-
]
|
234
|
+
should meet_expectations
|
204
235
|
end
|
205
236
|
end
|
206
237
|
context 'when target branch != staging || prototype' do
|
207
238
|
it 'should raise error' do
|
208
239
|
lambda {
|
209
|
-
|
210
|
-
|
211
|
-
|
240
|
+
expect(cli).to receive(:ask).and_return('master')
|
241
|
+
expect(cli).to receive(:yes?).and_return(true)
|
242
|
+
cli.nuke 'not-an-integration-branch'
|
212
243
|
}.should raise_error /Only aggregate branches are allowed to be reset/
|
213
244
|
end
|
214
245
|
end
|
215
246
|
context 'when user does not confirm nuking the target branch' do
|
247
|
+
let(:buildtags) do
|
248
|
+
%w( build-master-2013-10-01-01 ).join("\n")
|
249
|
+
end
|
216
250
|
before do
|
217
|
-
|
218
|
-
|
219
|
-
|
251
|
+
expect(cli).to receive(:ask).and_return('master')
|
252
|
+
expect(cli).to receive(:yes?).and_return(false)
|
253
|
+
|
254
|
+
expect(cli).to receive(:run).with("git fetch --tags", capture: true).ordered
|
255
|
+
expect(cli).to receive(:run).with("git tag -l 'build-master-*'", capture: true).and_return(buildtags).ordered
|
256
|
+
|
257
|
+
cli.nuke 'prototype'
|
220
258
|
end
|
221
259
|
it 'should run expected commands' do
|
222
|
-
|
223
|
-
|
224
|
-
|
260
|
+
should meet_expectations
|
261
|
+
end
|
262
|
+
end
|
263
|
+
context 'when no known good build tag found' do
|
264
|
+
let(:buildtags) do
|
265
|
+
''
|
266
|
+
end
|
267
|
+
it 'raises error' do
|
268
|
+
expect(cli).to receive(:ask).and_return('master')
|
269
|
+
|
270
|
+
expect(cli).to receive(:run).with("git fetch --tags", capture: true).ordered
|
271
|
+
expect(cli).to receive(:run).with("git tag -l 'build-master-*'", capture: true).and_return(buildtags).ordered
|
272
|
+
|
273
|
+
expect { cli.nuke('prototype') }.to raise_error /No known good tag found for branch/
|
225
274
|
end
|
226
275
|
end
|
227
276
|
end
|
228
277
|
|
229
278
|
describe '#reviewrequest' do
|
230
|
-
context 'when description != null' do
|
279
|
+
context 'when description != null and there is an existing authorization_token' do
|
280
|
+
let(:options) { {description: 'testing'} }
|
281
|
+
let(:authorization_token) { '123981239123' }
|
231
282
|
before do
|
232
283
|
stub_request(:post, "https://api.github.com/repos/thegarage/thegarage-gitx/pulls").
|
233
284
|
to_return(:status => 200, :body => %q({"html_url": "http://github.com/repo/project/pulls/1"}), :headers => {})
|
234
285
|
|
235
|
-
|
286
|
+
expect(cli).to receive(:authorization_token).and_return(authorization_token)
|
287
|
+
|
288
|
+
expect(cli).to receive(:run).with("git pull origin feature-branch", capture: true).ordered
|
289
|
+
expect(cli).to receive(:run).with("git pull origin master", capture: true).ordered
|
290
|
+
expect(cli).to receive(:run).with("git push origin HEAD", capture: true).ordered
|
291
|
+
|
292
|
+
cli.reviewrequest
|
293
|
+
end
|
294
|
+
it 'should create github pull request' do
|
295
|
+
should meet_expectations
|
236
296
|
end
|
237
|
-
it 'should create github pull request' do end # see expectations
|
238
297
|
it 'should run expected commands' do
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
298
|
+
should meet_expectations
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
describe '#buildtag' do
|
304
|
+
let(:env_travis_branch) { nil }
|
305
|
+
let(:env_travis_pull_request) { nil }
|
306
|
+
let(:env_travis_build_number) { nil }
|
307
|
+
before do
|
308
|
+
ENV['TRAVIS_BRANCH'] = env_travis_branch
|
309
|
+
ENV['TRAVIS_PULL_REQUEST'] = env_travis_pull_request
|
310
|
+
ENV['TRAVIS_BUILD_NUMBER'] = env_travis_build_number
|
311
|
+
end
|
312
|
+
context 'when ENV[\'TRAVIS_BRANCH\'] is nil' do
|
313
|
+
it 'should raise Unknown Branch error' do
|
314
|
+
expect { cli.buildtag }.to raise_error "Unknown branch. ENV['TRAVIS_BRANCH'] is required."
|
315
|
+
end
|
316
|
+
end
|
317
|
+
context 'when the travis branch is master and the travis pull request is not false' do
|
318
|
+
let(:env_travis_branch) { 'master' }
|
319
|
+
let(:env_travis_pull_request) { '45' }
|
320
|
+
before do
|
321
|
+
expect(cli).to receive(:say).with("Skipping creation of tag for pull request: #{ENV['TRAVIS_PULL_REQUEST']}")
|
322
|
+
cli.buildtag
|
323
|
+
end
|
324
|
+
it 'tells us that it is skipping the creation of the tag' do
|
325
|
+
should meet_expectations
|
326
|
+
end
|
327
|
+
end
|
328
|
+
context 'when the travis branch is NOT master and is not a pull request' do
|
329
|
+
let(:env_travis_branch) { 'random-branch' }
|
330
|
+
let(:env_travis_pull_request) { 'false' }
|
331
|
+
before do
|
332
|
+
expect(cli).to receive(:say).with(/Cannot create build tag for branch: #{ENV['TRAVIS_BRANCH']}/)
|
333
|
+
cli.buildtag
|
334
|
+
end
|
335
|
+
it 'tells us that the branch is not supported' do
|
336
|
+
should meet_expectations
|
337
|
+
end
|
338
|
+
end
|
339
|
+
context 'when the travis branch is master and not a pull request' do
|
340
|
+
let(:env_travis_branch) { 'master' }
|
341
|
+
let(:env_travis_pull_request) { 'false' }
|
342
|
+
let(:env_travis_build_number) { '24' }
|
343
|
+
before do
|
344
|
+
Timecop.freeze(Time.utc(2013, 10, 30, 10, 21, 28)) do
|
345
|
+
expect(cli).to receive(:run).with("git tag build-master-2013-10-30-10-21-28 -a -m 'Generated tag from TravisCI build 24'", capture: true).ordered
|
346
|
+
expect(cli).to receive(:run).with("git push origin build-master-2013-10-30-10-21-28", capture: true).ordered
|
347
|
+
cli.buildtag
|
348
|
+
end
|
349
|
+
end
|
350
|
+
it 'should create a tag for the branch and push it to github' do
|
351
|
+
should meet_expectations
|
244
352
|
end
|
245
353
|
end
|
246
354
|
end
|
data/thegarage-gitx.gemspec
CHANGED
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: 1.
|
4
|
+
version: 1.2.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Sonnek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grit
|
@@ -122,10 +122,25 @@ dependencies:
|
|
122
122
|
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: timecop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.6.3
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.6.3
|
125
139
|
description: Git eXtensions for common development workflow
|
126
140
|
email:
|
127
141
|
- ryan.sonnek@gmail.com
|
128
142
|
executables:
|
143
|
+
- git-buildtag
|
129
144
|
- git-cleanup
|
130
145
|
- git-integrate
|
131
146
|
- git-nuke
|
@@ -140,12 +155,15 @@ extensions: []
|
|
140
155
|
extra_rdoc_files: []
|
141
156
|
files:
|
142
157
|
- .gitignore
|
158
|
+
- .rspec
|
143
159
|
- .ruby-gemset
|
144
160
|
- .ruby-version
|
161
|
+
- .travis.yml
|
145
162
|
- Gemfile
|
146
163
|
- LICENSE.txt
|
147
164
|
- README.md
|
148
165
|
- Rakefile
|
166
|
+
- bin/git-buildtag
|
149
167
|
- bin/git-cleanup
|
150
168
|
- bin/git-integrate
|
151
169
|
- bin/git-nuke
|
@@ -163,6 +181,7 @@ files:
|
|
163
181
|
- lib/thegarage/gitx/string_extensions.rb
|
164
182
|
- lib/thegarage/gitx/version.rb
|
165
183
|
- spec/spec_helper.rb
|
184
|
+
- spec/support/meet_expectations_matcher.rb
|
166
185
|
- spec/thegarage/gitx/cli_spec.rb
|
167
186
|
- thegarage-gitx.gemspec
|
168
187
|
homepage: ''
|
@@ -180,15 +199,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
199
|
version: '0'
|
181
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
201
|
requirements:
|
183
|
-
- - '
|
202
|
+
- - '>'
|
184
203
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
204
|
+
version: 1.3.1
|
186
205
|
requirements: []
|
187
206
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
207
|
+
rubygems_version: 2.0.7
|
189
208
|
signing_key:
|
190
209
|
specification_version: 4
|
191
210
|
summary: Utility scripts for Git to increase productivity for common operations
|
192
211
|
test_files:
|
193
212
|
- spec/spec_helper.rb
|
213
|
+
- spec/support/meet_expectations_matcher.rb
|
194
214
|
- spec/thegarage/gitx/cli_spec.rb
|