Skip to content

Commit

Permalink
Fix bugs in error path for repository mirror push. Correct status is …
Browse files Browse the repository at this point in the history
…now reported. Removed extra cruft in error reporting.
  • Loading branch information
kubitron committed Jan 29, 2012
1 parent a472dbe commit 0758cbb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/controllers/repository_mirrors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def settings
def push
respond_to do |format|
format.html {
@mirror.push
(@push_failed,@shellout) = @mirror.push
}
end
end
Expand Down
15 changes: 4 additions & 11 deletions app/models/repository_mirror.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ def to_s

def push
repo_path = GitHosting.repository_path(project)
shellout = %x[ echo 'cd "#{repo_path}" ; env GIT_SSH=~/.ssh/run_gitolite_admin_ssh git push --mirror "#{url}" 2>&1' | #{GitHosting.git_user_runner} "bash" ]
shellout = %x[ echo 'cd "#{repo_path}" ; env GIT_SSH=~/.ssh/run_gitolite_admin_ssh git push --mirror "#{url}" 2>&1' | #{GitHosting.git_user_runner} "bash" ].chomp
push_failed = ($?.to_i!=0) ? true : false

err_output = push_failed ? "" : ""
if push_failed
ms = " #{mirror.url} push error "
nr = (70-ms.length)/2
GitHosting.logger.debug "Failed:\n%{nrs} #{ms} %{nrs}\n#{shellout}%{nre} #{ms} %{nre}\n" % {:nrs => ">"*nr, :nre => "<"*nr}
err_output = err_output + ("%{nrs} #{ms} %{nrs}\n" % {:nrs => ">"*nr})
err_output = err_output + "#{shellout}"
err_output = err_output + ("%{nre} #{ms} %{nre}\n" % {:nre => "<"*nr})
end
err_output
GitHosting.logger.error "Mirror push error: #{url}\n#{shellout}"
end
[push_failed,shellout]
end

end

0 comments on commit 0758cbb

Please sign in to comment.