Skip to content

Commit

Permalink
Merge pull request #409 from planetscale/iheanyi/fix-branch-prompts
Browse files Browse the repository at this point in the history
Fix branch prompts for protected branches in the shell
  • Loading branch information
iheanyi authored Oct 14, 2021
2 parents 79d295b + 009a660 commit 8be02c8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/cmd/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ second argument:
return err
}

styledBranch := formatMySQLBranch(database, branch)
styledBranch := formatMySQLBranch(database, dbBranch)

m := &mysql{
mysqlPath: mysqlPath,
Expand Down Expand Up @@ -221,12 +221,14 @@ func (m *mysql) Run(ctx context.Context, args ...string) error {
return c.Run()
}

func formatMySQLBranch(database, branch string) string {
if branch == "main" {
branch = "|⚠ main ⚠|"
func formatMySQLBranch(database string, branch *ps.DatabaseBranch) string {
branchStr := branch.Name

if branch.Production {
branchStr = fmt.Sprintf("|⚠ %s ⚠|", branch.Name)
}

return fmt.Sprintf("%s/%s> ", database, branch)
return fmt.Sprintf("%s/%s> ", database, branchStr)
}

func historyFilePath(org, db, branch string) (string, error) {
Expand Down

0 comments on commit 8be02c8

Please sign in to comment.