thegarage-gitx 2.3.0 → 2.4.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18f7a212c6ede8befd60a4c660860081d88b76bd
|
4
|
+
data.tar.gz: dd1b75b09a3f094dcef3653860f6f75d96305596
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 835eb5b2bd350ad126b6090957e1f4e5eafa45346774ebd7b9cf208f43d3a015c93d25a8165638b87b3237f62a9d223e6cff196e44af7cf4c210a973fa3018d1
|
7
|
+
data.tar.gz: f999cc27290a0cd1d319829b5335a206d98e8a9b1e516f15a63ed066673956407f622929188a954363b5a7cd1f89382068309545ab71c9638e8950634ccf9a27
|
@@ -8,25 +8,28 @@ module Thegarage
|
|
8
8
|
class BuildtagCommand < BaseCommand
|
9
9
|
TAGGABLE_BRANCHES = %w( master staging )
|
10
10
|
|
11
|
-
desc 'buildtag', 'create a tag for the current
|
11
|
+
desc 'buildtag', 'create a tag for the current build and push it back to origin (supports Travis CI and Codeship)'
|
12
12
|
def buildtag
|
13
|
-
branch
|
14
|
-
|
13
|
+
fail "Unknown branch. Environment variables TRAVIS_BRANCH or CI_BRANCH are required" unless branch_name
|
14
|
+
fail "Branch must be one of the supported taggable branches: #{TAGGABLE_BRANCHES}" unless TAGGABLE_BRANCHES.include?(branch_name)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
if pull_request != 'false'
|
19
|
-
say "Skipping creation of tag for pull request: #{pull_request}"
|
20
|
-
elsif !TAGGABLE_BRANCHES.include?(branch)
|
21
|
-
say "Cannot create build tag for branch: #{branch}. Only #{TAGGABLE_BRANCHES} are supported."
|
22
|
-
else
|
23
|
-
label = "Generated tag from TravisCI build #{ENV['TRAVIS_BUILD_NUMBER']}"
|
24
|
-
create_build_tag(branch, label)
|
25
|
-
end
|
16
|
+
label = "buildtag generated by build #{build_number}"
|
17
|
+
create_build_tag(branch_name, label)
|
26
18
|
end
|
27
19
|
|
28
20
|
private
|
29
21
|
|
22
|
+
# pull the current branch name from environment variables
|
23
|
+
# supports Travis CI or Codeship variables
|
24
|
+
# see https://www.codeship.io/documentation/continuous-integration/set-environment-variables/
|
25
|
+
def branch_name
|
26
|
+
ENV['TRAVIS_BRANCH'] || ENV['CI_BRANCH']
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_number
|
30
|
+
ENV['TRAVIS_BUILD_NUMBER'] || ENV['CI_BUILD_NUMBER']
|
31
|
+
end
|
32
|
+
|
30
33
|
def create_build_tag(branch, label)
|
31
34
|
timestamp = Time.now.utc.strftime '%Y-%m-%d-%H-%M-%S'
|
32
35
|
git_tag = "build-#{branch}-#{timestamp}"
|
@@ -18,47 +18,46 @@ describe Thegarage::Gitx::Cli::BuildtagCommand do
|
|
18
18
|
|
19
19
|
describe '#buildtag' do
|
20
20
|
let(:env_travis_branch) { nil }
|
21
|
-
let(:env_travis_pull_request) { nil }
|
22
21
|
let(:env_travis_build_number) { nil }
|
22
|
+
let(:env_ci_branch) { nil }
|
23
|
+
let(:env_ci_build_number) { nil }
|
23
24
|
before do
|
24
25
|
ENV['TRAVIS_BRANCH'] = env_travis_branch
|
25
|
-
ENV['TRAVIS_PULL_REQUEST'] = env_travis_pull_request
|
26
26
|
ENV['TRAVIS_BUILD_NUMBER'] = env_travis_build_number
|
27
|
+
ENV['CI_BRANCH'] = env_ci_branch
|
28
|
+
ENV['CI_BUILD_NUMBER'] = env_ci_build_number
|
27
29
|
end
|
28
|
-
context 'when
|
30
|
+
context 'when TRAVIS_BRANCH is nil' do
|
29
31
|
it 'raises Unknown Branch error' do
|
30
|
-
expect { cli.buildtag }.to raise_error
|
32
|
+
expect { cli.buildtag }.to raise_error(/Unknown branch/)
|
31
33
|
end
|
32
34
|
end
|
33
|
-
context 'when
|
34
|
-
let(:env_travis_branch) { '
|
35
|
-
|
36
|
-
|
37
|
-
expect(cli).to receive(:say).with("Skipping creation of tag for pull request: #{ENV['TRAVIS_PULL_REQUEST']}")
|
38
|
-
cli.buildtag
|
39
|
-
end
|
40
|
-
it 'tells us that it is skipping the creation of the tag' do
|
41
|
-
should meet_expectations
|
35
|
+
context 'when TRAVIS_BRANCH is NOT master or staging' do
|
36
|
+
let(:env_travis_branch) { 'random-branch' }
|
37
|
+
it 'raises unsupported branch error' do
|
38
|
+
expect { cli.buildtag }.to raise_error(/Branch must be one of the supported taggable branches/)
|
42
39
|
end
|
43
40
|
end
|
44
|
-
context 'when
|
45
|
-
let(:env_travis_branch) { '
|
46
|
-
let(:
|
41
|
+
context 'when TRAVIS_BRANCH is master' do
|
42
|
+
let(:env_travis_branch) { 'master' }
|
43
|
+
let(:env_travis_build_number) { '24' }
|
47
44
|
before do
|
48
|
-
|
49
|
-
|
45
|
+
Timecop.freeze(Time.utc(2013, 10, 30, 10, 21, 28)) do
|
46
|
+
expect(cli).to receive(:run_cmd).with("git tag build-master-2013-10-30-10-21-28 -a -m 'buildtag generated by build 24'").ordered
|
47
|
+
expect(cli).to receive(:run_cmd).with("git push origin build-master-2013-10-30-10-21-28").ordered
|
48
|
+
cli.buildtag
|
49
|
+
end
|
50
50
|
end
|
51
|
-
it '
|
51
|
+
it 'creates a tag for the branch and push it to github' do
|
52
52
|
should meet_expectations
|
53
53
|
end
|
54
54
|
end
|
55
|
-
context 'when
|
56
|
-
let(:
|
57
|
-
let(:
|
58
|
-
let(:env_travis_build_number) { '24' }
|
55
|
+
context 'when CI_BRANCH is master' do
|
56
|
+
let(:env_ci_branch) { 'master' }
|
57
|
+
let(:env_ci_build_number) { '24' }
|
59
58
|
before do
|
60
59
|
Timecop.freeze(Time.utc(2013, 10, 30, 10, 21, 28)) do
|
61
|
-
expect(cli).to receive(:run_cmd).with("git tag build-master-2013-10-30-10-21-28 -a -m '
|
60
|
+
expect(cli).to receive(:run_cmd).with("git tag build-master-2013-10-30-10-21-28 -a -m 'buildtag generated by build 24'").ordered
|
62
61
|
expect(cli).to receive(:run_cmd).with("git push origin build-master-2013-10-30-10-21-28").ordered
|
63
62
|
cli.buildtag
|
64
63
|
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.
|
4
|
+
version: 2.4.0.pre1
|
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-08-
|
11
|
+
date: 2014-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|
@@ -309,9 +309,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
309
309
|
version: '0'
|
310
310
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
311
311
|
requirements:
|
312
|
-
- - "
|
312
|
+
- - ">"
|
313
313
|
- !ruby/object:Gem::Version
|
314
|
-
version:
|
314
|
+
version: 1.3.1
|
315
315
|
requirements: []
|
316
316
|
rubyforge_project:
|
317
317
|
rubygems_version: 2.2.2
|