Skip to content

Commit

Permalink
Merge pull request #2947 from ActiveState/mitchell/dx-114
Browse files Browse the repository at this point in the history
Add notice about how to switch between branches in `state branch` when applicable.
  • Loading branch information
mitchell-as authored Dec 14, 2023
2 parents 1ad750b + 0b203a3 commit 8dfa1f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/runners/branch/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@ func (l *List) Run() error {
project.Branches,
))

if len(project.Branches) > 1 {
l.out.Notice(locale.Tl("branch_switch_notice", "To switch to another branch, run '[ACTIONABLE]state branch switch <name>[/RESET]'."))
}

return nil
}
7 changes: 7 additions & 0 deletions test/integration/branch_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ func (suite *BranchIntegrationTestSuite) TestBranch_List() {
cp := ts.SpawnWithOpts(e2e.OptArgs("branch"), e2e.OptTermTest(termtest.OptVerboseLogger()))
// Sometimes there's a space before the line break, unsure exactly why, but hence the regex
cp.ExpectRe(`main \(Current\)\s?\n ├─ firstbranch\s?\n │ └─ firstbranchchild\s?\n │ └─ childoffirstbranchchild\s?\n ├─ secondbranch\s?\n └─ thirdbranch`, termtest.OptExpectTimeout(5*time.Second))
cp.Expect("To switch to another branch,")
cp.ExpectExitCode(0)

ts.PrepareProject("ActiveState-CLI/small-python", "")
cp = ts.Spawn("branch")
cp.Expect("main")
suite.Assert().NotContains(cp.Snapshot(), "To switch to another branch,") // only shows when multiple branches are listed
cp.ExpectExitCode(0)
}

Expand Down

0 comments on commit 8dfa1f6

Please sign in to comment.