Documentation ¶
Overview ¶
Package project implements operations on project and repository.
Index ¶
- Constants
- func IndexByName(projects []*Project) map[string][]*Project
- func IndexByPath(projects []*Project) map[string]*Project
- func IsClean(dir string) (bool, error)
- func MatchGroups(match, groups string) bool
- type Branch
- type CheckoutOptions
- type CmdExecResult
- type ConfigWithDefault
- type FetchOptions
- type ManifestProject
- func (v ManifestProject) ArchiveEnabled() bool
- func (v ManifestProject) DissociateEnabled() bool
- func (v ManifestProject) MirrorEnabled() bool
- func (v *ManifestProject) ReadSettings() *RepoSettings
- func (v *ManifestProject) SaveSettings(s *RepoSettings) error
- func (v *ManifestProject) SetRevision(rev string)
- func (v ManifestProject) SubmoduleEnabled() bool
- type PatchSet
- type Project
- func (v *Project) AddRemote(mr *manifest.Remote, noCache bool) *Remote
- func (v Project) CheckoutRevision(args ...string) error
- func (v Project) CherryPick(commits ...string) error
- func (v Project) CleanPublishedCache() error
- func (v *Project) ConfigWithDefault() ConfigWithDefault
- func (v Project) CopyAndLinkFiles() error
- func (v Project) CopyFile(src, dest string) error
- func (v Project) DetachHead() error
- func (v Project) DownloadPatchSet(remoteName string, reviewID, patchID int) (*PatchSet, error)
- func (v Project) ExecuteCommand(args ...string) *CmdExecResult
- func (v Project) Exists() bool
- func (v Project) FastForward(args ...string) error
- func (v *Project) GetBranchRemote(branch string, useOrigin bool) *Remote
- func (v *Project) GetDefaultRemote(useOrigin bool) *Remote
- func (v *Project) GetRemotePushNameURL(remote *Remote) (string, string)
- func (v *Project) GetRemotePushURL(remote *Remote) string
- func (v *Project) GetRemoteURL() (string, error)
- func (v Project) GetSubmoduleProjects() []*Project
- func (v *Project) GetUploadableBranch(branch string, remote *Remote, remoteBranch string) *ReviewableBranch
- func (v *Project) GetUploadableBranchForChange(branch string, remote *Remote, codeReview *config.CodeReview) *ReviewableBranch
- func (v *Project) GetUploadableBranches(branch string) []ReviewableBranch
- func (v *Project) GitInit() error
- func (v *Project) GitRepository() (*git.Repository, error)
- func (v *Project) GitWorktree() (*git.Worktree, error)
- func (v Project) HardReset(args ...string) error
- func (v *Project) HeadBranch() Branch
- func (v Project) InstallGerritHooks() error
- func (v Project) IsClean() bool
- func (v Project) IsMirror() bool
- func (v Project) IsRepoInitialized() bool
- func (v Project) LinkFile(src, dest string) error
- func (v *Project) LoadRemotes(remoteMap *RemoteMap, noCache bool)
- func (v *Project) ManifestConfig() goconfig.GitConfig
- func (v Project) ManifestURL() string
- func (v Project) MatchGroups(expect string) bool
- func (v *Project) PrepareWorkdir() error
- func (v Project) PublishedReference(branch string) string
- func (v Project) PublishedRevision(branch string) string
- func (v Project) Rebase(args ...string) error
- func (v Project) RemoteTracking(rev string) string
- func (v Project) ResolveRemoteTracking(rev string) (string, error)
- func (v Project) ResolveRevision(rev string) (string, error)
- func (v Project) Revert(commit string) error
- func (v *Project) SetGitRemoteURL(remoteURL string) error
- func (v *Project) SetManifestURL(manifestURL string) error
- func (v Project) StartBranch(branch, track string, force bool) error
- func (v Project) Status() *CmdExecResult
- func (v Project) SubmoduleUpdate(args ...string) error
- func (v Project) SyncLocalHalf(o *CheckoutOptions) error
- func (v *Project) SyncNetworkHalf(o *FetchOptions) error
- func (v Project) TopDir() string
- func (v Project) UpdateBranchTracking(branch, remote, track string)
- func (v Project) UserEmail() string
- type Reference
- type Remote
- type RemoteMap
- type RemoteTrack
- type RepoSettings
- type Repository
- func (v Repository) CommonDir() string
- func (v Repository) Config() goconfig.GitConfig
- func (v Repository) DefaultTrackingBranch() string
- func (v Repository) DeleteBranch(branch string) error
- func (v Repository) Exists() bool
- func (v *Repository) Fetch(remote string, o *FetchOptions) error
- func (v Repository) GetHead() string
- func (v Repository) GitConfigRemoteURL(name string) string
- func (v Repository) HasAlternates() bool
- func (v Repository) Heads() []Branch
- func (v *Repository) Init(remoteName, remoteURL, referenceGitDir string) error
- func (v *Repository) InitByLink(remoteName, remoteURL string, repo *Repository) error
- func (v Repository) IsRebaseInProgress() bool
- func (v Repository) LastModified(revision string) string
- func (v Repository) LocalTrackBranch(branch string) string
- func (v Repository) ObjectsRepository() *Repository
- func (v Repository) Prompt() string
- func (v Repository) Raw() *git.Repository
- func (v Repository) RemoteMatchingBranch(remote, branch string) string
- func (v Repository) RepoDir() string
- func (v Repository) RevisionIsValid(revision string) bool
- func (v Repository) Revlist(args ...string) ([]string, error)
- func (v Repository) SSHInfoCacheFile() string
- func (v *Repository) SaveConfig(cfg goconfig.GitConfig) error
- func (v Repository) TrackBranch(branch string) string
- func (v Repository) TrackRemote(branch string) string
- func (v Repository) UpdateRef(refname, base, reason string) error
- type ReviewableBranch
- type Tree
Constants ¶
const ( // GIT is git command name GIT = config.GIT )
Variables ¶
This section is empty.
Functions ¶
func IndexByName ¶
IndexByName returns a map using project name as index to group projects.
func IndexByPath ¶
IndexByPath returns a map using project path as index to group projects.
func MatchGroups ¶
MatchGroups checks if project has matched groups.
Types ¶
type CheckoutOptions ¶
type CheckoutOptions struct { RepoSettings Quiet bool DetachHead bool IsManifest bool CheckPublished bool }
CheckoutOptions is options for git fetch.
type CmdExecResult ¶
CmdExecResult holds command output, and error.
func NewCmdExecResult ¶
func NewCmdExecResult(p *Project) *CmdExecResult
NewCmdExecResult creates new instance of CmdExecResult.
func (*CmdExecResult) Empty ¶
func (v *CmdExecResult) Empty() bool
Empty indicates output and error output is empty.
func (*CmdExecResult) Stderr ¶
func (v *CmdExecResult) Stderr() string
Stderr is command output on stderr.
func (*CmdExecResult) Stdout ¶
func (v *CmdExecResult) Stdout() string
Stdout is command output on stdout.
func (CmdExecResult) Success ¶
func (v CmdExecResult) Success() bool
Success indicates command runs successfully or not.
type ConfigWithDefault ¶
type ConfigWithDefault struct {
Project *Project
}
ConfigWithDefault checks git config from both project and manifest project.
func (ConfigWithDefault) Get ¶
func (v ConfigWithDefault) Get(key string) string
Get returns config of both project and manifest project.
func (ConfigWithDefault) GetBool ¶
func (v ConfigWithDefault) GetBool(key string, defaultVal bool) bool
GetBool returns boolean config of both project and manifest project.
func (ConfigWithDefault) HasKey ¶
func (v ConfigWithDefault) HasKey(key string) bool
HasKey checks whether key is set in both project and manifest project.
type FetchOptions ¶
type FetchOptions struct { RepoSettings Quiet bool IsNew bool CurrentBranchOnly bool CloneBundle bool ForceSync bool NoTags bool OptimizedFetch bool Prune bool }
FetchOptions is options for git fetch.
type ManifestProject ¶
type ManifestProject struct {
Project
}
ManifestProject is a special type of project.
func NewManifestProject ¶
func NewManifestProject(topDir, mURL string) *ManifestProject
NewManifestProject returns a manifest project: a worktree with a seperate repository.
func (ManifestProject) ArchiveEnabled ¶
func (v ManifestProject) ArchiveEnabled() bool
ArchiveEnabled checks if config variable repo.archive is true.
func (ManifestProject) DissociateEnabled ¶
func (v ManifestProject) DissociateEnabled() bool
DissociateEnabled checks if config variable repo.dissociate is true.
func (ManifestProject) MirrorEnabled ¶
func (v ManifestProject) MirrorEnabled() bool
MirrorEnabled checks if config variable repo.mirror is true.
func (*ManifestProject) ReadSettings ¶
func (v *ManifestProject) ReadSettings() *RepoSettings
ReadSettings reads settings from manifest project.
func (*ManifestProject) SaveSettings ¶
func (v *ManifestProject) SaveSettings(s *RepoSettings) error
SaveSettings saves settings to manifest project.
func (*ManifestProject) SetRevision ¶
func (v *ManifestProject) SetRevision(rev string)
SetRevision changes project default branch.
func (ManifestProject) SubmoduleEnabled ¶
func (v ManifestProject) SubmoduleEnabled() bool
SubmoduleEnabled checks if config variable repo.submodules is true.
type Project ¶
type Project struct { Repository WorkDir string }
Project inherits manifest's Project and has two related repositories.
func NewMirrorProject ¶
NewMirrorProject returns a mirror project.
func NewProject ¶
NewProject returns a project: project worktree with a bared repo and a seperate repository.
func (Project) CheckoutRevision ¶
CheckoutRevision runs git checkout.
func (Project) CherryPick ¶
CherryPick runs cherry-pick on commits.
func (Project) CleanPublishedCache ¶
CleanPublishedCache removes obsolete refs/published/ references.
func (*Project) ConfigWithDefault ¶
func (v *Project) ConfigWithDefault() ConfigWithDefault
ConfigWithDefault returns git config file parser.
func (Project) CopyAndLinkFiles ¶
CopyAndLinkFiles copies and links files.
func (Project) DownloadPatchSet ¶
DownloadPatchSet fetches code review and return the downloaded PatchSet.
func (Project) ExecuteCommand ¶
func (v Project) ExecuteCommand(args ...string) *CmdExecResult
ExecuteCommand runs command.
func (Project) FastForward ¶
FastForward runs git merge
func (*Project) GetBranchRemote ¶
GetBranchRemote gets default remote for branch of the project.
func (*Project) GetDefaultRemote ¶
GetDefaultRemote gets default remote for project.
func (*Project) GetRemotePushNameURL ¶
GetRemotePushNameURL returns remote name and URL for push.
func (*Project) GetRemotePushURL ¶
GetRemotePushURL returns URL for push.
func (*Project) GetRemoteURL ¶
GetRemoteURL returns new remote url user provided or from manifest repo url
func (Project) GetSubmoduleProjects ¶
GetSubmoduleProjects returns submodule projects.
func (*Project) GetUploadableBranch ¶
func (v *Project) GetUploadableBranch(branch string, remote *Remote, remoteBranch string) *ReviewableBranch
GetUploadableBranch returns branch which has commits ready for upload.
func (*Project) GetUploadableBranchForChange ¶
func (v *Project) GetUploadableBranchForChange(branch string, remote *Remote, codeReview *config.CodeReview) *ReviewableBranch
GetUploadableBranchForChange returns branch which has commits ready for upload.
func (*Project) GetUploadableBranches ¶
func (v *Project) GetUploadableBranches(branch string) []ReviewableBranch
GetUploadableBranches returns branches which has commits ready for upload.
func (*Project) GitRepository ¶
GitRepository returns go-git's repository object for project worktree.
func (*Project) GitWorktree ¶
GitWorktree returns go-git's worktree oject.
func (*Project) HeadBranch ¶
HeadBranch returns current branch (name and oid) of project's workdir.
func (Project) InstallGerritHooks ¶
InstallGerritHooks installs gerrit hooks if remote of current project is gerrit.
func (Project) IsClean ¶
IsClean indicates git worktree is clean. TODO: cannot use go-git, because it is incompatible with git new index format.
func (Project) IsRepoInitialized ¶
IsRepoInitialized indicates repository is initialized or not.
func (*Project) LoadRemotes ¶
LoadRemotes reads git config to load remotes.
func (*Project) ManifestConfig ¶
ManifestConfig returns git config of manifest project.
func (Project) ManifestURL ¶
ManifestURL returns manifest URL.
func (Project) MatchGroups ¶
MatchGroups indecates if project belongs to special groups.
func (*Project) PrepareWorkdir ¶
PrepareWorkdir setup workdir layout: .git is gitdir file points to repository.
func (Project) PublishedReference ¶
PublishedReference forms published reference for specific branch.
func (Project) PublishedRevision ¶
PublishedRevision resolves published reference to revision id.
func (Project) RemoteTracking ¶
RemoteTracking returns name of current remote tracking branch.
func (Project) ResolveRemoteTracking ¶
ResolveRemoteTracking returns revision id of current remote tracking branch.
func (Project) ResolveRevision ¶
ResolveRevision checks and resolves reference to revid.
func (*Project) SetGitRemoteURL ¶
SetGitRemoteURL sets remote.<remote>.url setting in git config.
func (*Project) SetManifestURL ¶
SetManifestURL sets manifestURL and change remote url if is MetaProject.
func (Project) StartBranch ¶
StartBranch creates new branch.
func (Project) Status ¶
func (v Project) Status() *CmdExecResult
Status shows combined output of git status for project.
func (Project) SubmoduleUpdate ¶
SubmoduleUpdate runs git submodule update.
func (Project) SyncLocalHalf ¶
func (v Project) SyncLocalHalf(o *CheckoutOptions) error
SyncLocalHalf will checkout/rebase branch.
func (*Project) SyncNetworkHalf ¶
func (v *Project) SyncNetworkHalf(o *FetchOptions) error
SyncNetworkHalf starts to fetch from remote repository.
func (Project) UpdateBranchTracking ¶
UpdateBranchTracking updates branch tracking info.
type Remote ¶
type Remote struct { manifest.Remote helper.ProtoHelper // contains filtered or unexported fields }
Remote wraps manifest remote.
func NewRemote ¶
func NewRemote(r *manifest.Remote, h helper.ProtoHelper) *Remote
NewRemote return new remote object.
func (*Remote) Initialized ¶
Initialized indicates whether Remote is initialized.
func (*Remote) ProtoHelperReady ¶
ProtoHelperReady indicates ProtoHelper is ready for remote.
type RemoteMap ¶
type RemoteMap struct {
// contains filtered or unexported fields
}
RemoteMap holds all remotes of a project.
func (*RemoteMap) SetDefault ¶
SetDefault sets default remote name.
type RemoteTrack ¶
RemoteTrack holds info of remote tracking branch
type RepoSettings ¶
type RepoSettings struct { TopDir string ManifestURL string ManifestName string Groups string Reference string Revision string Depth int Archive bool Dissociate bool Mirror bool Submodules bool Config goconfig.GitConfig }
RepoSettings holds settings in manifest project.
type Repository ¶
type Repository struct { manifest.Project DotGit string // Path to worktree/.git GitDir string // Project's bare repository inside .repo ObjectsGitDir string // Several projects may share the same repository // If project.Revision is a tag or sha, save manifest.DefaultRevision here ManifestDefaultRevision string IsBare bool RemoteURL string Remotes *RemoteMap Reference string // Alternate repository Settings *RepoSettings // contains filtered or unexported fields }
Repository has repository related operations.
func (Repository) CommonDir ¶
func (v Repository) CommonDir() string
CommonDir returns commondir of a repository.
func (Repository) Config ¶
func (v Repository) Config() goconfig.GitConfig
Config returns git config file parser.
func (Repository) DefaultTrackingBranch ¶ added in v0.7.7
func (v Repository) DefaultTrackingBranch() string
DefaultTrackingBranch is defined in Manifest file, and is used as default tracking branch for current project
func (Repository) DeleteBranch ¶
func (v Repository) DeleteBranch(branch string) error
DeleteBranch deletes a branch.
func (*Repository) Fetch ¶
func (v *Repository) Fetch(remote string, o *FetchOptions) error
Fetch runs git-fetch on repository.
func (Repository) GetHead ¶
func (v Repository) GetHead() string
GetHead returns current branch name
func (Repository) GitConfigRemoteURL ¶
func (v Repository) GitConfigRemoteURL(name string) string
GitConfigRemoteURL returns remote url in git config.
func (Repository) HasAlternates ¶
func (v Repository) HasAlternates() bool
HasAlternates checks if repository has defined alternates.
func (Repository) Heads ¶
func (v Repository) Heads() []Branch
Heads returns branches of repository.
func (*Repository) Init ¶
func (v *Repository) Init(remoteName, remoteURL, referenceGitDir string) error
Init runs git-init on repository.
func (*Repository) InitByLink ¶
func (v *Repository) InitByLink(remoteName, remoteURL string, repo *Repository) error
InitByLink starts to init repository by attaching other repository.
func (Repository) IsRebaseInProgress ¶
func (v Repository) IsRebaseInProgress() bool
IsRebaseInProgress checks whether is in middle of a rebase.
func (Repository) LastModified ¶
func (v Repository) LastModified(revision string) string
LastModified gets last modified time of a revision
func (Repository) LocalTrackBranch ¶
func (v Repository) LocalTrackBranch(branch string) string
LocalTrackBranch gets local tracking remote branch
func (Repository) ObjectsRepository ¶
func (v Repository) ObjectsRepository() *Repository
ObjectsRepository returns repository which ObjectsGitDir points to
func (Repository) Prompt ¶
func (v Repository) Prompt() string
Prompt will show project path as prompt.
func (Repository) Raw ¶
func (v Repository) Raw() *git.Repository
Raw returns go-git repository object.
func (Repository) RemoteMatchingBranch ¶
func (v Repository) RemoteMatchingBranch(remote, branch string) string
RemoteMatchingBranch gets local tracking branch name of a match remote branch
func (Repository) RepoDir ¶
func (v Repository) RepoDir() string
RepoDir returns git dir of the repository
func (Repository) RevisionIsValid ¶
func (v Repository) RevisionIsValid(revision string) bool
RevisionIsValid returns true if revision can be resolved
func (Repository) Revlist ¶
func (v Repository) Revlist(args ...string) ([]string, error)
Revlist works like rev-list. TODO: Hack go-git plumbing/revlist package to replace git exec
func (Repository) SSHInfoCacheFile ¶
func (v Repository) SSHInfoCacheFile() string
SSHInfoCacheFile is filename used to cache proto settings.
func (*Repository) SaveConfig ¶
func (v *Repository) SaveConfig(cfg goconfig.GitConfig) error
SaveConfig will save config to git config file.
func (Repository) TrackBranch ¶
func (v Repository) TrackBranch(branch string) string
TrackBranch gets remote tracking branch.
func (Repository) TrackRemote ¶
func (v Repository) TrackRemote(branch string) string
TrackRemote gets the remote name what current branch is tracking.
func (Repository) UpdateRef ¶
func (v Repository) UpdateRef(refname, base, reason string) error
UpdateRef creates new reference.
type ReviewableBranch ¶
type ReviewableBranch struct { Project *Project Branch Branch DestBranch string RemoteTrack RemoteTrack Uploaded bool Error error CodeReview config.CodeReview // Push to update specific code review, only available for single repository mode. Remote *Remote // contains filtered or unexported fields }
ReviewableBranch holds branch of project ready for upload.
func (ReviewableBranch) AppendReviewers ¶
func (v ReviewableBranch) AppendReviewers(people [][]string)
AppendReviewers adds reviewers to people.
func (ReviewableBranch) Commits ¶
func (v ReviewableBranch) Commits() []string
Commits contains commits avaiable for review.
func (*ReviewableBranch) IsPublished ¶
func (v *ReviewableBranch) IsPublished() bool
IsPublished indicates a branch has been published.
func (*ReviewableBranch) Published ¶
func (v *ReviewableBranch) Published() *Reference
Published returns published reference.
func (ReviewableBranch) UploadForReview ¶
func (v ReviewableBranch) UploadForReview(o *config.UploadOptions) error
UploadForReview sends review for branch.