From 5cabec8f8f4fcea4f8c55c348e67ab5f3d643871 Mon Sep 17 00:00:00 2001 From: "Duff, Robert W" Date: Thu, 16 Jul 2015 14:01:03 -0400 Subject: [PATCH] Include more information in hook error messages When pushing commits to the remote, if a pre-receive hook gets triggered that prevents the push, it may not be clear which commit is causing the issue. Having the values of what caused the comparison to fail in the error message will help debugging, whether it be the user or the administrator. --- lib/gitlab/git_access.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index dcadb15deb..0bae7eeaf6 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -197,29 +197,29 @@ module Gitlab commits.each do |commit| if git_hook.commit_message_regex.present? unless commit.safe_message =~ Regexp.new(git_hook.commit_message_regex) - return build_status_object(false, "Commit message does not follow the pattern") + return build_status_object(false, "Commit message does not follow the pattern '#{git_hook.commit_message_regex}'") end end if git_hook.author_email_regex.present? unless commit.committer_email =~ Regexp.new(git_hook.author_email_regex) - return build_status_object(false, "Commiter's email does not follow the pattern") + return build_status_object(false, "Committer's email '#{commit.committer_email}' does not follow the pattern '#{git_hook.author_email_regex}'") end unless commit.author_email =~ Regexp.new(git_hook.author_email_regex) - return build_status_object(false, "Author's email does not follow the pattern") + return build_status_object(false, "Author's email '#{commit.author_email}' does not follow the pattern '#{git_hook.author_email_regex}'") end end # Check whether author is a GitLab member if git_hook.member_check unless User.existing_member?(commit.author_email) - return build_status_object(false, "Author is not a member of team") + return build_status_object(false, "Author '#{commit.author_email}' is not a member of team") end if commit.author_email != commit.committer_email unless User.existing_member?(commit.committer_email) - return build_status_object(false, "Commiter is not a member of team") + return build_status_object(false, "Committer '#{commit.committer_email}' is not a member of team") end end end @@ -227,7 +227,7 @@ module Gitlab if git_hook.file_name_regex.present? commit.diffs.each do |diff| if (diff.renamed_file || diff.new_file) && diff.new_path =~ Regexp.new(git_hook.file_name_regex) - return build_status_object(false, "File name #{diff.new_path.inspect} does not follow the pattern") + return build_status_object(false, "File name #{diff.new_path.inspect} does not follow the pattern '#{git_hook.file_name_regex}'") end end end