Skip to content

Commit

Permalink
remove head from git diff command, rename unstaged to staged (#1439)
Browse files Browse the repository at this point in the history
  • Loading branch information
zricethezav committed Jun 29, 2023
1 parent 18a70b6 commit 452734a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/gitparse/gitparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ func (c *Parser) RepoPath(ctx context.Context, source string, head string, abbre
return c.executeCommand(ctx, cmd)
}

// Unstaged parses the output of the `git diff` command for the `source` path.
func (c *Parser) Unstaged(ctx context.Context, source string) (chan Commit, error) {
// Staged parses the output of the `git diff` command for the `source` path.
func (c *Parser) Staged(ctx context.Context, source string) (chan Commit, error) {
// Provide the --cached flag to diff to get the diff of the staged changes.
args := []string{"-C", source, "diff", "-p", "--cached", "--full-history", "--diff-filter=AM", "--date=format:%a %b %d %H:%M:%S %Y %z", "HEAD"}
args := []string{"-C", source, "diff", "-p", "--cached", "--full-history", "--diff-filter=AM", "--date=format:%a %b %d %H:%M:%S %Y %z"}

cmd := exec.Command("git", args...)

Expand Down
2 changes: 1 addition & 1 deletion pkg/sources/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ func (s *Git) ScanStaged(ctx context.Context, repo *git.Repository, path string,
// Get the URL metadata for reporting (may be empty).
urlMetadata := getSafeRemoteURL(repo, "origin")

commitChan, err := gitparse.NewParser().Unstaged(ctx, path)
commitChan, err := gitparse.NewParser().Staged(ctx, path)
if err != nil {
return err
}
Expand Down

0 comments on commit 452734a

Please sign in to comment.