MCPcopy Create free account
hub / github.com/docker/secrets-engine / ReleaseCommand

Function ReleaseCommand

x/release/command.go:46–89  ·  view source on GitHub ↗
(cfg Config)

Source from the content-addressed store, hash-verified

44}
45
46func ReleaseCommand(cfg Config) (*cobra.Command, error) {
47 opts := opts{level: helper.Patch}
48 if _, err := os.Stat(".git"); err != nil {
49 if os.IsNotExist(err) {
50 return nil, fmt.Errorf("not in a git repository root directory")
51 }
52 return nil, err
53 }
54 bump := &cobra.Command{
55 Use: "bump [OPTIONS] <module>",
56 Args: cobra.ExactArgs(1),
57 RunE: func(cmd *cobra.Command, args []string) error {
58 mod := args[0]
59 if !opts.dryRun && !opts.skipGit {
60 if err := verifyReleaseRef(cmd.Context()); err != nil {
61 return err
62 }
63 }
64 data, err := newRepoData(cfg.EnableModulesWithPreReleaseVersion)
65 if err != nil {
66 return err
67 }
68 if _, ok := data[mod]; !ok {
69 return fmt.Errorf("module %s not found", mod)
70 }
71 if opts.noPropagate {
72 modData, ok := data[mod]
73 if !ok {
74 return fmt.Errorf("module %s not found", mod)
75 }
76 return helper.BumpModule(cmd.Context(), mod, opts.level, modData, &projectFS{opts: opts, beforeCommitHook: cfg.BeforeCommitHook, logger: logging.NewDefaultLogger("")})
77 }
78 return helper.BumpIterative(cmd.Context(), mod, opts.level, data, &projectFS{opts: opts, beforeCommitHook: cfg.BeforeCommitHook, logger: logging.NewDefaultLogger("")})
79 },
80 }
81
82 flags := bump.Flags()
83 flags.BoolVar(&opts.dryRun, "dry", false, "Dry run: Only log all steps, no actual changes will be made.")
84 flags.BoolVar(&opts.skipGit, "skip-git", false, "Skip git operations: Useful to preview only the go.mod changes.")
85 flags.Var(&opts.level, "release", fmt.Sprintf("Release type (default=patch): %s", helper.AllowedLevels()))
86 flags.BoolVar(&opts.noPropagate, "no-propagate", false, "Only release the specified module and do not propagate to internal downstream dependencies.")
87
88 return bump, nil
89}
90
91type projectFS struct {
92 opts

Callers 1

mainFunction · 0.85

Calls 3

verifyReleaseRefFunction · 0.85
newRepoDataFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected