require "git_fusion_strings/version" module GitFusionStrings # These constants are used as the default configuration for the # encode and decode methods. # GitFusion-specific character encodings to use in Perforce # This enables select characters to be used as repo names GF_CHARACTER_MAPPING = { '/' => '_0xS_', ':' => '_0xC_', } GF_DEFAULT_ILLEGAL_CHARS = GF_CHARACTER_MAPPING.keys # Characters that are permitted in usernames in Perforce # but render URI impossible to decode URI_RESERVED_CHARACTERS = ['/', '\\', ':', '?', '=', '%', ':', '#'] # Encodes a string for Git Fusion use def self.encode(str, illegal_characters: GF_DEFAULT_ILLEGAL_CHARS) str.chars.map do |ch| if illegal_characters.include?(ch) GF_CHARACTER_MAPPING[ch] else ch end end.join('') end # Decodes a string coming from GitFusion encoding def self.decode(str, illegal_characters: GF_DEFAULT_ILLEGAL_CHARS) escape_map = Hash[illegal_characters.map{ |c| [c, GF_CHARACTER_MAPPING[c]] }] escape_map.each do |ch, escaped| str = str.gsub(escaped, ch) end str end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 16014 | Doug Scheirer | Merge down from main | ||
//guest/perforce_software/helix-web-services/main/source/git_fusion_strings/lib/git_fusion_strings.rb | |||||
#1 | 15969 | tjuricek |
Add support for repo creation/update and deletion, same for SSH keys. Add util module for supporting methods, modify temp client to dissapear. (Modified submit of review 15549 by @ptomiak) |