From 288bd4724faf398558eed95dd7a3e0b12fca3480 Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Tue, 23 May 2023 22:17:04 +0200 Subject: [PATCH] Tidy info output (#7) --- cmd/git-pair/info.go | 5 +++-- internal/git/git.go | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/git-pair/info.go b/cmd/git-pair/info.go index d0781cc..5a00771 100644 --- a/cmd/git-pair/info.go +++ b/cmd/git-pair/info.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "strings" "github.com/inverse/git-pair/internal/git" ) @@ -22,11 +23,11 @@ func Info() { contributors, err := git.ReadTemplateFile() if err != nil { - fmt.Println(err) + fmt.Printf("Failed to read template file: %s \n", err) return } for _, contributor := range contributors { - fmt.Printf("- %s\n", contributor) + fmt.Printf("- %s\n", strings.Replace(contributor, git.CoAuthoredBy, "", 1)) } } diff --git a/internal/git/git.go b/internal/git/git.go index f0ba3e5..bbbe452 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -13,6 +13,8 @@ import ( const templateFileName string = ".git/template" +const CoAuthoredBy string = "Co-authored-by: " + func templateFilePath() string { out, err := exec.Command("git", "rev-parse", "--show-toplevel").Output() @@ -47,7 +49,7 @@ func createTemplateFile(contributors []string, templateFilePath string) error { defer templateFile.Close() for _, contributor := range contributors { - _, err := templateFile.WriteString(fmt.Sprintf("Co-authored-by: %s \n", contributor)) + _, err := templateFile.WriteString(fmt.Sprintf("%s%s \n", CoAuthoredBy, contributor)) if err != nil { return err }