Skip to content

Commit

Permalink
Tidy info output (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
inverse authored May 23, 2023
1 parent 3ff92ce commit 288bd47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cmd/git-pair/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"strings"

"github.com/inverse/git-pair/internal/git"
)
Expand All @@ -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))
}
}
4 changes: 3 additions & 1 deletion internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 288bd47

Please sign in to comment.