Skip to content

Commit

Permalink
Support av stack branch <new branch> <base branch> (#265)
Browse files Browse the repository at this point in the history
address #244

```sh
$ av stack branch new-branch parent-branch
```
  • Loading branch information
Konboi authored May 6, 2024
1 parent 270194a commit 934e5c7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/av/stack_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ var stackBranchFlags struct {
Force bool
}
var stackBranchCmd = &cobra.Command{
Use: "branch [flags] <branch-name>",
Use: "branch [flags] <branch-name> [<parent-branch>]",
Aliases: []string{"b", "br"},
Short: "create a new stacked branch",
Long: `Create a new branch that is stacked on the current branch.
<parent-branch>. If omitted, the new branch bases off the current branch.
If the --rename/-m flag is given, the current branch is renamed to the name
given as the first argument to the command. Branches should only be renamed
with this command (not with git branch -m ...) because av needs to update
internal tracking metadata that defines the order of branches within a stack.`,
SilenceUsage: true,
Args: cobra.ExactArgs(1),
Args: cobra.RangeArgs(1, 2),
RunE: func(cmd *cobra.Command, args []string) (reterr error) {
repo, err := getRepo()
if err != nil {
Expand All @@ -51,6 +53,10 @@ internal tracking metadata that defines the order of branches within a stack.`,
}

branchName := args[0]
if len(args) == 2 {
stackBranchFlags.Parent = args[1]
}

if stackBranchFlags.Rename {
return stackBranchMove(repo, db, branchName, stackBranchFlags.Force)
}
Expand Down

0 comments on commit 934e5c7

Please sign in to comment.