Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Command = &cli.Command{ Name: "checkout", UsageText: "checkout [options] <changeID>", Usage: "Checkout an available change", Action: func(ctx *cli.Context) error { gerritAPI := common.GerritAPI(ctx.Context) repo := common.GitRepository(ctx.Context) wt, err := repo.Worktree() if err != nil { return fmt.Errorf("failed to obtain worktree: %v", err) } changeID := ctx.Args().Get(0) change, err := gerritAPI.Client.GetChange(ctx.Context, changeID, gerrit.QueryChangesOpt{ Fields: []string{"CURRENT_REVISION"}, }) if err != nil { return err } branchName := fmt.Sprintf("gerrit/%d", change.ChangeNumber) branchRefName := plumbing.NewBranchReferenceName(branchName) revision := change.Revisions[change.CurrentRevision] err = repo.Fetch(&git.FetchOptions{ RemoteName: "gerrit", RefSpecs: []config.RefSpec{ config.RefSpec(revision.Ref + ":" + string(branchRefName)), }, Force: true, }) if err != nil { return fmt.Errorf("failed to fetch updates for branch: %v", err) } err = wt.Checkout(&git.CheckoutOptions{ Branch: branchRefName, }) if err != nil { return fmt.Errorf("failed to checkout branch: %v", err) } return nil }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.