Module: Gitolite::Utils
Instance Method Summary collapse
-
#gitolite_friendly(permission) ⇒ Object
Converts permission to gitolite friendly permission.
-
#is_subset?(array1, array2) ⇒ Boolean
Checks to see if array2 is subset of array1.
- #raise_gitolite_error(msg, content) ⇒ Object
- #validate_gitolite_conf_file(content) ⇒ Object
Instance Method Details
#gitolite_friendly(permission) ⇒ Object
Converts permission to gitolite friendly permission
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/gitolite/utils.rb', line 61 def gitolite_friendly() if .empty? return nil elsif .match(/^RWDP?/) return "RW+" elsif .match(/^RW/) return "RW+" elsif .match(/^R/) return 'R' else return nil end end |
#is_subset?(array1, array2) ⇒ Boolean
Checks to see if array2 is subset of array1
53 54 55 56 |
# File 'lib/gitolite/utils.rb', line 53 def is_subset?(array1, array2) result = array1 & array2 (array2.length == result.length) end |
#raise_gitolite_error(msg, content) ⇒ Object
44 45 46 47 48 |
# File 'lib/gitolite/utils.rb', line 44 def raise_gitolite_error(msg, content) Rails.logger.debug "Gitolite validation failed with: #{msg}" Rails.logger.debug content raise ::Error::GitoliteValidation.new(msg) end |
#validate_gitolite_conf_file(content) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gitolite/utils.rb', line 20 def validate_gitolite_conf_file(content) # first line that is not empty first_line = true content.split(/\n|\r/).each_with_index do |line, i| next if line.strip().empty? next if line.strip().match(/^include/) if first_line raise_gitolite_error("Gitolite conf repo header is not valid", content) unless line.match(/repo *[a-zA-Z\-0-9]+/) first_line = !first_line next end # line must start with R/W/RW+ raise_gitolite_error("Gitolite conf repo line must start with R/RW/W(+)", content) unless line.match(/^ *(R|W|RW)\+? *=/m) # must be matched only once raise_gitolite_error("Gitolite conf repo line must containt ONLY one entry of R/RW/W(+)=", content) if line.scan(/(R|W|RW)\+? *=/).size > 1 end return content end |