diff options
| author | Jeff Carr <[email protected]> | 2025-09-11 17:41:59 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-11 17:41:59 -0500 |
| commit | 95d1f6fc7c6af1565749979d1ac7a85fbb311de6 (patch) | |
| tree | 2fd90a03cdaf82c9052792e76139f248dc221e0b /readControlFile.go | |
| parent | d011972b708cb5cab8e95c1c5f9459c3a451c277 (diff) | |
more fixes. almost works againv0.22.130
Diffstat (limited to 'readControlFile.go')
| -rw-r--r-- | readControlFile.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/readControlFile.go b/readControlFile.go index 21e141a..b53a79d 100644 --- a/readControlFile.go +++ b/readControlFile.go @@ -4,11 +4,26 @@ import ( "bufio" "os" "strings" + "unicode" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) +func trimNonNumericPrefix(s string) string { + // Find the index of the first character that IS a digit. + firstDigitIndex := strings.IndexFunc(s, unicode.IsDigit) + + // If no digit is found, IndexFunc returns -1. + // In this case, the result should be an empty string. + if firstDigitIndex == -1 { + return "" + } + + // Return the substring starting from the first digit. + return s[firstDigitIndex:] +} + // readGitConfig reads and parses the control file func readControlFile(repo *gitpb.Repo) error { pairs := make(map[string]string) @@ -31,6 +46,8 @@ func readControlFile(repo *gitpb.Repo) error { } defer file.Close() + pairs["Version"] = trimNonNumericPrefix(repo.GetCurrentVersion()) + scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text() |
