<commit_before>namespace Buckaroo

open Buckaroo.Git

type Version = 
| SemVerVersion of SemVer
| Branch of Branch
| Revision of Revision
| Tag of Tag
| Latest // When we download from HTTP, version is always latest

module Version = 

  open FParsec

  let harmonious (v : Version) (u : Version) = 
    match (v, u) with 
    | (Version.SemVerVersion x, Version.SemVerVersion y) -> x = y
    | (Version.Branch x, Version.Branch y) -> x = y
    | (Version.Revision x, Version.Revision y) -> x = y
    | (Version.Tag x, Version.Tag y) -> x = y
    | _ -> true

  let show (v : Version) : string = 
    match v with
    | Latest -> "latest" 
    | SemVerVersion semVer -> SemVer.show semVer
    | Branch branch -> "branch=" + branch
    | Revision revision -> "revision=" + revision
    | Tag tag -> "tag=" + tag

  let identifierParser = CharParsers.regex @"[a-zA-Z\d](?:[a-zA-Z\d]|-(?=[a-zA-Z\d])){2,64}"

  let branchNameParser = CharParsers.regex @"[a-zA-Z0-9-\.]{2,64}"

  let tagVersionParser = parse {
    do! CharParsers.skipString "tag="
    let! tag = CharParsers.regex @"[a-zA-Z\d\\\.\-_]{2,64}"
    return Tag tag
  }

  let branchVersionParser = parse {
    do! CharParsers.skipString "branch="
    let! branch = branchNameParser
    return Branch branch
  }
<commit_msg>fix: support slashes in version-tags<commit_after>namespace Buckaroo

open Buckaroo.Git

type Version = 
| SemVerVersion of SemVer
| Branch of Branch
| Revision of Revision
| Tag of Tag
| Latest // When we download from HTTP, version is always latest

module Version = 

  open FParsec

  let harmonious (v : Version) (u : Version) = 
    match (v, u) with 
    | (Version.SemVerVersion x, Version.SemVerVersion y) -> x = y
    | (Version.Branch x, Version.Branch y) -> x = y
    | (Version.Revision x, Version.Revision y) -> x = y
    | (Version.Tag x, Version.Tag y) -> x = y
    | _ -> true

  let show (v : Version) : string = 
    match v with
    | Latest -> "latest" 
    | SemVerVersion semVer -> SemVer.show semVer
    | Branch branch -> "branch=" + branch
    | Revision revision -> "revision=" + revision
    | Tag tag -> "tag=" + tag

  let identifierParser = CharParsers.regex @"[a-zA-Z\d](?:[a-zA-Z\d]|-(?=[a-zA-Z\d])){2,64}"

  let branchNameParser = CharParsers.regex @"[a-zA-Z0-9-\.]{2,64}"

  let tagVersionParser = parse {
    do! CharParsers.skipString "tag="
    let! tag = CharParsers.regex @"[a-zA-Z\d\\\.\-_/]{2,64}"
    return Tag tag
  }

  let branchVersionParser = parse {
    do! CharParsers.skipString "branch="
    let! branch = branchNameParser
    return Branch branch
  }

{'fraction_non_alphanumeric': 0.14412673879443585, 'fraction_numerical': 0.008500772797527048, 'mean_word_length': 2.8129602356406482, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4696304', 'n_tokens_mistral': 936, 'n_tokens_neox': 885, 'n_words': 256}