summaryrefslogtreecommitdiff
path: root/lib/gitlab/git_ref_validator.rb
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2014-07-27 16:40:00 +0200
committerRobert Schilling <rschilling@student.tugraz.at>2014-09-03 13:08:35 +0200
commit551145bc98e257280b615e305d531a44d7aa4131 (patch)
tree20a853ca41d610247f955a9c8824ba50b18d3220 /lib/gitlab/git_ref_validator.rb
parent7a0e1c7238033b33b7296701bfded56d4ad7f250 (diff)
downloadgitlab-ce-551145bc98e257280b615e305d531a44d7aa4131.tar.gz
Validate branch-names and references in WebUI, API
Add specs for GitRefValidator
Diffstat (limited to 'lib/gitlab/git_ref_validator.rb')
-rw-r--r--lib/gitlab/git_ref_validator.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/gitlab/git_ref_validator.rb b/lib/gitlab/git_ref_validator.rb
new file mode 100644
index 00000000000..13cb08948bb
--- /dev/null
+++ b/lib/gitlab/git_ref_validator.rb
@@ -0,0 +1,11 @@
+module Gitlab
+ module GitRefValidator
+ extend self
+ # Validates a given name against the git reference specification
+ #
+ # Returns true for a valid reference name, false otherwise
+ def validate(ref_name)
+ system *%W(git check-ref-format refs/#{ref_name})
+ end
+ end
+end