<commit_before>﻿namespace YoutrackGitlab

[<AutoOpen>]
module WebHooks =

    #if INTERACTIVE
    System.IO.Directory.SetCurrentDirectory(__SOURCE_DIRECTORY__)
    #endif

    open System.Text.RegularExpressions

    open FSharp.Data


    type CommentCommitEvent = JsonProvider<"CommentCommit.json", EmbeddedResource="YoutrackGitlab, CommentCommit.json">

    type CommitCommentCommand = { TicketId: string
                                  Comment: string
                                  CommitUrl: string }

    let financeRegex () =
        let regex = new Regex("""(BF-(\d+))""")
        regex

    let extractTicketNr message =
        let regex = financeRegex()
        let matching = regex.Match(message)
        match matching.Success with
        | true  -> matching.Groups.[0].Value
        | false -> ""

    let eventToCommand (event:CommentCommitEvent.Root) =
        let ticketNr = extractTicketNr event.Commit.Message
        { TicketId = ticketNr
          Comment = event.Commit.Message
          CommitUrl = event.Commit.Url }
<commit_msg>Updated regex to get generic issue id<commit_after>﻿namespace YoutrackGitlab

[<AutoOpen>]
module WebHooks =
    open System.Text.RegularExpressions
    open FSharp.Data

    type CommentCommitEvent = JsonProvider<"CommentCommit.json", EmbeddedResource="YoutrackGitlab, CommentCommit.json">
    type CommitCommentCommand = { TicketId: string
                                  Comment: string
                                  CommitUrl: string }

    let financeRegex () =
        let regex = new Regex("""(^|\s)([A-Z]+-(\d+))""")
        regex

    let extractTicketNr message =
        let regex = financeRegex()
        let matching = regex.Match(message)
        match matching.Success with
        | true  -> matching.Groups.[2].Value
        | false -> ""

    let eventToCommand (event:CommentCommitEvent.Root) =
        let ticketNr = extractTicketNr event.Commit.Message
        { TicketId = ticketNr
          Comment = event.Commit.Message
          CommitUrl = event.Commit.Url }

{'fraction_non_alphanumeric': 0.0935672514619883, 'fraction_numerical': 0.0009746588693957114, 'mean_word_length': 2.2953451043338684, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7141385', 'n_tokens_mistral': 576, 'n_tokens_neox': 564, 'n_words': 124}