Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Extract say to its own file #312

Merged
merged 3 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions coauthors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bufio"
"fmt"
"github.com/remotemobprogramming/mob/v3/say"
hollesse marked this conversation as resolved.
Show resolved Hide resolved
"os"
"path"
"regexp"
Expand All @@ -24,20 +25,20 @@ func collectCoauthorsFromWipCommits(file *os.File) []Author {
// For details and background, see https://github.com/remotemobprogramming/mob/issues/81

coauthors := parseCoauthors(file)
debugInfo("Parsed coauthors")
debugInfo(strings.Join(coauthors, ","))
say.Debug("Parsed coauthors")
say.Debug(strings.Join(coauthors, ","))

coauthors = removeElementsContaining(coauthors, gitUserEmail())
debugInfo("Parsed coauthors without committer")
debugInfo(strings.Join(coauthors, ","))
say.Debug("Parsed coauthors without committer")
say.Debug(strings.Join(coauthors, ","))

coauthors = removeDuplicateValues(coauthors)
debugInfo("Unique coauthors without committer")
debugInfo(strings.Join(coauthors, ","))
say.Debug("Unique coauthors without committer")
say.Debug(strings.Join(coauthors, ","))

sortByLength(coauthors)
debugInfo("Sorted unique coauthors without committer")
debugInfo(strings.Join(coauthors, ","))
say.Debug("Sorted unique coauthors without committer")
say.Debug(strings.Join(coauthors, ","))

return coauthors
}
Expand Down Expand Up @@ -94,11 +95,11 @@ func removeDuplicateValues(slice []string) []string {

func appendCoauthorsToSquashMsg(gitDir string) error {
squashMsgPath := path.Join(gitDir, "SQUASH_MSG")
debugInfo("opening " + squashMsgPath)
say.Debug("opening " + squashMsgPath)
file, err := os.OpenFile(squashMsgPath, os.O_APPEND|os.O_RDWR, 0644)
if err != nil {
if os.IsNotExist(err) {
debugInfo(squashMsgPath + " does not exist")
say.Debug(squashMsgPath + " does not exist")
// No wip commits, nothing to squash, this isn't really an error
return nil
}
Expand Down
Loading