Skip to content

Commit

Permalink
Use repoRevisions and limit in git log command
Browse files Browse the repository at this point in the history
  • Loading branch information
felixjung authored and daveshanley committed Oct 8, 2024
1 parent 47b3402 commit bca5591
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion git/read_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"os/exec"
"path"
"strconv"
"strings"
"time"

Expand All @@ -30,6 +31,7 @@ const (
TOPLEVEL = "--show-toplevel"
NOPAGER = "--no-pager"
LOGFORMAT = "--pretty=%cD||%h||%s||%an||%ae"
NUMBER = "-n"
DIV = "--"
)

Expand Down Expand Up @@ -60,7 +62,17 @@ func GetTopLevel(dir string) (string, error) {
func ExtractHistoryFromFile(repoDirectory, filePath string,
progressChan chan *model.ProgressUpdate, errorChan chan model.ProgressError, repoRevisions bool, limit int, limitTime int) ([]*model.Commit, []error) {

cmd := exec.Command(GIT, NOPAGER, LOG, LOGFORMAT, DIV, filePath)
args := []string{NOPAGER, LOG, LOGFORMAT}

if limit > 0 && repoRevisions {
args = append(args, fmt.Sprintf("HEAD~%d..HEAD", limit))
} else if limit > 0 {
args = append(args, NUMBER, strconv.Itoa(limit))
}

args = append(args, DIV, filePath)

cmd := exec.Command(GIT, args...)
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
Expand Down

0 comments on commit bca5591

Please sign in to comment.