Implemented GetGitLog

This commit is contained in:
マリウス
2020-10-17 13:16:06 +01:00
parent ee1ab3204b
commit 25f526d036
+17
View File
@@ -2,6 +2,8 @@ package z
import (
"os/user"
"os/exec"
"bytes"
"regexp"
"strconv"
"strings"
@@ -129,3 +131,18 @@ func GetISOWeekInMonth(date time.Time) (month int, weeknumber int) {
return int(changedDate.Month()), int(math.Ceil(float64(changedDate.Day()) / 7.0));
}
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.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
}