Skip to content

Commit 6cbc1e0

Browse files
committed
Add section headers for rebase todos, cherry-picks, reverts, and actual commits
1 parent 98c19fe commit 6cbc1e0

File tree

46 files changed

+231
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+231
-0
lines changed

pkg/gui/context/local_commits_context.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package context
22

33
import (
4+
"fmt"
45
"log"
56
"strings"
67
"time"
@@ -66,6 +67,51 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
6667
)
6768
}
6869

70+
getNonModelItems := func() []*NonModelItem {
71+
result := []*NonModelItem{}
72+
if c.Model().WorkingTreeStateAtLastCommitRefresh.CanShowTodos() {
73+
if c.Model().WorkingTreeStateAtLastCommitRefresh.Rebasing {
74+
result = append(result, &NonModelItem{
75+
Index: 0,
76+
Content: fmt.Sprintf("--- %s ---", c.Tr.PendingRebaseTodosSectionHeader),
77+
})
78+
}
79+
80+
if c.Model().WorkingTreeStateAtLastCommitRefresh.CherryPicking ||
81+
c.Model().WorkingTreeStateAtLastCommitRefresh.Reverting {
82+
_, firstCherryPickOrRevertTodo, found := lo.FindIndexOf(
83+
c.Model().Commits, func(c *models.Commit) bool {
84+
return c.Status == models.StatusCherryPickingOrReverting ||
85+
c.Status == models.StatusConflicted
86+
})
87+
if !found {
88+
firstCherryPickOrRevertTodo = 0
89+
}
90+
label := lo.Ternary(c.Model().WorkingTreeStateAtLastCommitRefresh.CherryPicking,
91+
c.Tr.PendingCherryPicksSectionHeader,
92+
c.Tr.PendingRevertsSectionHeader)
93+
result = append(result, &NonModelItem{
94+
Index: firstCherryPickOrRevertTodo,
95+
Content: fmt.Sprintf("--- %s ---", label),
96+
})
97+
}
98+
99+
_, firstRealCommit, found := lo.FindIndexOf(
100+
c.Model().Commits, func(c *models.Commit) bool {
101+
return !c.IsTODO()
102+
})
103+
if !found {
104+
firstRealCommit = 0
105+
}
106+
result = append(result, &NonModelItem{
107+
Index: firstRealCommit,
108+
Content: fmt.Sprintf("--- %s ---", c.Tr.CommitsSectionHeader),
109+
})
110+
}
111+
112+
return result
113+
}
114+
69115
ctx := &LocalCommitsContext{
70116
LocalCommitsViewModel: viewModel,
71117
SearchTrait: NewSearchTrait(c),
@@ -82,6 +128,7 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
82128
ListRenderer: ListRenderer{
83129
list: viewModel,
84130
getDisplayStrings: getDisplayStrings,
131+
getNonModelItems: getNonModelItems,
85132
},
86133
c: c,
87134
refreshViewportOnChange: true,

pkg/i18n/english.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ type TranslationSet struct {
350350
NoRoom string
351351
YouAreHere string
352352
ConflictLabel string
353+
PendingRebaseTodosSectionHeader string
354+
PendingCherryPicksSectionHeader string
355+
PendingRevertsSectionHeader string
356+
CommitsSectionHeader string
353357
YouDied string
354358
RewordNotSupported string
355359
ChangingThisActionIsNotAllowed string
@@ -1419,6 +1423,10 @@ func EnglishTranslationSet() *TranslationSet {
14191423
NoRoom: "Not enough room",
14201424
YouAreHere: "YOU ARE HERE",
14211425
ConflictLabel: "CONFLICT",
1426+
PendingRebaseTodosSectionHeader: "Pending rebase todos",
1427+
PendingCherryPicksSectionHeader: "Pending cherry-picks",
1428+
PendingRevertsSectionHeader: "Pending reverts",
1429+
CommitsSectionHeader: "Commits",
14221430
YouDied: "YOU DIED!",
14231431
RewordNotSupported: "Rewording commits while interactively rebasing is not currently supported",
14241432
ChangingThisActionIsNotAllowed: "Changing this kind of rebase todo entry is not allowed",

pkg/integration/tests/branch/rebase_and_drop.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,23 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
5151
t.Views().Commits().
5252
Focus().
5353
TopLines(
54+
Contains("--- Pending rebase todos ---"),
5455
MatchesRegexp(`pick.*to keep`).IsSelected(),
5556
MatchesRegexp(`pick.*to remove`),
5657
MatchesRegexp(`pick.*CONFLICT.*first change`),
58+
Contains("--- Commits ---"),
5759
MatchesRegexp("second-change-branch unrelated change"),
5860
MatchesRegexp("second change"),
5961
MatchesRegexp("original"),
6062
).
6163
SelectNextItem().
6264
Press(keys.Universal.Remove).
6365
TopLines(
66+
Contains("--- Pending rebase todos ---"),
6467
MatchesRegexp(`pick.*to keep`),
6568
MatchesRegexp(`drop.*to remove`).IsSelected(),
6669
MatchesRegexp(`pick.*CONFLICT.*first change`),
70+
Contains("--- Commits ---"),
6771
MatchesRegexp("second-change-branch unrelated change"),
6872
MatchesRegexp("second change"),
6973
MatchesRegexp("original"),

pkg/integration/tests/cherry_pick/cherry_pick_during_rebase.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
5959
SelectNextItem().
6060
Press(keys.Universal.Edit).
6161
Lines(
62+
Contains("--- Pending rebase todos ---"),
6263
Contains("pick CI two"),
64+
Contains("--- Commits ---"),
6365
Contains(" CI <-- YOU ARE HERE --- one").IsSelected(),
6466
Contains(" CI base"),
6567
).
@@ -74,7 +76,9 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
7476
t.Views().Information().Content(DoesNotContain("commit copied"))
7577
}).
7678
Lines(
79+
Contains("--- Pending rebase todos ---"),
7780
Contains("pick CI two"),
81+
Contains("--- Commits ---"),
7882
Contains(" CI <-- YOU ARE HERE --- three"),
7983
Contains(" CI one"),
8084
Contains(" CI base"),

pkg/integration/tests/commit/amend_when_there_are_conflicts_and_amend.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ var AmendWhenThereAreConflictsAndAmend = NewIntegrationTest(NewIntegrationTestAr
2929
t.Views().Commits().
3030
Focus().
3131
Lines(
32+
Contains("--- Pending rebase todos ---"),
3233
Contains("pick").Contains("commit three"),
3334
Contains("pick").Contains("<-- CONFLICT --- file1 changed in branch"),
35+
Contains("--- Commits ---"),
3436
Contains("commit two"),
3537
Contains("file1 changed in master"),
3638
Contains("base commit"),

pkg/integration/tests/commit/amend_when_there_are_conflicts_and_cancel.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ var AmendWhenThereAreConflictsAndCancel = NewIntegrationTest(NewIntegrationTestA
3333
t.Views().Commits().
3434
Focus().
3535
Lines(
36+
Contains("--- Pending rebase todos ---"),
3637
Contains("pick").Contains("commit three"),
3738
Contains("pick").Contains("<-- CONFLICT --- file1 changed in branch"),
39+
Contains("--- Commits ---"),
3840
Contains("commit two"),
3941
Contains("file1 changed in master"),
4042
Contains("base commit"),

pkg/integration/tests/commit/revert_with_conflict_multiple_commits.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ var RevertWithConflictMultipleCommits = NewIntegrationTest(NewIntegrationTestArg
4444
Confirm()
4545
}).
4646
Lines(
47+
Contains("--- Pending reverts ---"),
4748
Contains("revert").Contains("CI unrelated change"),
4849
Contains("revert").Contains("CI <-- CONFLICT --- add first line"),
50+
Contains("--- Commits ---"),
4951
Contains("CI ◯ add second line"),
5052
Contains("CI ◯ add first line"),
5153
Contains("CI ◯ unrelated change"),

pkg/integration/tests/commit/revert_with_conflict_single_commit.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ var RevertWithConflictSingleCommit = NewIntegrationTest(NewIntegrationTestArgs{
3939
Confirm()
4040
}).
4141
Lines(
42+
Contains("--- Pending reverts ---"),
4243
Contains("revert").Contains("CI <-- CONFLICT --- add first line"),
44+
Contains("--- Commits ---"),
4345
Contains("CI ◯ add second line"),
4446
Contains("CI ◯ add first line"),
4547
Contains("CI ◯ add empty file"),

pkg/integration/tests/commit/shared.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ func doTheRebaseForAmendTests(t *TestDriver, keys config.KeybindingConfig) {
4343

4444
t.Views().Commits().
4545
Lines(
46+
Contains("--- Pending rebase todos ---"),
4647
Contains("pick").Contains("commit three"),
4748
Contains("pick").Contains("<-- CONFLICT --- file1 changed in branch"),
49+
Contains("--- Commits ---"),
4850
Contains("commit two"),
4951
Contains("file1 changed in master"),
5052
Contains("base commit"),

pkg/integration/tests/interactive_rebase/advanced_interactive_rebase.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,25 @@ var AdvancedInteractiveRebase = NewIntegrationTest(NewIntegrationTestArgs{
4545
t.Views().Commits().
4646
IsFocused().
4747
Lines(
48+
Contains("--- Pending rebase todos ---"),
4849
Contains(TOP_COMMIT),
50+
Contains("--- Commits ---"),
4951
Contains(BASE_COMMIT).Contains("YOU ARE HERE"),
5052
).
5153
NavigateToLine(Contains(TOP_COMMIT)).
5254
Press(keys.Universal.Edit).
5355
Lines(
56+
Contains("--- Pending rebase todos ---"),
5457
Contains(TOP_COMMIT).Contains("edit"),
58+
Contains("--- Commits ---"),
5559
Contains(BASE_COMMIT).Contains("YOU ARE HERE"),
5660
).
5761
Tap(func() {
5862
t.Common().ContinueRebase()
5963
}).
6064
Lines(
65+
Contains("--- Pending rebase todos ---"),
66+
Contains("--- Commits ---"),
6167
Contains(TOP_COMMIT).Contains("YOU ARE HERE"),
6268
Contains(BASE_COMMIT),
6369
)

0 commit comments

Comments
 (0)