Documentation
¶
Overview ¶
Package git implements the `atmos git` command group, providing Git repository operations (clone, pull, status, diff, commit, push) through the shared pkg/git service and provider registry.
All commands follow the command registry pattern (CommandProvider interface) and use flags.NewStandardParser() for flag handling.
Index ¶
- func CICloneBootstrapRequested(cmd *cobra.Command, args []string) bool
- func CIGitCloneBootstrapRequestedFromRawArgs(rawArgs []string) bool
- func IsURI(s string) bool
- func SetAtmosConfig(config *schema.AtmosConfiguration)
- type Executor
- func (e *Executor) Clone(ctx context.Context, opts *atmosgit.CloneOptions, label string) error
- func (e *Executor) CloneWithoutSpinner(ctx context.Context, opts *atmosgit.CloneOptions, label string) error
- func (e *Executor) Commit(ctx context.Context, opts *atmosgit.CommitOptions) (*atmosgit.CommitResult, error)
- func (e *Executor) Diff(ctx context.Context, opts *atmosgit.DiffOptions) (*atmosgit.DiffResult, error)
- func (e *Executor) Init(ctx context.Context, opts *atmosgit.InitOptions, label string) error
- func (e *Executor) Pull(ctx context.Context, opts *atmosgit.PullOptions) error
- func (e *Executor) Push(ctx context.Context, opts *atmosgit.PushOptions) error
- func (e *Executor) Status(ctx context.Context, opts *atmosgit.StatusOptions) (*atmosgit.StatusResult, error)
- type GitCommandProvider
- func (g *GitCommandProvider) GetAliases() []internal.CommandAlias
- func (g *GitCommandProvider) GetCommand() *cobra.Command
- func (g *GitCommandProvider) GetCompatibilityFlags() map[string]compat.CompatibilityFlag
- func (g *GitCommandProvider) GetFlagsBuilder() flags.Builder
- func (g *GitCommandProvider) GetGroup() string
- func (g *GitCommandProvider) GetName() string
- func (g *GitCommandProvider) GetPositionalArgsBuilder() *flags.PositionalArgsBuilder
- func (g *GitCommandProvider) IsExperimental() bool
- type GitListOptions
- type ParsedURI
- type StatusProber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CICloneBootstrapRequested ¶ added in v1.225.0
CICloneBootstrapRequested reports whether the invoked command is a no-argument `atmos git clone` running under a detected CI provider that has not explicitly opted out of CI checkout (--ci=false / ATMOS_CI=false).
RootCmd's config-init-error path (cmd/root.go) uses this to tolerate a missing or malformed atmos.yaml: the CI bootstrap clone runs in an empty workspace (e.g. replacing actions/checkout) where no atmos.yaml can exist yet. This must only be called after Cobra has parsed cmd's flags (true from PersistentPreRun onward), since it reads the real --ci flag via resolveCICloneMode instead of re-parsing os.Args by hand.
func CIGitCloneBootstrapRequestedFromRawArgs ¶ added in v1.226.0
CIGitCloneBootstrapRequestedFromRawArgs reports the same no-argument CI git-clone bootstrap condition as CICloneBootstrapRequested, but checked against raw, unparsed arguments instead of an already Cobra-resolved command, where rawArgs is the clone-specific arguments only, with the leading "atmos git clone" tokens already stripped by the caller.
Execute() in cmd/root.go runs an initial cfg.InitCliConfig before Cobra ever parses the invoked command (see that function's config-init-error handling). A missing/invalid atmos.yaml or unresolved profile at that point currently aborts the process before PersistentPreRun -- and therefore before CICloneBootstrapRequested/applyCIGitCloneBootstrap ever run -- even for the CI bootstrap clone, which runs in an empty workspace where no atmos.yaml or profile can exist yet. This lets that earlier handler recognize the same bootstrap shape.
This parses rawArgs against a throwaway command carrying the real clone flag set (a fresh newCloneParser() instance, never the shared package-level cloneParser singleton, to avoid disturbing its registered *cobra.Command) so flags that take a value, such as --depth and --branch, are correctly distinguished from a positional repo name/URI via real pflag parsing, instead of guessing from a "-"-prefix heuristic that a space-separated flag value such as the "0" in `--depth 0` would misread as a positional argument and wrongly disqualify the bootstrap. It also honors an explicit --ci/--ci=false on rawArgs, which a purely environment-based check could not see.
The throwaway root also carries the real global persistent flags (e.g. --config, --chdir) via a fresh GlobalOptionsBuilder, since this bootstrap check runs before RootCmd's own PersistentFlags are attached to it. Without them, an otherwise-valid invocation like `atmos git clone --config missing.yaml` would fail clone.ParseFlags with "unknown flag" and this function would wrongly report false, deferring CI bootstrap detection.
func IsURI ¶
IsURI reports whether s looks like a Git URI:
- has git:: forcing prefix
- starts with https:// or http://
- starts with git@... (SCP-style)
- starts with ssh://
- starts with git://
func SetAtmosConfig ¶
func SetAtmosConfig(config *schema.AtmosConfiguration)
SetAtmosConfig is called from root.go after atmosConfig is initialized, making the configuration available to all git subcommands.
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor holds the resolved inputs for a single Git operation and delegates to an injected Provider. This enables unit testing without invoking real git subprocesses: tests pass a stub provider; production passes the real one.
func (*Executor) CloneWithoutSpinner ¶
func (*Executor) Commit ¶
func (e *Executor) Commit(ctx context.Context, opts *atmosgit.CommitOptions) (*atmosgit.CommitResult, error)
Commit delegates to the provider.
func (*Executor) Diff ¶
func (e *Executor) Diff(ctx context.Context, opts *atmosgit.DiffOptions) (*atmosgit.DiffResult, error)
Diff delegates to the provider.
func (*Executor) Status ¶
func (e *Executor) Status(ctx context.Context, opts *atmosgit.StatusOptions) (*atmosgit.StatusResult, error)
Status delegates to the provider and prints the result.
type GitCommandProvider ¶
type GitCommandProvider struct{}
GitCommandProvider implements the CommandProvider interface for `atmos git`.
func (*GitCommandProvider) GetAliases ¶
func (g *GitCommandProvider) GetAliases() []internal.CommandAlias
GetAliases returns command aliases for git subcommands. Registers "atmos list git-repositories" as an alias for "atmos git list", following the same pattern as "atmos workflow list" ↔ "atmos list workflows".
func (*GitCommandProvider) GetCommand ¶
func (g *GitCommandProvider) GetCommand() *cobra.Command
GetCommand returns the git parent command (with all subcommands attached).
func (*GitCommandProvider) GetCompatibilityFlags ¶
func (g *GitCommandProvider) GetCompatibilityFlags() map[string]compat.CompatibilityFlag
GetCompatibilityFlags returns compatibility flags for this command. The git command group has no compatibility flags.
func (*GitCommandProvider) GetFlagsBuilder ¶
func (g *GitCommandProvider) GetFlagsBuilder() flags.Builder
GetFlagsBuilder returns the flags builder for this command. The parent git command has no flags of its own.
func (*GitCommandProvider) GetGroup ¶
func (g *GitCommandProvider) GetGroup() string
GetGroup returns the command group for help organization.
func (*GitCommandProvider) GetName ¶
func (g *GitCommandProvider) GetName() string
GetName returns the command name.
func (*GitCommandProvider) GetPositionalArgsBuilder ¶
func (g *GitCommandProvider) GetPositionalArgsBuilder() *flags.PositionalArgsBuilder
GetPositionalArgsBuilder returns the positional args builder for this command. The parent git command has no positional arguments.
func (*GitCommandProvider) IsExperimental ¶
func (g *GitCommandProvider) IsExperimental() bool
IsExperimental returns whether this command is experimental.
type GitListOptions ¶
type GitListOptions struct {
global.Flags
Columns []string
Format string
Delimiter string
CheckStatus bool
}
GitListOptions holds parsed options for `atmos git list`.
type ParsedURI ¶
type ParsedURI struct {
// URI is the clean remote URI (without git:: prefix and without query params).
URI string
// Branch is the parsed branch/ref from ?ref=, or empty.
Branch string
// Depth is the parsed clone depth from ?depth=, or 0 for full history.
Depth int
// RepoName is the last path component without .git suffix, used as the
// clone directory name for ad hoc URI clones.
RepoName string
}
ParsedURI is the result of parsing a clone URI argument.
func ParseCloneURI ¶
ParseCloneURI parses a clone URI argument, stripping the git:: prefix and extracting ?ref= and ?depth= query parameters (precedence: flags > query params > config). Unknown query parameters return an error.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package hooks implements the `atmos git hooks` command group: thin cobra wiring over pkg/git/hooks, which owns the shim install/run/uninstall logic.
|
Package hooks implements the `atmos git hooks` command group: thin cobra wiring over pkg/git/hooks, which owns the shim install/run/uninstall logic. |