mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-05 00:59:19 +02:00
show author info in rebase commits
This commit is contained in:
@ -110,7 +110,7 @@ func (c *CommitListBuilder) MergeRebasingCommits(commits []*models.Commit) ([]*m
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
rebasingCommits, err := c.getRebasingCommits(rebaseMode)
|
rebasingCommits, err := c.getHydratedRebasingCommits(rebaseMode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Commit
|
|||||||
cmd := c.getLogCmd(opts)
|
cmd := c.getLogCmd(opts)
|
||||||
|
|
||||||
err = oscommands.RunLineOutputCmd(cmd, func(line string) (bool, error) {
|
err = oscommands.RunLineOutputCmd(cmd, func(line string) (bool, error) {
|
||||||
if strings.Split(line, " ")[0] != "gpg:" {
|
if canExtractCommit(line) {
|
||||||
commit := c.extractCommitFromLine(line)
|
commit := c.extractCommitFromLine(line)
|
||||||
if commit.Sha == firstPushedCommit {
|
if commit.Sha == firstPushedCommit {
|
||||||
passedFirstPushedCommit = true
|
passedFirstPushedCommit = true
|
||||||
@ -177,6 +177,47 @@ func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Commit
|
|||||||
return commits, nil
|
return commits, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *CommitListBuilder) getHydratedRebasingCommits(rebaseMode string) ([]*models.Commit, error) {
|
||||||
|
commits, err := c.getRebasingCommits(rebaseMode)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
commitShas := make([]string, len(commits))
|
||||||
|
for i, commit := range commits {
|
||||||
|
commitShas[i] = commit.Sha
|
||||||
|
}
|
||||||
|
|
||||||
|
// note that we're not filtering these as we do non-rebasing commits just because
|
||||||
|
// I suspect that will cause some damage
|
||||||
|
cmd := c.OSCommand.ExecutableFromString(
|
||||||
|
fmt.Sprintf(
|
||||||
|
"git show %s --no-patch --oneline %s --abbrev=%d",
|
||||||
|
strings.Join(commitShas, " "),
|
||||||
|
prettyFormat,
|
||||||
|
20,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
hydratedCommits := make([]*models.Commit, 0, len(commits))
|
||||||
|
i := 0
|
||||||
|
err = oscommands.RunLineOutputCmd(cmd, func(line string) (bool, error) {
|
||||||
|
c.Log.Warn(line)
|
||||||
|
if canExtractCommit(line) {
|
||||||
|
commit := c.extractCommitFromLine(line)
|
||||||
|
commit.Action = commits[i].Action
|
||||||
|
commit.Status = commits[i].Status
|
||||||
|
hydratedCommits = append(hydratedCommits, commit)
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return hydratedCommits, nil
|
||||||
|
}
|
||||||
|
|
||||||
// getRebasingCommits obtains the commits that we're in the process of rebasing
|
// getRebasingCommits obtains the commits that we're in the process of rebasing
|
||||||
func (c *CommitListBuilder) getRebasingCommits(rebaseMode string) ([]*models.Commit, error) {
|
func (c *CommitListBuilder) getRebasingCommits(rebaseMode string) ([]*models.Commit, error) {
|
||||||
switch rebaseMode {
|
switch rebaseMode {
|
||||||
@ -361,16 +402,25 @@ func (c *CommitListBuilder) getLogCmd(opts GetCommitsOptions) *exec.Cmd {
|
|||||||
|
|
||||||
return c.OSCommand.ExecutableFromString(
|
return c.OSCommand.ExecutableFromString(
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"git log %s --oneline --pretty=format:\"%%H%s%%at%s%%aN%s%%d%s%%p%s%%s\" %s --abbrev=%d %s",
|
"git log %s --oneline %s %s --abbrev=%d %s",
|
||||||
c.OSCommand.Quote(opts.RefName),
|
c.OSCommand.Quote(opts.RefName),
|
||||||
SEPARATION_CHAR,
|
prettyFormat,
|
||||||
SEPARATION_CHAR,
|
|
||||||
SEPARATION_CHAR,
|
|
||||||
SEPARATION_CHAR,
|
|
||||||
SEPARATION_CHAR,
|
|
||||||
limitFlag,
|
limitFlag,
|
||||||
20,
|
20,
|
||||||
filterFlag,
|
filterFlag,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var prettyFormat = fmt.Sprintf(
|
||||||
|
"--pretty=format:\"%%H%s%%at%s%%aN%s%%d%s%%p%s%%s\"",
|
||||||
|
SEPARATION_CHAR,
|
||||||
|
SEPARATION_CHAR,
|
||||||
|
SEPARATION_CHAR,
|
||||||
|
SEPARATION_CHAR,
|
||||||
|
SEPARATION_CHAR,
|
||||||
|
)
|
||||||
|
|
||||||
|
func canExtractCommit(line string) bool {
|
||||||
|
return strings.Split(line, " ")[0] != "gpg:"
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user