summaryrefslogtreecommitdiff
path: root/app/validators
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2019-03-14 10:05:17 +0000
committerDouwe Maan <douwe@gitlab.com>2019-03-14 10:05:17 +0000
commit150f7c1e9c8d4a9d8134664d00a6385ac21a1939 (patch)
tree5a5fc090c6ebcd856a384fd90b38d9b708c916b8 /app/validators
parentd0053d51719c4f9719bbe2d043c7aff23d9eabd1 (diff)
downloadgitlab-ce-150f7c1e9c8d4a9d8134664d00a6385ac21a1939.tar.gz
Fix Bitbucket import
In https://gitlab.com/gitlab-org/gitlab-ce/commit/ebf16ada856efb85424a98848c141f21e609886a we introduced a SHA validator, to ensure that the data provided in merge request diffs, was legit. Nevertheless, the validator assumed that the SHA should be 40 chars long. When we import a project from BitBucket, the retrieved SHA is shorter (12 chars long). Therefore, this validator prevented to create a valid MergeRequestDiff for ever MergeRequest (triggering an exception).
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/sha_validator.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/validators/sha_validator.rb b/app/validators/sha_validator.rb
index 085fca4d65d..77e7cfa4f6b 100644
--- a/app/validators/sha_validator.rb
+++ b/app/validators/sha_validator.rb
@@ -2,7 +2,7 @@
class ShaValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
- return if value.blank? || value.match(/\A\h{40}\z/)
+ return if value.blank? || Commit.valid_hash?(value)
record.errors.add(attribute, 'is not a valid SHA')
end