summaryrefslogtreecommitdiff
path: root/lib/oxidized
diff options
context:
space:
mode:
authorDanilo Sousa <dsgoncalves@uoldiveo.com>2016-02-16 18:56:30 -0200
committerDanilo Sousa <dsgoncalves@uoldiveo.com>2016-02-18 15:15:23 -0200
commita626c212f9e64434b828dadcb0cb3bd879beb612 (patch)
treea0abded6db4a64340f9971f8ea0e570dc431e776 /lib/oxidized
parenta5b400f83e4cec0704ecda219bf4182e3de059b1 (diff)
fix `githubrepo` hook for groups repositories remotes
when there was a repository per group we could not use the hook for pushing since we only had **one** remote configured. This PR configures each repository its own remote based in the `groups` config, as follows: ``` --- groups: first: remote_repo: git@gitlab.lab:oxidized/first.git second: remote_repo: git@gitlab.lab:oxidized/second.git ```
Diffstat (limited to 'lib/oxidized')
-rw-r--r--lib/oxidized/hook/githubrepo.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb
index d10b51e..80ae665 100644
--- a/lib/oxidized/hook/githubrepo.rb
+++ b/lib/oxidized/hook/githubrepo.rb
@@ -4,9 +4,9 @@ class GithubRepo < Oxidized::Hook
end
def run_hook(ctx)
- repo = Rugged::Repository.new(Oxidized.config.output.git.repo)
+ repo = Rugged::Repository.new(ctx.node.repo)
log "Pushing local repository(#{repo.path})..."
- remote = repo.remotes['origin'] || repo.remotes.create('origin', cfg.remote_repo)
+ remote = repo.remotes['origin'] || repo.remotes.create('origin', remote_repo(ctx.node))
log "to remote: #{remote.url}"
fetch_and_merge_remote(repo)
@@ -54,4 +54,16 @@ class GithubRepo < Oxidized::Hook
end
end
+ def remote_repo(node)
+ if node.group.nil? || single_repo?
+ cfg.remote_repo
+ else
+ Oxidized.config.groups[node.group].remote_repo
+ end
+ end
+
+ def single_repo?
+ Oxidized.config.git.single_repo?
+ end
+
end