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
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/gitolite/utils.rb', line 44 def gitolite_friendly() if .empty? return nil elsif .match(/^RWDP?/) return "RW+" elsif .match(/^RW/) return "RW" elsif .match(/^R/) return 'R' else raise ::Error::NotSupported, "Not supported permission '#{}'!" end end |
#is_subset?(array1, array2) ⇒ Boolean
Checks to see if array2 is subset of array1
36 37 38 39 |
# File 'lib/gitolite/utils.rb', line 36 def is_subset?(array1, array2) result = array1 & array2 (array2.length == result.length) end |
#raise_gitolite_error(msg, content) ⇒ Object
27 28 29 30 31 |
# File 'lib/gitolite/utils.rb', line 27 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
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitolite/utils.rb', line 3 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 |