diff --git a/z/helpers.go b/z/helpers.go index 493c31f..fd09c10 100644 --- a/z/helpers.go +++ b/z/helpers.go @@ -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 +}