Implemented GetGitLog
This commit is contained in:
parent
ee1ab3204b
commit
25f526d036
1 changed files with 17 additions and 0 deletions
17
z/helpers.go
17
z/helpers.go
|
@ -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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue