Fix showing the "YOU ARE HERE" marker for old-style non-interactive rebases

When stopping in an old-style non-interactive rebase (see previous commit for an
explanation of what that means), the YOU ARE HERE marker should point to the
first non-rebasing commit, but it was pointing at the first rebasing commit
instead.

To keep the tests working, we need to set all commits that have an Action to
StatusRebasing, which matches what happens in the real code.
This commit is contained in:
Stefan Haller 2024-02-26 20:39:00 +01:00
parent 37c671b4c0
commit d5e0630967
2 changed files with 16 additions and 16 deletions

View file

@ -69,7 +69,7 @@ func GetCommitListDisplayStrings(
}
// this is where my non-TODO commits begin
rebaseOffset := utils.Min(indexOfFirstNonTODOCommit(commits), endIdx)
rebaseOffset := utils.Min(indexOfFirstNonRebasingCommit(commits), endIdx)
filteredCommits := commits[startIdx:endIdx]
@ -187,9 +187,9 @@ func getbisectBounds(commits []*models.Commit, bisectInfo *git_commands.BisectIn
}
// precondition: slice is not empty
func indexOfFirstNonTODOCommit(commits []*models.Commit) int {
func indexOfFirstNonRebasingCommit(commits []*models.Commit) int {
for i, commit := range commits {
if !commit.IsTODO() {
if commit.Status != models.StatusRebasing {
return i
}
}

View file

@ -216,8 +216,8 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
{
testName: "showing graph, including rebase commits",
commits: []*models.Commit{
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: todo.Pick},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: todo.Pick},
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}},
{Name: "commit4", Sha: "sha4", Parents: []string{"sha5"}},
{Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}},
@ -240,8 +240,8 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
{
testName: "showing graph, including rebase commits, with offset",
commits: []*models.Commit{
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: todo.Pick},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: todo.Pick},
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}},
{Name: "commit4", Sha: "sha4", Parents: []string{"sha5"}},
{Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}},
@ -263,8 +263,8 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
{
testName: "startIdx is past TODO commits",
commits: []*models.Commit{
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: todo.Pick},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: todo.Pick},
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}},
{Name: "commit4", Sha: "sha4", Parents: []string{"sha5"}},
{Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}},
@ -284,8 +284,8 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
{
testName: "only showing TODO commits",
commits: []*models.Commit{
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: todo.Pick},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: todo.Pick},
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}},
{Name: "commit4", Sha: "sha4", Parents: []string{"sha5"}},
{Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}},
@ -325,10 +325,10 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
{
testName: "only TODO commits except last",
commits: []*models.Commit{
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: todo.Pick},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: todo.Pick},
{Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}, Action: todo.Pick},
{Name: "commit4", Sha: "sha4", Parents: []string{"sha5"}, Action: todo.Pick},
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit4", Sha: "sha4", Parents: []string{"sha5"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}},
},
startIdx: 0,
@ -346,7 +346,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
{
testName: "don't show YOU ARE HERE label when not asked for (e.g. in branches panel)",
commits: []*models.Commit{
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2"}, Action: todo.Pick},
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2"}, Action: todo.Pick, Status: models.StatusRebasing},
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}},
{Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}},
},