Updated GetGitLog to only include own commits
This commit is contained in:
parent
25ad96dba2
commit
0d71ab2d34
1 changed files with 16 additions and 2 deletions
18
z/helpers.go
18
z/helpers.go
|
@ -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) {
|
func GetGitLog(repo string, since time.Time, until time.Time) (string, string, error) {
|
||||||
var stdout, stderr bytes.Buffer
|
var stdout, stderr bytes.Buffer
|
||||||
|
cmd := exec.Command("git", "-C", repo, "config", "user.name")
|
||||||
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.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
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())
|
stdoutStr, stderrStr := string(stdout.Bytes()), string(stderr.Bytes())
|
||||||
return stdoutStr, stderrStr, nil
|
return stdoutStr, stderrStr, nil
|
||||||
|
|
Loading…
Reference in a new issue