summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanilo Sousa <code@danilosousa.net>2016-02-19 22:17:37 -0200
committerDanilo Sousa <code@danilosousa.net>2016-02-19 22:17:37 -0200
commitc098f57f5dfc4588673ac62083611736c8a75136 (patch)
tree53daffc4fffea78fb136dd2344b78c067316fa37
parent3a57984ed70d7d217147b4d7341dff86aeceed70 (diff)
refactor `#remote_repo` to not rely on `#single_repo?` config
even in the case we have groups, we can assume is only one repository if the `remote_repo` config is a String.
-rw-r--r--lib/oxidized/hook/githubrepo.rb7
-rw-r--r--spec/githubrepo_spec.rb4
2 files changed, 2 insertions, 9 deletions
diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb
index 0c75c68..7fc6677 100644
--- a/lib/oxidized/hook/githubrepo.rb
+++ b/lib/oxidized/hook/githubrepo.rb
@@ -55,15 +55,10 @@ class GithubRepo < Oxidized::Hook
end
def remote_repo(node)
- if node.group.nil? || single_repo?
+ if node.group.nil? || cfg.remote_repo.is_a?(String)
cfg.remote_repo
else
cfg.remote_repo[node.group]
end
end
-
- def single_repo?
- Oxidized.config.output.git.single_repo?
- end
-
end
diff --git a/spec/githubrepo_spec.rb b/spec/githubrepo_spec.rb
index 8d85761..b6a8d9e 100644
--- a/spec/githubrepo_spec.rb
+++ b/spec/githubrepo_spec.rb
@@ -126,7 +126,6 @@ describe GithubRepo do
before do
Rugged::Credentials::SshKeyFromAgent.expects(:new).with(username: 'git').returns(credentials)
Rugged::Repository.expects(:new).with(repository).returns(repo)
- Oxidized.config.output.git.single_repo = single_repo
repo.expects(:remotes).twice.returns(remotes)
remotes.expects(:[]).with('origin').returns(nil)
@@ -138,7 +137,6 @@ describe GithubRepo do
describe 'and there are several repositories' do
let(:create_remote) { 'ggrroouupp#remote_repo' }
let(:repository) { './ggrroouupp.git' }
- let(:single_repo) { nil }
before do
Oxidized.config.hooks.github_repo_hook.remote_repo.ggrroouupp = 'ggrroouupp#remote_repo'
@@ -153,10 +151,10 @@ describe GithubRepo do
describe 'and has a single repository' do
let(:create_remote) { 'github_repo_hook#remote_repo' }
let(:repository) { 'foo.git' }
- let(:single_repo) { true }
before do
Oxidized.config.hooks.github_repo_hook.remote_repo = 'github_repo_hook#remote_repo'
+ Oxidized.config.output.git.single_repo = true
end
it 'will push to the correct repository' do