summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-02-26 20:39:00 +0100
committerStefan Haller <stefan@haller-berlin.de>2024-02-26 20:48:25 +0100
commitd5e06309676c649caf2644eea593964eb18943de (patch)
tree179d1ef8994954bece83bd29158c48efd27dcd3e
parent37c671b4c0bc295b55bc53864a1041b17ff749b3 (diff)
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.
-rw-r--r--pkg/gui/presentation/commits.go6
-rw-r--r--pkg/gui/presentation/commits_test.go26
2 files changed, 16 insertions, 16 deletions
diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go
index b4297f6ed..9b4730a43 100644
--- a/pkg/gui/presentation/commits.go
+++ b/pkg/gui/presentation/commits.go
@@ -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
}
}
diff --git a/pkg/gui/presentation/commits_test.go b/pkg/gui/presentation/commits_test.go
index 16f1de660..b907b29d2 100644
--- a/pkg/gui/presentation/commits_test.go
+++ b/pkg/gui/presentation/commits_test.go
@@ -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"}},
},