From d1ea68e25624fb0a887a741fef49b6d91078b196 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Mon, 20 Apr 2015 18:56:25 +0300 Subject: support having all groups in single repo output: git: single_repo: true would cause repos to appear as directories in group --- lib/oxidized/output/git.rb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/oxidized/output/git.rb b/lib/oxidized/output/git.rb index e9256e8..64497c9 100644 --- a/lib/oxidized/output/git.rb +++ b/lib/oxidized/output/git.rb @@ -68,17 +68,23 @@ class Git < Output def update repo, file, data return if data.empty? if @opt[:group] - repo = File.join File.dirname(repo), @opt[:group] + '.git' + if @cfg.single_repo? + file = File.join @opt[:group], file + else + repo = File.join File.dirname(repo), @opt[:group] + '.git' + end end - repo = Rugged::Repository.new repo - update_repo repo, file, data, @msg, @user, @email - rescue Rugged::OSError, Rugged::RepositoryError => open_error begin - Rugged::Repository.init_at repo, :bare - rescue => create_error - raise GitError, "first '#{open_error.message}' was raised while opening git repo, then '#{create_error.message}' was while trying to create git repo" + repo = Rugged::Repository.new repo + update_repo repo, file, data, @msg, @user, @email + rescue Rugged::OSError, Rugged::RepositoryError => open_error + begin + Rugged::Repository.init_at repo, :bare + rescue => create_error + raise GitError, "first '#{open_error.message}' was raised while opening git repo, then '#{create_error.message}' was while trying to create git repo" + end + retry end - retry end def update_repo repo, file, data, msg, user, email -- cgit v1.2.1