99 "github.com/boneskull/gh-stack/internal/config"
1010 "github.com/boneskull/gh-stack/internal/git"
1111 "github.com/boneskull/gh-stack/internal/state"
12+ "github.com/boneskull/gh-stack/internal/style"
1213 "github.com/boneskull/gh-stack/internal/tree"
1314 "github.com/boneskull/gh-stack/internal/undo"
1415 "github.com/spf13/cobra"
@@ -36,6 +37,8 @@ func init() {
3637}
3738
3839func runCascade (cmd * cobra.Command , args []string ) error {
40+ s := style .New ()
41+
3942 cwd , err := os .Getwd ()
4043 if err != nil {
4144 return err
@@ -81,19 +84,19 @@ func runCascade(cmd *cobra.Command, args []string) error {
8184 var stashRef string
8285 if ! cascadeDryRunFlag {
8386 var saveErr error
84- stashRef , saveErr = saveUndoSnapshot (g , cfg , branches , nil , "cascade" , "gh stack cascade" )
87+ stashRef , saveErr = saveUndoSnapshot (g , cfg , branches , nil , "cascade" , "gh stack cascade" , s )
8588 if saveErr != nil {
86- fmt .Printf ("Warning: could not save undo state: %v\n " , saveErr )
89+ fmt .Printf ("%s could not save undo state: %v\n " , s . WarningIcon () , saveErr )
8790 }
8891 }
8992
90- err = doCascadeWithState (g , cfg , branches , cascadeDryRunFlag , state .OperationCascade , false , false , false , nil , stashRef )
93+ err = doCascadeWithState (g , cfg , branches , cascadeDryRunFlag , state .OperationCascade , false , false , false , nil , stashRef , s )
9194
9295 // Restore auto-stashed changes after operation (unless conflict, which saves stash in state)
9396 if stashRef != "" && err != ErrConflict {
9497 fmt .Println ("Restoring auto-stashed changes..." )
9598 if popErr := g .StashPop (stashRef ); popErr != nil {
96- fmt .Printf ("Warning: could not restore stashed changes (commit %s): %v\n " , git .AbbrevSHA (stashRef ), popErr )
99+ fmt .Printf ("%s could not restore stashed changes (commit %s): %v\n " , s . WarningIcon () , git .AbbrevSHA (stashRef ), popErr )
97100 }
98101 }
99102
@@ -103,7 +106,7 @@ func runCascade(cmd *cobra.Command, args []string) error {
103106// doCascadeWithState performs cascade and saves state with the given operation type.
104107// allBranches is the complete list of branches for submit operations (used for push/PR after continue).
105108// stashRef is the commit hash of auto-stashed changes (if any), persisted to state on conflict.
106- func doCascadeWithState (g * git.Git , cfg * config.Config , branches []* tree.Node , dryRun bool , operation string , updateOnly , web , pushOnly bool , allBranches []string , stashRef string ) error {
109+ func doCascadeWithState (g * git.Git , cfg * config.Config , branches []* tree.Node , dryRun bool , operation string , updateOnly , web , pushOnly bool , allBranches []string , stashRef string , s * style. Style ) error {
107110 originalBranch , err := g .CurrentBranch ()
108111 if err != nil {
109112 return err
@@ -126,12 +129,12 @@ func doCascadeWithState(g *git.Git, cfg *config.Config, branches []*tree.Node, d
126129 }
127130
128131 if ! needsRebase {
129- fmt .Printf ("Cascading %s... already up to date \n " , b .Name )
132+ fmt .Printf ("Cascading %s... %s \n " , s . Branch ( b .Name ), s . Muted ( "already up to date" ) )
130133 continue
131134 }
132135
133136 if dryRun {
134- fmt .Printf ("Would rebase %s onto %s\n " , b .Name , parent )
137+ fmt .Printf ("%s Would rebase %s onto %s\n " , s . Muted ( "dry-run:" ), s . Branch ( b .Name ), s . Branch ( parent ) )
135138 continue
136139 }
137140
@@ -150,9 +153,9 @@ func doCascadeWithState(g *git.Git, cfg *config.Config, branches []*tree.Node, d
150153 }
151154
152155 if useOnto {
153- fmt .Printf ("Cascading %s onto %s (using fork point) ...\n " , b .Name , parent )
156+ fmt .Printf ("Cascading %s onto %s %s ...\n " , s . Branch ( b .Name ), s . Branch ( parent ), s . Muted ( "(using fork point)" ) )
154157 } else {
155- fmt .Printf ("Cascading %s onto %s...\n " , b .Name , parent )
158+ fmt .Printf ("Cascading %s onto %s...\n " , s . Branch ( b .Name ), s . Branch ( parent ) )
156159 }
157160
158161 // Checkout and rebase
@@ -187,15 +190,15 @@ func doCascadeWithState(g *git.Git, cfg *config.Config, branches []*tree.Node, d
187190 }
188191 _ = state .Save (g .GetGitDir (), st ) //nolint:errcheck // best effort - user can recover manually
189192
190- fmt .Printf ("\n CONFLICT : Resolve conflicts and run 'gh stack continue', or 'gh stack abort' to cancel.\n " )
193+ fmt .Printf ("\n %s %s \n " , s . FailureIcon (), s . Error ( "CONFLICT : Resolve conflicts and run 'gh stack continue', or 'gh stack abort' to cancel." ) )
191194 fmt .Printf ("Remaining branches: %v\n " , remaining )
192195 if stashRef != "" {
193- fmt .Printf ( "Note: Your uncommitted changes are stashed and will be restored when you continue or abort.\n " )
196+ fmt .Println ( s . Muted ( "Note: Your uncommitted changes are stashed and will be restored when you continue or abort." ) )
194197 }
195198 return ErrConflict
196199 }
197200
198- fmt .Printf ("Cascading %s... ok \n " , b .Name )
201+ fmt .Printf ("Cascading %s... %s \n " , s . Branch ( b .Name ), s . Success ( "ok" ) )
199202
200203 // Update fork point to current parent tip
201204 parentTip , tipErr := g .GetTip (parent )
@@ -217,7 +220,7 @@ func doCascadeWithState(g *git.Git, cfg *config.Config, branches []*tree.Node, d
217220// branches: branches that will be modified (rebased)
218221// deletedBranches: branches that will be deleted (for sync)
219222// Returns the stash ref (commit hash) if changes were stashed, empty string otherwise.
220- func saveUndoSnapshot (g * git.Git , cfg * config.Config , branches []* tree.Node , deletedBranches []* tree.Node , operation , command string ) (string , error ) {
223+ func saveUndoSnapshot (g * git.Git , cfg * config.Config , branches []* tree.Node , deletedBranches []* tree.Node , operation , command string , s * style. Style ) (string , error ) {
221224 gitDir := g .GetGitDir ()
222225
223226 // Get current branch for original head
@@ -243,7 +246,7 @@ func saveUndoSnapshot(g *git.Git, cfg *config.Config, branches []*tree.Node, del
243246 }
244247 if stashRef != "" {
245248 snapshot .StashRef = stashRef
246- fmt .Println ("Auto-stashed uncommitted changes" )
249+ fmt .Println (s . Muted ( "Auto-stashed uncommitted changes" ) )
247250 }
248251 }
249252
@@ -252,7 +255,7 @@ func saveUndoSnapshot(g *git.Git, cfg *config.Config, branches []*tree.Node, del
252255 bs , captureErr := captureBranchState (g , cfg , node .Name )
253256 if captureErr != nil {
254257 // Non-fatal: log warning and continue
255- fmt .Printf ("Warning: could not capture state for %s: %v\n " , node .Name , captureErr )
258+ fmt .Printf ("%s could not capture state for %s: %v\n " , s . WarningIcon (), s . Branch ( node .Name ) , captureErr )
256259 continue
257260 }
258261 snapshot .Branches [node .Name ] = bs
@@ -262,7 +265,7 @@ func saveUndoSnapshot(g *git.Git, cfg *config.Config, branches []*tree.Node, del
262265 for _ , node := range deletedBranches {
263266 bs , captureErr := captureBranchState (g , cfg , node .Name )
264267 if captureErr != nil {
265- fmt .Printf ("Warning: could not capture state for deleted branch %s: %v\n " , node .Name , captureErr )
268+ fmt .Printf ("%s could not capture state for deleted branch %s: %v\n " , s . WarningIcon (), s . Branch ( node .Name ) , captureErr )
266269 continue
267270 }
268271 snapshot .DeletedBranches [node .Name ] = bs
@@ -278,7 +281,7 @@ func saveUndoSnapshot(g *git.Git, cfg *config.Config, branches []*tree.Node, del
278281// saveUndoSnapshotByName is like saveUndoSnapshot but takes branch names instead of tree nodes.
279282// Useful for sync where we don't always have tree nodes.
280283// Returns the stash ref (commit hash) if changes were stashed, empty string otherwise.
281- func saveUndoSnapshotByName (g * git.Git , cfg * config.Config , branchNames []string , deletedBranchNames []string , operation , command string ) (string , error ) {
284+ func saveUndoSnapshotByName (g * git.Git , cfg * config.Config , branchNames []string , deletedBranchNames []string , operation , command string , s * style. Style ) (string , error ) {
282285 gitDir := g .GetGitDir ()
283286
284287 // Get current branch for original head
@@ -304,15 +307,15 @@ func saveUndoSnapshotByName(g *git.Git, cfg *config.Config, branchNames []string
304307 }
305308 if stashRef != "" {
306309 snapshot .StashRef = stashRef
307- fmt .Println ("Auto-stashed uncommitted changes" )
310+ fmt .Println (s . Muted ( "Auto-stashed uncommitted changes" ) )
308311 }
309312 }
310313
311314 // Capture state of branches that will be modified
312315 for _ , name := range branchNames {
313316 bs , captureErr := captureBranchState (g , cfg , name )
314317 if captureErr != nil {
315- fmt .Printf ("Warning: could not capture state for %s: %v\n " , name , captureErr )
318+ fmt .Printf ("%s could not capture state for %s: %v\n " , s . WarningIcon (), s . Branch ( name ) , captureErr )
316319 continue
317320 }
318321 snapshot .Branches [name ] = bs
@@ -322,7 +325,7 @@ func saveUndoSnapshotByName(g *git.Git, cfg *config.Config, branchNames []string
322325 for _ , name := range deletedBranchNames {
323326 bs , captureErr := captureBranchState (g , cfg , name )
324327 if captureErr != nil {
325- fmt .Printf ("Warning: could not capture state for deleted branch %s: %v\n " , name , captureErr )
328+ fmt .Printf ("%s could not capture state for deleted branch %s: %v\n " , s . WarningIcon (), s . Branch ( name ) , captureErr )
326329 continue
327330 }
328331 snapshot .DeletedBranches [name ] = bs
0 commit comments