Skip to content

Commit

Permalink
Updated GetGitLog to only include own commits
Browse files Browse the repository at this point in the history
  • Loading branch information
マリウス committed Oct 17, 2020
1 parent 25ad96d commit 0d71ab2
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions z/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,28 @@ func GetISOWeekInMonth(date time.Time) (month int, weeknumber int) {

func GetGitLog(repo string, since time.Time, until time.Time) (string, string, error) {
var stdout, stderr bytes.Buffer

cmd := exec.Command("git", "-C", repo, "log", "--since", since.Format("2006-01-02T15:04:05-0700"), "--until", until.Format("2006-01-02T15:04:05-0700"), "--pretty=oneline")
cmd := exec.Command("git", "-C", repo, "config", "user.name")
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
return "", "", err
}
gitUserStr, gitUserErrStr := string(stdout.Bytes()), string(stderr.Bytes())
if gitUserStr == "" && gitUserErrStr != "" {
return gitUserStr, gitUserErrStr, errors.New(gitUserErrStr)
}

stdout.Reset()
stderr.Reset()

cmd = exec.Command("git", "-C", repo, "log", "--author", gitUserStr, "--since", since.Format("2006-01-02T15:04:05-0700"), "--until", until.Format("2006-01-02T15:04:05-0700"), "--pretty=oneline")
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err = cmd.Run()
if err != nil {
return "", "", err
}

stdoutStr, stderrStr := string(stdout.Bytes()), string(stderr.Bytes())
return stdoutStr, stderrStr, nil
Expand Down

0 comments on commit 0d71ab2

Please sign in to comment.