gitget

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package gitget implements business logic of the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecomposeGitURL

func DecomposeGitURL(gitURL string) (string, string, string)

func GenerateGitfileConfig

func GenerateGitfileConfig(
	cfgFile string,
	ignoreFiles []string,
	gitCloudProviderRootURL string,
	gitCloudProvider string,
	targetClonePath string,
	configGenParams ConfigGenParamsStruct,
)

GenerateGitfileConfig - Entry point for Gitfile generation logic

func GetRepositories

func GetRepositories(
	cfgFiles []string,
	ignoreFiles []string,
	concurrencyLevel int,
	stickToRef bool,
	shallow bool,
	defaultTrunkBranch string,
	status bool,
)

GetRepositories - gets the list of repositories

func MirrorRepositories

func MirrorRepositories(
	cfgFiles []string,
	ignoreFiles []string,
	concurrencyLevel int,
	pushMirror bool,
	mirrorRootURL string,
	mirrorProviderName string,
	mirrorVisibilityModeName string,
	mirrorBitbucketProjectName string,
)

MirrorRepositories - Entry point for mirror creation/update logic

func PathExists

func PathExists(path string) (bool, os.FileInfo)

PathExists returns `true` if given `path` passed as sting exists, otherwise returns false.

Types

type ConfigGenParamsStruct

type ConfigGenParamsStruct struct {
	// ssh or https in output file
	GitSchema string

	// Gitlab specific vars
	GitlabOwned          bool
	GitlabVisibility     string
	GitlabMinAccessLevel string

	// GitHub specific vars
	GithubVisibility  string
	GithubAffiliation string

	// Bitbucket specific vars
	/*
		MAYBE: implement for bitbucket to allow subset of repositories
		BitbucketDivision string
	*/
	BitbucketRole string
}

ConfigGenParamsStruct - data structure to store parameters passed via cli flags

type Repo

type Repo struct {
	URL      string   `yaml:"url"`                // git url of the remote repository
	Path     string   `yaml:"path,omitempty"`     // to clone repository to
	AltName  string   `yaml:"altname,omitempty"`  // when cloned, repository will have different name from remote
	Ref      string   `yaml:"ref,omitempty"`      // branch to clone (normally trunk branch name, but git sha or git tag can be also specified)
	Symlinks []string `yaml:"symlinks,omitempty"` // paths where to create symlinks to the repository clone
	// contains filtered or unexported fields
}

Repo structure defines information about single git repository.

func GetIgnoreRepoList

func GetIgnoreRepoList(ignoreFiles []string) []Repo

GetIgnoreRepoList - tries to read ignore files from the list, if these are existing and returns list of repositories

func (*Repo) ChoosePathPrefix

func (repo *Repo) ChoosePathPrefix(pathPrefix string) string

func (*Repo) Clone

func (repo *Repo) Clone() bool

Clone runs `git clone --branch` command.

func (*Repo) CloneMirror

func (repo *Repo) CloneMirror() bool

CloneMirror runs `git clone --mirror` command.

func (repo *Repo) CreateSymlink(symlink string)

func (*Repo) EnsureBitbucketMirrorExists

func (repo *Repo) EnsureBitbucketMirrorExists()

EnsureBitbucketMirrorExists - creates mirror repository if it does not exist

func (*Repo) EnsureGithubMirrorExists

func (repo *Repo) EnsureGithubMirrorExists()

EnsureGithubMirrorExists - creates mirror repository if it does not exist

func (*Repo) EnsureGitlabMirrorExists

func (repo *Repo) EnsureGitlabMirrorExists()

func (*Repo) EnsureMirrorExists

func (repo *Repo) EnsureMirrorExists()

func (*Repo) EnsurePathExists

func (repo *Repo) EnsurePathExists(pathPrefix string)

func (*Repo) GetCurrentBranch

func (repo *Repo) GetCurrentBranch() string

func (*Repo) GetRepoLocalName

func (repo *Repo) GetRepoLocalName() string

func (*Repo) GitCheckout

func (repo *Repo) GitCheckout(branch string) bool

func (*Repo) GitPull

func (repo *Repo) GitPull()

func (*Repo) GitStashPop

func (repo *Repo) GitStashPop() bool

func (*Repo) GitStashSave

func (repo *Repo) GitStashSave() bool

func (*Repo) IsClean

func (repo *Repo) IsClean() bool

func (*Repo) IsCurrentBranchRef

func (repo *Repo) IsCurrentBranchRef() bool

func (*Repo) IsRefBranch

func (repo *Repo) IsRefBranch() bool

IsRefBranch returns true if

func (*Repo) IsRefTag

func (repo *Repo) IsRefTag() bool

func (*Repo) PrepareForGet

func (repo *Repo) PrepareForGet()

PrepareForGet performs checks for repository as well as constructs extra information and sets repository data structure values.

func (*Repo) PrepareForMirror

func (repo *Repo) PrepareForMirror(pathPrefix string, mirrorRootURL string)

PrepareForMirror - set repository structure fields for mirror operation

func (*Repo) ProcessRepoBasedOnCleaness

func (repo *Repo) ProcessRepoBasedOnCleaness()

func (*Repo) ProcessRepoBasedOnCurrentBranch

func (repo *Repo) ProcessRepoBasedOnCurrentBranch()
func (repo *Repo) ProcessSymlinks()

func (*Repo) PushMirror

func (repo *Repo) PushMirror() bool

PushMirror runs `git push --mirror` command.

func (*Repo) RemoveTargetDir

func (repo *Repo) RemoveTargetDir(dotGit bool)

func (*Repo) RepoPathExists

func (repo *Repo) RepoPathExists() bool

func (*Repo) SetDefaultRef

func (repo *Repo) SetDefaultRef()

SetDefaultRef sets in place default name of the ref to master (by default) or user passed via flag if not specified

func (*Repo) SetMirrorURL

func (repo *Repo) SetMirrorURL(mirrorRootURL string)

func (*Repo) SetRepoFullPath

func (repo *Repo) SetRepoFullPath()

func (*Repo) SetRepoLocalName

func (repo *Repo) SetRepoLocalName()

SetRepoLocalName sets struct AltName to short name obtained from repository uri

func (*Repo) SetSha

func (repo *Repo) SetSha()

SetSha generates and sets `sha` of the data structure to use in log messages.

func (*Repo) SetShellRunner added in v0.0.14

func (repo *Repo) SetShellRunner(exe exec.ShellRunnerI)

func (*Repo) SetTempRepoPathForMirror

func (repo *Repo) SetTempRepoPathForMirror(pathPrefix string)

func (*Repo) ShallowClone

func (repo *Repo) ShallowClone() bool

ShallowClone runs `git clone --depth 1 --branch` command.

type RepoI

type RepoI interface {
	Clone() bool
	CreateSymlink(symlink string)
	ChoosePathPrefix(pathPrefix string) string
	EnsurePathExists()
	GetCurrentBranch() string
	GetRepoLocalName() string
	GitCheckout(branch string) bool
	GitPull()
	GitStashPop() bool
	GitStashSave() bool
	IsClean() bool
	IsCurrentBranchRef() bool
	IsRefBranch() bool
	IsRefTag() bool
	PathExists(path string) (bool, os.FileInfo)
	PrepareForGet()
	PrepareForMirror(pathPrefix string, mirrorRootURL string)
	ProcessRepoBasedOnCleaness()
	ProcessRepoBasedOnCurrentBranch()
	ProcessSymlinks()
	RepoPathExists() bool
	SetDefaultRef()
	SetRepoFullPath()
	SetRepoLocalName()
	SetSha()
}

RepoI interface defined for mocking purposes.

type RepoList

type RepoList []Repo

RepoList is a slice of Repo structs

func GetConfigRepoList

func GetConfigRepoList(cfgFiles []string) *RepoList

GetConfigRepoList - tries to read config files from the list, if these are existing and returns list of repositories, if any file is missing - it fails

type RepoStatus

type RepoStatus struct {
	Processed             bool   // by default repository is not processed, and won't be if skipped
	NotOnRefBranch        bool   // repository checked out branch is not trunk but feature branch
	UncommittedChanges    bool   // there are no uncommitted or staged changes in the branch
	OperationErrorMessage string // last operation error message if any
	Error                 bool   // last operation error message if any
}

RepoStatus - data structure to track repository status

Jump to

Keyboard shortcuts

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