ee/lib/ee/gitlab/checks/change_access.rb
# If commit does not pass push rule validation the whole push should be rejected.
# This method should return nil if no error found or a string if error.
# In case of errors - all other checks will be canceled and push will be rejected.
If commit does not pass push rule validation the whole push should be rejected.
This method should return nil if no error found or a string if error.
In case of errors - all other checks will be canceled and push will be rejected.
If commit does not pass push rule validation the whole push should be rejected . This method should return nil if no error found or a string if error . In case of errors - all other checks will be canceled and push will be rejected .
def check_commit(commit)
          unless push_rule.commit_message_allowed?(commit.safe_message)
            return "Commit message does not follow the pattern '#{push_rule.commit_message_regex}'"
          end
          unless push_rule.author_email_allowed?(commit.committer_email)
            return "Committer's email '#{commit.committer_email}' does not follow the pattern '#{push_rule.author_email_regex}'"
          end
          unless push_rule.author_email_allowed?(commit.author_email)
            return "Author's email '#{commit.author_email}' does not follow the pattern '#{push_rule.author_email_regex}'"
          end
          committer_error_message = committer_check(commit)
          return committer_error_message if committer_error_message
          if !updated_from_web? && !push_rule.commit_signature_allowed?(commit)
            return "Commit must be signed with a GPG key"
          end
          if push_rule.member_check
            unless ::User.existing_member?(commit.author_email.downcase)
              return "Author '#{commit.author_email}' is not a member of team"
            end
            if commit.author_email.casecmp(commit.committer_email) == -1
              unless ::User.existing_member?(commit.committer_email.downcase)
                return "Committer '#{commit.committer_email}' is not a member of team"
              end
            end
          end
          nil
        end
def check_commit ( commit ) unless push_rule . commit_message_allowed? ( commit . safe_message ) return "Commit message does not follow the pattern '#{push_rule.commit_message_regex}'" end unless push_rule . author_email_allowed? ( commit . committer_email ) return "Committer's email '#{commit.committer_email}' does not follow the pattern '#{push_rule.author_email_regex}'" end unless push_rule . author_email_allowed? ( commit . author_email ) return "Author's email '#{commit.author_email}' does not follow the pattern '#{push_rule.author_email_regex}'" end committer_error_message = committer_check ( commit ) return committer_error_message if committer_error_message if ! updated_from_web? && ! push_rule . commit_signature_allowed? ( commit ) return "Commit must be signed with a GPG key" end if push_rule . member_check unless :: User . existing_member? ( commit . author_email . downcase ) return "Author '#{commit.author_email}' is not a member of team" end if commit . author_email . casecmp ( commit . committer_email ) == - 1 unless :: User . existing_member? ( commit . committer_email . downcase ) return "Committer '#{commit.committer_email}' is not a member of team" end end end nil end
If commit does not pass push rule validation the whole push should be rejected.
If commit does not pass push rule validation the whole push should be rejected .
# Check whether author is a GitLab member
commit
<not_specific>