Skip to content

Commit 58d1549

Browse files
committed
placeholders for checkout and merge
1 parent cc21c25 commit 58d1549

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

cmd/checkout.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cmd
2+
3+
import (
4+
"github.com/github/gh-stack/internal/config"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
type checkoutOptions struct {
9+
target string
10+
noSwitch bool
11+
}
12+
13+
func CheckoutCmd(cfg *config.Config) *cobra.Command {
14+
opts := &checkoutOptions{}
15+
16+
cmd := &cobra.Command{
17+
Use: "checkout <pr-or-branch>",
18+
Short: "Checkout a stack from a PR number or branch name",
19+
Long: "Discover and check out an entire stack from a pull request number, URL, or branch name.",
20+
Args: cobra.ExactArgs(1),
21+
RunE: func(cmd *cobra.Command, args []string) error {
22+
opts.target = args[0]
23+
return runCheckout(cfg, opts)
24+
},
25+
}
26+
27+
cmd.Flags().BoolVar(&opts.noSwitch, "no-switch", false, "Fetch and track the stack without switching branches")
28+
29+
return cmd
30+
}
31+
32+
// runCheckout is a placeholder for the stack checkout workflow.
33+
//
34+
// The intended behavior is:
35+
// 1. Resolve the target (PR number, URL, or branch name) to a PR
36+
// 2. If the PR is part of a stack, discover the full set of PRs in the stack
37+
// 3. Fetch and create local tracking branches for every branch in the stack
38+
// 4. Save the stack to local tracking (.git/gh-stack, similar to gh stack init --adopt)
39+
// 5. Switch to the target branch (unless --no-switch is set)
40+
func runCheckout(cfg *config.Config, opts *checkoutOptions) error {
41+
cfg.Warningf("gh stack checkout is not yet implemented\n")
42+
return nil
43+
}

cmd/merge.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package cmd
2+
3+
import (
4+
"github.com/github/gh-stack/internal/config"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
func MergeCmd(cfg *config.Config) *cobra.Command {
9+
opts := struct{}{}
10+
11+
cmd := &cobra.Command{
12+
Use: "merge <pr>",
13+
Short: "Merge a stack of PRs",
14+
Long: "Merges the specified PR and all PRs below it in the stack.",
15+
Args: cobra.ExactArgs(1),
16+
RunE: func(cmd *cobra.Command, args []string) error {
17+
return runMerge(cfg, opts)
18+
},
19+
}
20+
21+
return cmd
22+
}
23+
24+
// runMerge is a placeholder for the stack merge workflow.
25+
//
26+
// We need a mergeability check for the entire stack
27+
// and an endpoint for merging an entire stack
28+
func runMerge(cfg *config.Config, opts struct{}) error {
29+
cfg.Warningf("gh stack merge is not yet implemented\n")
30+
return nil
31+
}

cmd/root.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ func RootCmd() *cobra.Command {
2525
root.AddCommand(InitCmd(cfg))
2626
root.AddCommand(AddCmd(cfg))
2727

28+
// Remote operations
29+
root.AddCommand(CheckoutCmd(cfg))
30+
root.AddCommand(MergeCmd(cfg))
31+
2832
// Helper commands
2933
root.AddCommand(ViewCmd(cfg))
3034
root.AddCommand(UpdateCmd(cfg))

0 commit comments

Comments
 (0)