cmd

package
v0.0.0-...-cb20eed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package cmd encapsulates the logic for all cli commands

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneAllRepos

func CloneAllRepos(git git.Gitter, cloneTargets []scm.Repo)

CloneAllRepos clones all repos

func CommandFactory

func CommandFactory() map[string]cli.CommandFactory

CommandFactory creates CLI commands

func GetVersion

func GetVersion() string

func InitConfig

func InitConfig()

func PrintConfigs

func PrintConfigs()

PrintConfigs shows the user what is set before cloning

func PrintVersion

func PrintVersion()

Types

type CloneCommand

type CloneCommand struct {
	UI cli.Ui
}

func (*CloneCommand) Help

func (c *CloneCommand) Help() string

func (*CloneCommand) Run

func (c *CloneCommand) Run(args []string) int

func (*CloneCommand) Synopsis

func (c *CloneCommand) Synopsis() string

type CloneFlags

type CloneFlags struct {
	// Global flags (these were on rootCmd in the old cobra version)
	Config string `long:"config" description:"GHORG_CONFIG - Manually set the path to your config file"`
	Color  string `long:"color" description:"GHORG_COLOR - Toggles colorful output, enabled/disabled (default: disabled)"`

	// Path and protocol flags
	Path     string `` /* 153-byte string literal not displayed */
	Protocol string `long:"protocol" description:"GHORG_CLONE_PROTOCOL - Protocol to clone with, ssh or https, (default https)"`

	// Branch and sync flags
	Branch            string `short:"b" long:"branch" description:"GHORG_BRANCH - Branch left checked out for each repo cloned (default master)"`
	SyncDefaultBranch bool   `` /* 190-byte string literal not displayed */

	// Token and auth flags
	Token             string `` /* 197-byte string literal not displayed */
	BitbucketUsername string `long:"bitbucket-username" description:"GHORG_BITBUCKET_USERNAME - Bitbucket only: username associated with the app password"`
	NoToken           bool   `` /* 164-byte string literal not displayed */

	// SCM and clone type flags
	SCMType   string `` /* 132-byte string literal not displayed */
	CloneType string `short:"c" long:"clone-type" description:"GHORG_CLONE_TYPE - Clone target type, user or org (default org)"`
	BaseURL   string `` /* 185-byte string literal not displayed */

	// Filter flags
	SkipArchived                 bool   `long:"skip-archived" description:"GHORG_SKIP_ARCHIVED - Skips archived repos, github/gitlab/gitea only"`
	SkipForks                    bool   `long:"skip-forks" description:"GHORG_SKIP_FORKS - Skips repo if its a fork, github/gitlab/gitea only"`
	Topics                       string `long:"topics" description:"GHORG_TOPICS - Comma separated list of github/gitea topics to filter for"`
	MatchPrefix                  string `long:"match-prefix" description:"GHORG_MATCH_PREFIX - Only clone repos with matching prefix, can be a comma separated list"`
	ExcludeMatchPrefix           string `` /* 144-byte string literal not displayed */
	MatchRegex                   string `long:"match-regex" description:"GHORG_MATCH_REGEX - Only clone repos that match name to regex provided"`
	ExcludeMatchRegex            string `long:"exclude-match-regex" description:"GHORG_EXCLUDE_MATCH_REGEX - Exclude cloning repos that match name to regex provided"`
	GitlabGroupExcludeMatchRegex string `` /* 158-byte string literal not displayed */
	GhorgIgnorePath              string `` /* 147-byte string literal not displayed */
	GhorgOnlyPath                string `` /* 139-byte string literal not displayed */
	TargetReposPath              string `` /* 154-byte string literal not displayed */

	// Clone behavior flags
	NoClean                 bool `long:"no-clean" description:"GHORG_NO_CLEAN - Only clones new repos and does not perform a git clean on existing repos"`
	Prune                   bool `` /* 354-byte string literal not displayed */
	PruneNoConfirm          bool `long:"prune-no-confirm" description:"GHORG_PRUNE_NO_CONFIRM - Don't prompt on every prune candidate, just delete"`
	PruneUntouched          bool `` /* 152-byte string literal not displayed */
	PruneUntouchedNoConfirm bool `` /* 160-byte string literal not displayed */
	FetchAll                bool `long:"fetch-all" description:"GHORG_FETCH_ALL - Fetches all remote branches for each repo by running a git fetch --all"`
	DryRun                  bool `long:"dry-run" description:"GHORG_DRY_RUN - Perform a dry run of the clone; fetches repos but does not clone them"`
	Backup                  bool `long:"backup" description:"GHORG_BACKUP - Backup mode, clone as mirror, no working copy (ignores branch parameter)"`
	IncludeSubmodules       bool `long:"include-submodules" description:"GHORG_INCLUDE_SUBMODULES - Include submodules in all clone and pull operations"`

	// Additional content flags
	CloneWiki     bool `long:"clone-wiki" description:"GHORG_CLONE_WIKI - Additionally clone the wiki page for repo"`
	CloneSnippets bool `long:"clone-snippets" description:"GHORG_CLONE_SNIPPETS - Additionally clone all snippets, gitlab only"`

	// Insecure client flags
	InsecureGitlabClient    bool `` /* 136-byte string literal not displayed */
	InsecureGiteaClient     bool `` /* 126-byte string literal not displayed */
	InsecureBitbucketClient bool `` /* 145-byte string literal not displayed */
	InsecureSourcehutClient bool `` /* 138-byte string literal not displayed */

	// Directory and output flags
	PreserveDir         bool   `` /* 220-byte string literal not displayed */
	OutputDir           string `` /* 133-byte string literal not displayed */
	NoDirSize           bool   `` /* 211-byte string literal not displayed */
	PreserveSCMHostname bool   `` /* 239-byte string literal not displayed */

	// Performance and control flags
	Concurrency       string `long:"concurrency" description:"GHORG_CONCURRENCY - Max goroutines to spin up while cloning (default 25)"`
	CloneDelaySeconds string `` /* 191-byte string literal not displayed */
	CloneDepth        string `` /* 135-byte string literal not displayed */
	GitFilter         string `` /* 223-byte string literal not displayed */
	GitBackend        string `` /* 143-byte string literal not displayed */

	// Exit code flags
	ExitCodeOnCloneInfos  string `` /* 292-byte string literal not displayed */
	ExitCodeOnCloneIssues string `` /* 295-byte string literal not displayed */

	// Logging and stats flags
	Quiet        bool `long:"quiet" description:"GHORG_QUIET - Emit critical output only"`
	StatsEnabled bool `` /* 278-byte string literal not displayed */

	// GitHub specific flags
	GitHubTokenFromGitHubApp string `` /* 231-byte string literal not displayed */
	GitHubAppPemPath         string `` /* 137-byte string literal not displayed */
	GitHubAppInstallationID  string `` /* 145-byte string literal not displayed */
	GitHubAppID              string `long:"github-app-id" description:"GHORG_GITHUB_APP_ID - GitHub App ID, for authenticating with GitHub App"`
	GitHubFilterLanguage     string `` /* 148-byte string literal not displayed */
	GitHubUserOption         string `` /* 194-byte string literal not displayed */
}

type CloneStats

type CloneStats struct {
	CloneCount           int
	PulledCount          int
	UpdateRemoteCount    int
	NewCommits           int
	UntouchedPrunes      int
	SyncedCount          int
	TotalDurationSeconds int
	CloneInfos           []string
	CloneErrors          []string
}

CloneStats tracks statistics during clone operations

type LsCommand

type LsCommand struct {
	UI cli.Ui
}

func (*LsCommand) Help

func (c *LsCommand) Help() string

func (*LsCommand) Run

func (c *LsCommand) Run(args []string) int

func (*LsCommand) Synopsis

func (c *LsCommand) Synopsis() string

type LsFlags

type LsFlags struct {
	Long  bool `` /* 224-byte string literal not displayed */
	Total bool `` /* 168-byte string literal not displayed */
}

type ReClone

type ReClone struct {
	Cmd            string `yaml:"cmd"`
	Description    string `yaml:"description"`
	PostExecScript string `yaml:"post_exec_script"` // optional
}

type RecloneCommand

type RecloneCommand struct {
	UI cli.Ui
}

func (*RecloneCommand) Help

func (c *RecloneCommand) Help() string

func (*RecloneCommand) Run

func (c *RecloneCommand) Run(args []string) int

func (*RecloneCommand) Synopsis

func (c *RecloneCommand) Synopsis() string

type RecloneCronCommand

type RecloneCronCommand struct {
	UI cli.Ui
}

func (*RecloneCronCommand) Help

func (c *RecloneCronCommand) Help() string

func (*RecloneCronCommand) Run

func (c *RecloneCronCommand) Run(args []string) int

func (*RecloneCronCommand) Synopsis

func (c *RecloneCronCommand) Synopsis() string

type RecloneCronFlags

type RecloneCronFlags struct {
	Minutes string `short:"m" long:"minutes" description:"GHORG_CRON_TIMER_MINUTES - Number of minutes to run the reclone command on a cron"`
}

type RecloneFlags

type RecloneFlags struct {
	ReclonePath   string `` /* 155-byte string literal not displayed */
	Quiet         bool   `long:"quiet" description:"GHORG_RECLONE_QUIET - Quiet logging output"`
	List          bool   `` /* 178-byte string literal not displayed */
	EnvConfigOnly bool   `` /* 141-byte string literal not displayed */
}

type RecloneServerCommand

type RecloneServerCommand struct {
	UI cli.Ui
}

func (*RecloneServerCommand) Help

func (c *RecloneServerCommand) Help() string

func (*RecloneServerCommand) Run

func (c *RecloneServerCommand) Run(args []string) int

func (*RecloneServerCommand) Synopsis

func (c *RecloneServerCommand) Synopsis() string

type RecloneServerFlags

type RecloneServerFlags struct {
	Port string `short:"p" long:"port" description:"GHORG_RECLONE_SERVER_PORT - Specify the port the reclone server will run on"`
}

type RepositoryFilter

type RepositoryFilter struct{}

RepositoryFilter handles filtering of repositories based on various criteria

func NewRepositoryFilter

func NewRepositoryFilter() *RepositoryFilter

NewRepositoryFilter creates a new repository filter

func (*RepositoryFilter) ApplyAllFilters

func (rf *RepositoryFilter) ApplyAllFilters(cloneTargets []scm.Repo) []scm.Repo

ApplyAllFilters applies all configured filters to the repository list

func (*RepositoryFilter) FilterByExcludeMatchPrefix

func (rf *RepositoryFilter) FilterByExcludeMatchPrefix(repos []scm.Repo) []scm.Repo

FilterByExcludeMatchPrefix filters out repositories that start with the specified prefix(es)

func (*RepositoryFilter) FilterByExcludeRegexMatch

func (rf *RepositoryFilter) FilterByExcludeRegexMatch(repos []scm.Repo) []scm.Repo

FilterByExcludeRegexMatch filters out repositories that match the regex pattern

func (*RepositoryFilter) FilterByGhorgignore

func (rf *RepositoryFilter) FilterByGhorgignore(cloneTargets []scm.Repo) []scm.Repo

FilterByGhorgignore filters out repositories listed in the ghorgignore file

func (*RepositoryFilter) FilterByGhorgonly

func (rf *RepositoryFilter) FilterByGhorgonly(cloneTargets []scm.Repo) []scm.Repo

FilterByGhorgonly filters repositories to only include those matching patterns in ghorgonly file

func (*RepositoryFilter) FilterByMatchPrefix

func (rf *RepositoryFilter) FilterByMatchPrefix(repos []scm.Repo) []scm.Repo

FilterByMatchPrefix filters repositories that start with the specified prefix(es)

func (*RepositoryFilter) FilterByRegexMatch

func (rf *RepositoryFilter) FilterByRegexMatch(repos []scm.Repo) []scm.Repo

FilterByRegexMatch filters repositories that match the regex pattern

func (*RepositoryFilter) FilterByTargetReposPath

func (rf *RepositoryFilter) FilterByTargetReposPath(cloneTargets []scm.Repo) []scm.Repo

FilterByTargetReposPath filters repositories based on a file containing target repo names

type RepositoryProcessor

type RepositoryProcessor struct {
	// contains filtered or unexported fields
}

RepositoryProcessor handles the processing of individual repositories

func NewRepositoryProcessor

func NewRepositoryProcessor(git git.Gitter) *RepositoryProcessor

NewRepositoryProcessor creates a new repository processor

func (*RepositoryProcessor) GetStats

func (rp *RepositoryProcessor) GetStats() CloneStats

GetStats returns a copy of the current statistics

func (*RepositoryProcessor) GetUntouchedRepos

func (rp *RepositoryProcessor) GetUntouchedRepos() []string

GetUntouchedRepos returns the list of untouched repositories

func (*RepositoryProcessor) ProcessRepository

func (rp *RepositoryProcessor) ProcessRepository(repo *scm.Repo, repoNameWithCollisions map[string]bool, hasCollisions bool, repoSlug string, index int)

ProcessRepository handles the cloning or updating of a single repository

func (*RepositoryProcessor) SetTotalDuration

func (rp *RepositoryProcessor) SetTotalDuration(durationSeconds int)

SetTotalDuration sets the total duration in seconds for the clone operation

type VersionCommand

type VersionCommand struct {
	UI cli.Ui
}

func (*VersionCommand) Help

func (c *VersionCommand) Help() string

func (*VersionCommand) Run

func (c *VersionCommand) Run(args []string) int

func (*VersionCommand) Synopsis

func (c *VersionCommand) Synopsis() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL