thegarage-gitx 2.11.0 → 2.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/thegarage/gitx.rb +1 -0
- data/lib/thegarage/gitx/cli/base_command.rb +7 -5
- data/lib/thegarage/gitx/cli/buildtag_command.rb +1 -2
- data/lib/thegarage/gitx/cli/cleanup_command.rb +2 -2
- data/lib/thegarage/gitx/cli/integrate_command.rb +1 -5
- data/lib/thegarage/gitx/cli/nuke_command.rb +1 -1
- data/lib/thegarage/gitx/configuration.rb +47 -0
- data/lib/thegarage/gitx/version.rb +1 -1
- data/spec/support/global_config.rb +7 -4
- data/spec/support/home_env.rb +1 -1
- data/spec/thegarage/gitx/cli/base_command_spec.rb +41 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c042898972c5d2092ec9f3a579a75e32c448a95
|
4
|
+
data.tar.gz: a8b5e3cd62170304f12cfdb4000e2325ad77325d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0aca7c57d79390ecfc96913132303a830fa258f6e3dd5d0a5f26de44b584a5cb840324f14ee160b06127cb37c8068eeaad86c5a6ff315fa3b23945ee35db624
|
7
|
+
data.tar.gz: cb4eed326c8c2ddeb0554d88a8722c84a06e40aab83856f0ee61051a13c9a061ce0b565f9da71b1b8d82b6d56c22a0b6d13f561c472edb72ca3aaac7f5c3b6d8
|
data/lib/thegarage/gitx.rb
CHANGED
@@ -11,8 +11,6 @@ module Thegarage
|
|
11
11
|
|
12
12
|
class MergeError < Thor::Error; end
|
13
13
|
|
14
|
-
AGGREGATE_BRANCHES = %w( staging prototype )
|
15
|
-
RESERVED_BRANCHES = %w( HEAD master next_release ) + AGGREGATE_BRANCHES
|
16
14
|
add_runtime_options!
|
17
15
|
|
18
16
|
method_option :trace, :type => :boolean, :aliases => '-v'
|
@@ -38,18 +36,22 @@ module Thegarage
|
|
38
36
|
repo.branches.find(&:head?)
|
39
37
|
end
|
40
38
|
|
41
|
-
def
|
42
|
-
|
39
|
+
def assert_aggregate_branch!(target_branch)
|
40
|
+
fail "Invalid aggregate branch: #{target_branch} must be one of supported aggregate branches #{config.aggregate_branches}" unless config.aggregate_branch?(target_branch)
|
43
41
|
end
|
44
42
|
|
45
43
|
def assert_not_protected_branch!(branch, action)
|
46
|
-
raise "Cannot #{action} reserved branch" if
|
44
|
+
raise "Cannot #{action} reserved branch" if config.reserved_branch?(branch) || config.aggregate_branch?(branch)
|
47
45
|
end
|
48
46
|
|
49
47
|
# helper to invoke other CLI commands
|
50
48
|
def execute_command(command_class, method, args = [])
|
51
49
|
command_class.new.send(method, *args)
|
52
50
|
end
|
51
|
+
|
52
|
+
def config
|
53
|
+
@configuration ||= Thegarage::Gitx::Configuration.new(repo.workdir)
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -6,12 +6,11 @@ module Thegarage
|
|
6
6
|
module Gitx
|
7
7
|
module Cli
|
8
8
|
class BuildtagCommand < BaseCommand
|
9
|
-
TAGGABLE_BRANCHES = %w( master staging )
|
10
9
|
|
11
10
|
desc 'buildtag', 'create a tag for the current build and push it back to origin (supports Travis CI and Codeship)'
|
12
11
|
def buildtag
|
13
12
|
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: #{
|
13
|
+
fail "Branch must be one of the supported taggable branches: #{config.taggable_branches}" unless config.taggable_branch?(branch_name)
|
15
14
|
|
16
15
|
label = "buildtag generated by build #{build_number}"
|
17
16
|
create_build_tag(branch_name, label)
|
@@ -26,7 +26,7 @@ module Thegarage
|
|
26
26
|
integrate_branch(branch, integration_branch) unless options[:resume]
|
27
27
|
checkout_branch branch
|
28
28
|
|
29
|
-
create_integrate_comment(branch) unless
|
29
|
+
create_integrate_comment(branch) unless config.reserved_branch?(branch)
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
@@ -59,10 +59,6 @@ module Thegarage
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
def assert_aggregate_branch!(target_branch)
|
63
|
-
fail "Invalid aggregate branch: #{target_branch} must be one of supported aggregate branches #{AGGREGATE_BRANCHES}" unless aggregate_branch?(target_branch)
|
64
|
-
end
|
65
|
-
|
66
62
|
# nuke local branch and pull fresh version from remote repo
|
67
63
|
def fetch_remote_branch(target_branch)
|
68
64
|
create_remote_branch(target_branch) unless remote_branch_exists?(target_branch)
|
@@ -14,7 +14,7 @@ module Thegarage
|
|
14
14
|
|
15
15
|
last_known_good_tag = current_build_tag(good_branch)
|
16
16
|
return unless yes?("Reset #{bad_branch} to #{last_known_good_tag}? (y/n)", :green)
|
17
|
-
|
17
|
+
assert_aggregate_branch!(bad_branch)
|
18
18
|
return if migrations_need_to_be_reverted?(bad_branch, last_known_good_tag)
|
19
19
|
|
20
20
|
say "Resetting "
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Thegarage
|
4
|
+
module Gitx
|
5
|
+
class Configuration
|
6
|
+
DEFAULT_CONFIG = {
|
7
|
+
'aggregate_branches' => %w( staging prototype ),
|
8
|
+
'reserved_branches' => %w( HEAD master next_release staging prototype ),
|
9
|
+
'taggable_branches' => %w( master staging )
|
10
|
+
}
|
11
|
+
CONFIG_FILE = '.gitx.yml'
|
12
|
+
|
13
|
+
attr_reader :config
|
14
|
+
|
15
|
+
def initialize(root_dir)
|
16
|
+
@config = Thor::CoreExt::HashWithIndifferentAccess.new(DEFAULT_CONFIG)
|
17
|
+
config_file_path = File.join(root_dir, CONFIG_FILE)
|
18
|
+
if File.exists?(config_file_path)
|
19
|
+
@config.merge!(::YAML::load_file(config_file_path))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def aggregate_branches
|
24
|
+
config[:aggregate_branches]
|
25
|
+
end
|
26
|
+
def aggregate_branch?(branch)
|
27
|
+
aggregate_branches.include?(branch)
|
28
|
+
end
|
29
|
+
|
30
|
+
def reserved_branches
|
31
|
+
config[:reserved_branches]
|
32
|
+
end
|
33
|
+
|
34
|
+
def reserved_branch?(branch)
|
35
|
+
reserved_branches.include?(branch)
|
36
|
+
end
|
37
|
+
|
38
|
+
def taggable_branches
|
39
|
+
config[:taggable_branches]
|
40
|
+
end
|
41
|
+
|
42
|
+
def taggable_branch?(branch)
|
43
|
+
taggable_branches.include?(branch)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,21 +1,24 @@
|
|
1
1
|
# helper for reading global config file
|
2
2
|
module GlobalConfig
|
3
3
|
def global_config_file
|
4
|
-
|
5
|
-
|
4
|
+
config_file = File.join(temp_dir, '.config/gitx/github.yml')
|
5
|
+
config_dir = File.dirname(config_file)
|
6
6
|
FileUtils.mkdir_p(config_dir) unless File.exists?(config_dir)
|
7
7
|
config_file
|
8
8
|
end
|
9
9
|
def global_config
|
10
10
|
YAML.load_file(global_config_file)
|
11
11
|
end
|
12
|
+
def temp_dir
|
13
|
+
tmp_dir = File.join(__dir__, '../tmp')
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
17
|
RSpec.configure do |config|
|
15
18
|
config.include GlobalConfig
|
16
19
|
|
17
20
|
config.before do
|
18
|
-
|
19
|
-
FileUtils.
|
21
|
+
FileUtils.rm_rf(temp_dir)
|
22
|
+
FileUtils.mkdir_p(temp_dir)
|
20
23
|
end
|
21
24
|
end
|
data/spec/support/home_env.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'thegarage/gitx/cli/base_command'
|
3
|
+
|
4
|
+
describe Thegarage::Gitx::Cli::BaseCommand do
|
5
|
+
let(:args) { [] }
|
6
|
+
let(:options) { {} }
|
7
|
+
let(:config) do
|
8
|
+
{
|
9
|
+
pretend: true
|
10
|
+
}
|
11
|
+
end
|
12
|
+
let(:cli) { described_class.new(args, options, config) }
|
13
|
+
let(:repo) { cli.send(:repo) }
|
14
|
+
|
15
|
+
describe 'without custom .gitx.yml config file' do
|
16
|
+
it 'provides default options' do
|
17
|
+
expect(cli.send(:config).config).to eq Thegarage::Gitx::Configuration::DEFAULT_CONFIG
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'with custom .gitx.yml config file' do
|
22
|
+
let(:config) do
|
23
|
+
{
|
24
|
+
'aggregate_branches' => %w( foo bar ),
|
25
|
+
'reserved_branches' => %w( baz qux ),
|
26
|
+
'taggable_branches' => %w( quux corge )
|
27
|
+
}
|
28
|
+
end
|
29
|
+
before do
|
30
|
+
expect(repo).to receive(:workdir).and_return(temp_dir)
|
31
|
+
File.open(File.join(temp_dir, '.gitx.yml'), 'w') do |f|
|
32
|
+
f.puts config.to_yaml
|
33
|
+
end
|
34
|
+
end
|
35
|
+
it 'overrides default options' do
|
36
|
+
expect(cli.send(:config).aggregate_branches).to eq(%w( foo bar ))
|
37
|
+
expect(cli.send(:config).reserved_branches).to eq(%w( baz qux ))
|
38
|
+
expect(cli.send(:config).taggable_branches).to eq(%w( quux corge ))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
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.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Sonnek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|
@@ -271,6 +271,7 @@ files:
|
|
271
271
|
- lib/thegarage/gitx/cli/start_command.rb
|
272
272
|
- lib/thegarage/gitx/cli/track_command.rb
|
273
273
|
- lib/thegarage/gitx/cli/update_command.rb
|
274
|
+
- lib/thegarage/gitx/configuration.rb
|
274
275
|
- lib/thegarage/gitx/extensions/string.rb
|
275
276
|
- lib/thegarage/gitx/extensions/thor.rb
|
276
277
|
- lib/thegarage/gitx/github.rb
|
@@ -287,6 +288,7 @@ files:
|
|
287
288
|
- spec/support/timecop.rb
|
288
289
|
- spec/support/vcr.rb
|
289
290
|
- spec/support/webmock.rb
|
291
|
+
- spec/thegarage/gitx/cli/base_command_spec.rb
|
290
292
|
- spec/thegarage/gitx/cli/buildtag_command_spec.rb
|
291
293
|
- spec/thegarage/gitx/cli/cleanup_command_spec.rb
|
292
294
|
- spec/thegarage/gitx/cli/integrate_command_spec.rb
|
@@ -335,6 +337,7 @@ test_files:
|
|
335
337
|
- spec/support/timecop.rb
|
336
338
|
- spec/support/vcr.rb
|
337
339
|
- spec/support/webmock.rb
|
340
|
+
- spec/thegarage/gitx/cli/base_command_spec.rb
|
338
341
|
- spec/thegarage/gitx/cli/buildtag_command_spec.rb
|
339
342
|
- spec/thegarage/gitx/cli/cleanup_command_spec.rb
|
340
343
|
- spec/thegarage/gitx/cli/integrate_command_spec.rb
|