Documentation
¶
Index ¶
- func Clone(dir string, url string) <-chan *CloneUpdate
- func Pull(dir string) <-chan *PullUpdate
- func RepoNameFromUrl(url string) string
- func RevListCommitCount(dir string, fromCommitHash string, toCommitHash string) (int, error)
- func RevParseShowTopLevel(dir string) (string, error)
- type CloneStatus
- type CloneUpdate
- type PullStatus
- type PullUpdate
- type RemoteDetails
- type RepoState
- type Repository
- type StashedChangeset
- type SyncOp
- type SyncOptions
- type SyncStatus
- type SyncUpdate
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
func Clone(dir string, url string) <-chan *CloneUpdate
func Pull ¶
func Pull(dir string) <-chan *PullUpdate
func RepoNameFromUrl ¶
func RevListCommitCount ¶
func RevParseShowTopLevel ¶
RevParseShowTopLevel returns absolute path of top level directory of Git repository. This command will return `/repo` if called from `/repo/subdir` if `/repo` is a Git repository.
Types ¶
type CloneStatus ¶
type CloneStatus string
const ( Cloning CloneStatus = "Cloning" Cloned CloneStatus = "Cloned" BadRedirect CloneStatus = "BadRedirect" CloneRepoNotFound CloneStatus = "RepositoryNotFound" AuthRequired CloneStatus = "AuthRequired" CloneFailed CloneStatus = "CloneFailed" )
type CloneUpdate ¶
type CloneUpdate struct { Status CloneStatus Error string }
type PullStatus ¶
type PullStatus string
const ( Pulling PullStatus = "Pulling" Pulled PullStatus = "Pulled" CouldNotResolveHost PullStatus = "CouldNotResolveHost" ConnectionFailure PullStatus = "ConnectionFailure" OverwritesLocalChanges PullStatus = "OverwritesLocalChanges" MergeConflict PullStatus = "MergeConflict" DetachedHead PullStatus = "DetachedHead" PullRepoNotFound PullStatus = "RepositoryNotFound" RemoteBranchNotFound PullStatus = "RemoteBranchNotFound" UnsetUpstream PullStatus = "UnsetUpstream" UnstagedChanges PullStatus = "UnstagedChanges" NotRepository PullStatus = "NotRepository" PullFailed PullStatus = "PullFailed" )
type PullUpdate ¶
type PullUpdate struct { Status PullStatus Error string PulledCommits int RepoState *RepoState StashList []*StashedChangeset }
type RemoteDetails ¶
type RemoteDetails struct { // Url is the repo's git remote origin. Url string }
RemoteDetails contains git program details for a Repository.
type RepoState ¶
type RepoState struct { BranchesDiverged bool LocalCommits int StagedChanges int UnstagedChanges int UntrackedFiles int }
RepoState holds data from `git status` and is available with git.Status.
type Repository ¶
type Repository struct { // Name is the display name for the Repository, and will be the path from the workspace root to the repository // directory when not explicitly set. Name string // Dir is the absolute path to the repository. Dir string // Git specific config for the repository remote such as RemoteDetails.Url. Git *RemoteDetails }
Repository represents a cloned git repo within a Workspace. Instances for local repositories within a workspace can be instantiated with ScanForRepositories or NewWorkspace.
func NewRepository ¶
func NewRepository(name string, dir string, url string) *Repository
NewRepository creates a Repository.
func ScanForRepositories ¶
func ScanForRepositories(dir string, repoScanDepth int) []*Repository
ScanForRepositories will recursively look for git repositories within the specified directory. repoScanDepth controls how many directories deep the repository scan will recurse.
type StashedChangeset ¶
func StashList ¶
func StashList(dir string) ([]*StashedChangeset, error)
type SyncOptions ¶
type SyncOptions struct {
DetailLocalChanges bool
}
type SyncStatus ¶
type SyncStatus string
const ( SyncSuccess SyncStatus = "SyncSuccess" SyncWarning SyncStatus = "SyncWarning" SyncFailure SyncStatus = "SyncFailure" )
type SyncUpdate ¶
type SyncUpdate struct { Repo string Op SyncOp Message string Error string Status SyncStatus }
type Workspace ¶
type Workspace struct { RootDir string Repositories map[string]*Repository }
Workspace represents a local directory structure of git repositories.
func NewWorkspace ¶
func NewWorkspace(rootDir string, repositories []*Repository, repoScanDepth int) *Workspace
NewWorkspace creates a Workspace at a specified rootDir. Repositories will be configured with the repositories argument and using ScanForRepositories. Use repoScanDepth to specify how deep subdirectories should be scanned for additional repositories. repoScanDepth=0 skips subdirectory scanning.
func (*Workspace) Sync ¶
func (w *Workspace) Sync(syncOptions *SyncOptions) <-chan *SyncUpdate
Sync performs clones and pulls to sync all Repository instances within a Workspace using the git.Clone and git.Pull APIs. A git clone will be performed for any repositories configured within the Workspace that are not present on disk. For Workspace repositories already cloned, the Sync operation will perform a git pull.