|
| 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 | +} |
0 commit comments