Skip to content

Commit 0758cbb

Browse files
committed
Fix bugs in error path for repository mirror push. Correct status is now reported. Removed extra cruft in error reporting.
1 parent a472dbe commit 0758cbb

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

Diff for: app/controllers/repository_mirrors_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def settings
9696
def push
9797
respond_to do |format|
9898
format.html {
99-
@mirror.push
99+
(@push_failed,@shellout) = @mirror.push
100100
}
101101
end
102102
end

Diff for: app/models/repository_mirror.rb

+4-11
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,12 @@ def to_s
1818

1919
def push
2020
repo_path = GitHosting.repository_path(project)
21-
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" ]
21+
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
2222
push_failed = ($?.to_i!=0) ? true : false
23-
24-
err_output = push_failed ? "" : ""
2523
if push_failed
26-
ms = " #{mirror.url} push error "
27-
nr = (70-ms.length)/2
28-
GitHosting.logger.debug "Failed:\n%{nrs} #{ms} %{nrs}\n#{shellout}%{nre} #{ms} %{nre}\n" % {:nrs => ">"*nr, :nre => "<"*nr}
29-
err_output = err_output + ("%{nrs} #{ms} %{nrs}\n" % {:nrs => ">"*nr})
30-
err_output = err_output + "#{shellout}"
31-
err_output = err_output + ("%{nre} #{ms} %{nre}\n" % {:nre => "<"*nr})
32-
end
33-
err_output
24+
GitHosting.logger.error "Mirror push error: #{url}\n#{shellout}"
25+
end
26+
[push_failed,shellout]
3427
end
3528

3629
end

0 commit comments

Comments
 (0)