Implemented GetGitLog

This commit is contained in:
マリウス 2020-10-17 13:16:06 +01:00
parent ee1ab3204b
commit 25f526d036
No known key found for this signature in database
GPG key ID: C228EF0A530AF06F

View file

@ -2,6 +2,8 @@ package z
import ( import (
"os/user" "os/user"
"os/exec"
"bytes"
"regexp" "regexp"
"strconv" "strconv"
"strings" "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)); 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
}