singularity_dsl 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODFhM2I0MWY1MzZjYTllMTBhOTk5NjU5OWRkMTRlOWMyNmI3ZDM4MA==
4
+ YzY3Yjc1ZjI2NmNkYWVhYzNkZjNlNDEwZTZiZDA2ZjI2NDAwNzMxYg==
5
5
  data.tar.gz: !binary |-
6
- ZjJlZDBlZTNhYTkwOWJlMDEyYjI0ZjYwODg2ZDMyN2Q3ZTJiNzBhZQ==
6
+ MzUxMGE2OTI5OTFkNzBkYTQ2Njk1YjkyN2JjYjA2MmRjOTIxMGUxNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjEwNzEzNDdiMGExZTk5OWU2NTAyYjgyYmFlOTBhZmU1YzVhMzAwZTNiOGYx
10
- NDMzNzAzM2VlNzZmMTlmYTFjODAxNTI0MjkzZjc1Zjg2YmUwNzA4YzQzYTk2
11
- OTdiMWY1ZTVmMDNmNjgxOWJkNjMzZTA0ZDg1ODMwYTYzNzRjY2I=
9
+ OTAyZWE5NjllYTNhYjg3YTI2ZmE2ZDUwYjM0MDMyMDIyODM5ZGQ1MjgyMWNi
10
+ ODhmMjYzNTNiOTRlMmFmMDdmZmFkZDE0ZmYyNjQxNGZhMzM5MTgzZTYzZjBk
11
+ MjEwMWM4MGE4ZmE5ZGU5ODc2YmRlYTcwN2QxZmFhN2RjNWEyMTA=
12
12
  data.tar.gz: !binary |-
13
- MzQyNGNmY2FjMjcwNDQyMTZhZjljZTU0ZWNkYzhhZWY5ZDhjNTgwM2QwZGRj
14
- M2VjOWE2ZWNjZWRhMmY3ZjQyZGY5ODNlOWQxNzRlNmFmZjU1ZTRjOTY4ZWIz
15
- YzNlY2I0NDBkNjQyNTU5NWRkZjE0YzAwODRkZmNhNjMwZTc1MTA=
13
+ Y2IzNjZmYmY4ZDZmN2JiYzI0ZjUxNDFhZDVmNDI0MTRhYmNlNDAwNGU3M2Vm
14
+ NDdmOThiZmYxMmFlNTk1MjEyYjk1N2Y1MGVlZDIwNzhlNzJiYTQ2YTA3MzFk
15
+ Yzc0MzNmNGFlMGI1ZDg2MzE1YjJiODE1OWJmMzg0ZTg2NzM1MTQ=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- singularity_dsl (2.0.0)
4
+ singularity_dsl (2.1.0)
5
5
  coveralls (~> 0.7.9)
6
6
  json (~> 1.0)
7
7
  mixlib-shellout (~> 2.0)
@@ -44,7 +44,7 @@ GEM
44
44
  rspec-core (~> 3.2.0)
45
45
  rspec-expectations (~> 3.2.0)
46
46
  rspec-mocks (~> 3.2.0)
47
- rspec-core (3.2.1)
47
+ rspec-core (3.2.2)
48
48
  rspec-support (~> 3.2.0)
49
49
  rspec-expectations (3.2.0)
50
50
  diff-lcs (>= 1.2.0, < 2.0)
@@ -18,10 +18,19 @@ module SingularityDsl
18
18
  @git.verbosity options[:verbose]
19
19
  end
20
20
 
21
- def perform_merge(git_fork, branch, base_branch, base_fork = nil)
22
- git.merge_refs git_fork, branch, base_branch, base_fork
23
- @diff_list += get_diff_list(base_branch, base_fork)
24
- remove_remotes git_fork, base_fork
21
+ def bootstrap_cwd(repo_url)
22
+ return self unless options[:bootstrap_cwd]
23
+ git.clean_reset if git.cwd_is_git_repo
24
+ git.clone_to_cwd(repo_url) unless git.cwd_is_git_repo
25
+ git.install_submodules
26
+ self
27
+ end
28
+
29
+ def perform_merge(fork_url, branch, base_branch, repo_url = nil)
30
+ git.merge_refs fork_url, branch, base_branch, repo_url
31
+ git.install_submodules
32
+ @diff_list += get_diff_list(base_branch, repo_url)
33
+ remove_remotes fork_url, repo_url
25
34
  self
26
35
  end
27
36
 
@@ -69,10 +69,16 @@ EOD
69
69
  type: :string,
70
70
  desc: 'Run a batch instead, after testmerge.',
71
71
  default: ''
72
+ option :bootstrap_cwd,
73
+ aliases: '-b',
74
+ type: :boolean,
75
+ desc: 'Bootstrap local directory by cloning & setting up the repo.'
72
76
  def testmerge(git_fork, branch, base_branch, base_fork = nil)
