From f18b3afa5c64f017b55dba837d23d8b9ba5aba1c Mon Sep 17 00:00:00 2001 From: Simon Let Date: Wed, 29 Apr 2020 22:03:09 +0200 Subject: [PATCH] normalize git remotes --- pkg/records/records.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/records/records.go b/pkg/records/records.go index 15d5ee5..b9914ad 100644 --- a/pkg/records/records.go +++ b/pkg/records/records.go @@ -186,6 +186,7 @@ func Enriched(r Record) EnrichedRecord { // log.Println("Invalid command:", rec) record.Invalid = true } + record.GitOriginRemote = NormalizeGitRemote(record.GitOriginRemote) return record // TODO: Detect and mark simple commands r.Simple } @@ -327,6 +328,14 @@ func GetCommandAndFirstWord(cmdLine string) (string, string, error) { return "ERROR", "ERROR", errors.New("this should not happen - contact developer ;)") } +// NormalizeGitRomote func +func NormalizeGitRemote(gitRemote string) string { + if strings.HasSuffix(gitRemote, ".git") { + return gitRemote[:len(gitRemote)-4] + } + return gitRemote +} + // DistParams is used to supply params to Enrichedrecords.DistanceTo() type DistParams struct { ExitCode float64