summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Hassan <ahmad.hassan612@gmail.com>2018-07-17 15:12:29 +0200
committerAhmad Hassan <ahmad.hassan612@gmail.com>2018-07-18 18:34:46 +0200
commit474c580525c6d0dc3437f9e886f928df94e1caa8 (patch)
treef9eab5b3d179f48e34b3f3906ae05d999bb0aba0
parent59b82fbcd48108682d58426975b581800672ca28 (diff)
downloadgitlab-ce-use-rugged-for-reference-validator.tar.gz
Use rugged to validate ref nameuse-rugged-for-reference-validator
-rw-r--r--lib/gitlab/git_ref_validator.rb5
-rwxr-xr-xscripts/lint-rugged4
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/gitlab/git_ref_validator.rb b/lib/gitlab/git_ref_validator.rb
index 2e3e4fc3f1f..36b06f4f1a8 100644
--- a/lib/gitlab/git_ref_validator.rb
+++ b/lib/gitlab/git_ref_validator.rb
@@ -9,9 +9,10 @@ module Gitlab
def validate(ref_name)
return false if ref_name.start_with?('refs/heads/')
return false if ref_name.start_with?('refs/remotes/')
+ return false if ref_name.start_with?('-')
+ return true if ref_name == 'HEAD'
- Gitlab::Utils.system_silent(
- %W(#{Gitlab.config.git.bin_path} check-ref-format --branch #{ref_name}))
+ Rugged::Reference.valid_name? "refs/heads/#{ref_name}"
end
end
end
diff --git a/scripts/lint-rugged b/scripts/lint-rugged
index cabd083e9f9..5df3caf2a7a 100755
--- a/scripts/lint-rugged
+++ b/scripts/lint-rugged
@@ -14,7 +14,9 @@ ALLOWED = [
'lib/tasks/gitlab/cleanup.rake',
# The only place where Rugged code is still allowed in production
- 'lib/gitlab/git/'
+ 'lib/gitlab/git/',
+
+ 'lib/gitlab/git_ref_validator.rb'
].freeze
rugged_lines = IO.popen(%w[git grep -i -n rugged -- app config lib], &:read).lines