73
- Command::TestMerge.new(options)
74
- .perform_merge(git_fork, branch, base_branch, base_fork)
75
- .execute
77
+ Command::TestMerge.new(options).tap do |cmd|
78
+ cmd.bootstrap_cwd(base_fork)
79
+ .perform_merge(git_fork, branch, base_branch, base_fork)
80
+ .execute
81
+ end
76
82
  end
77
83
 
78
84
  private
@@ -15,6 +15,14 @@ module SingularityDsl
15
15
  @verbose = false
16
16
  end
17
17
 
18
+ def cwd_is_git_repo
19
+ ::File.exist? "#{::Dir.pwd}/.git"
20
+ end
21
+
22
+ def clone_to_cwd(repo_url)
23
+ exec("git clone #{repo_url} .")
24
+ end
25
+
18
26
  def clean_reset
19
27
  fail 'failed to clean' unless (reset | clean) == 0
20
28
  end
@@ -57,7 +65,6 @@ module SingularityDsl
57
65
  checkout_remote base_branch, base_fork
58
66
  add_remote git_fork
59
67
  merge_remote branch, git_fork
60
- install_submodules
61
68
  end
62
69
 
63
70
  def verbosity(level)
@@ -2,5 +2,5 @@
2
2
 
3
3
  # version const for gem
4
4
  module SingularityDsl
5
- VERSION = '2.0.0'
5
+ VERSION = '2.1.0'
6
6
  end
@@ -3,9 +3,13 @@
3
3
  require 'singularity_dsl/cli/command/test_merge'
4
4
 
5
5
  describe SingularityDsl::Cli::Command::TestMerge do
6
+ def create_command(params)
7
+ SingularityDsl::Cli::Command::TestMerge.new params
8
+ end
9
+
6
10
  describe '#batch' do
7
11
  context ':run_task given' do
8
- let(:cmd) { SingularityDsl::Cli::Command::TestMerge.new(run_task: 'foo') }
12
+ let(:cmd) { create_command(run_task: 'foo') }
9
13
 
10
14
  it 'returns batch' do
11
15
  expect(cmd.batch).to eql 'foo'
@@ -13,11 +17,64 @@ describe SingularityDsl::Cli::Command::TestMerge do
13
17
  end
14
18
 
15
19
  context ':run_task not given' do
16
- let(:cmd) { SingularityDsl::Cli::Command::TestMerge.new(run_task: '') }
20
+ let(:cmd) { create_command(run_task: '') }
17
21
 
18
22
  it 'returns false when :run_task is an empty string' do
19
23
  expect(cmd.batch).to eql false
20
24
  end
21
25
  end
22
26
  end
27
+
28
+ describe '#bootstrap_cwd' do
29
+ let(:repo) { 'fakedood/fakerepo' }
30
+
31
+ context ':bootstrap_cwd is false' do
32
+ let(:cmd) { create_command(bootstrap_cwd: false) }
33
+
34
+ it 'does nothing' do
35
+ allow(cmd.git).to receive :verbosity
36
+ expect(cmd.bootstrap_cwd repo).to eql cmd
37
+ end
38
+ end
39
+
40
+ context ':bootstrap_cwd is true' do
41
+ def expect_git_cmd(cmd)
42
+ cmd_double = double.as_null_object
43
+ allow(cmd_double).to receive(:exitstatus).and_return 0
44
+ expect(::Mixlib::ShellOut)
45
+ .to receive(:new).with(cmd)
46
+ .once
47
+ .and_return(cmd_double)
48
+ end
49
+
50
+ let(:cmd) { create_command(bootstrap_cwd: true) }
51
+
52
+ context 'and the cwd is an empty directory' do
53
+ before :each do
54
+ allow(::File).to receive(:exist?).and_return(false)
55
+ end
56
+
57
+ it 'attempts clone into local directory' do
58
+ allow(cmd.git).to receive :verbosity
59
+ expect_git_cmd("git clone #{repo} .")
60
+ expect_git_cmd('git submodule update --init --recursive')
61
+ expect(cmd.bootstrap_cwd repo).to eql cmd
62
+ end
63
+ end
64
+
65
+ context 'and the cwd is a git directory' do
66
+ before :each do
67
+ allow(::File).to receive(:exist?).and_return(true)
68
+ end
69
+
70
+ it 'attempts to clean & reset local' do
71
+ allow(cmd.git).to receive :verbosity
72
+ expect_git_cmd('git clean -fdx')
73
+ expect_git_cmd('git add . && git reset --hard')
74
+ expect_git_cmd('git submodule update --init --recursive')
75
+ expect(cmd.bootstrap_cwd repo).to eql cmd
76
+ end
77
+ end
78
+ end
79
+ end
23
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singularity_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chr0n1x
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json