Documentation
¶
Overview ¶
注意,这里面的这些方法看不懂作用是什么的,根据方法里面的参数,在某个git管理的项目下执行就能知道效果是什么了
Index ¶
- Constants
- Variables
- func PushError(url string, actual error) error
- type Checkout
- func (c *Checkout) ChangedFiles(ctx context.Context, ref string) ([]string, []string, error)
- func (c *Checkout) Clean()
- func (c *Checkout) CommitAndPush(ctx context.Context, commitAction CommitAction, note interface{}) error
- func (c *Checkout) DevOpsSyncRevision(ctx context.Context) (string, error)
- func (c *Checkout) Dir() string
- func (c *Checkout) FileLastCommit(ctx context.Context, file string) (string, error)
- func (c *Checkout) GetNote(ctx context.Context, rev string, note interface{}) (bool, error)
- func (c *Checkout) HeadRevision(ctx context.Context) (string, error)
- func (c *Checkout) ManifestDir() string
- func (c *Checkout) MoveSyncTagAndPush(ctx context.Context, ref, msg string) error
- func (c *Checkout) NoteRevList(ctx context.Context) (map[string]struct{}, error)
- func (c *Checkout) SyncRevision(ctx context.Context) (string, error)
- type Commit
- type CommitAction
- type Config
- type GitRepoStatus
- type Option
- type PollInterval
- type Remote
- type Repo
- func (r *Repo) Clean()
- func (r *Repo) Clone(ctx context.Context, conf Config) (*Checkout, error)
- func (r *Repo) CommitsBefore(ctx context.Context, ref, path string) ([]Commit, error)
- func (r *Repo) CommitsBetween(ctx context.Context, ref1, ref2, path string) ([]Commit, error)
- func (r *Repo) Dir() string
- func (r *Repo) Notify()
- func (r *Repo) Origin() Remote
- func (r *Repo) Refresh(ctx context.Context) error
- func (r *Repo) Revision(ctx context.Context, ref string) (string, error)
- func (r *Repo) Start(shutdown <-chan struct{}, repoRefreshShutdown chan struct{}, ...) error
- func (r *Repo) Status() (GitRepoStatus, error)
Constants ¶
const ( DefaultCloneTimeout = 2 * time.Minute CheckPushTag = "choerodon-write-check" MirrorRepoPrefix = "choerodon-git-clone" WorkingRepoPrefix = "choerodon-working" )
Variables ¶
Functions ¶
Types ¶
type Checkout ¶
type Checkout struct {
// contains filtered or unexported fields
}
Checkout is a local working clone of the remote repo. It is intended to be used for one-off "transactions", e.g,. committing changes then pushing upstream. It has no locking.
func (*Checkout) ChangedFiles ¶
ChangedFiles does a git diff listing changed files
func (*Checkout) CommitAndPush ¶
func (c *Checkout) CommitAndPush(ctx context.Context, commitAction CommitAction, note interface{}) error
CommitAndPush commits changes made in this checkout, along with any extra data as a note, and pushes the commit and note to the remote repo.
func (*Checkout) DevOpsSyncRevision ¶
func (*Checkout) FileLastCommit ¶
func (*Checkout) GetNote ¶
GetNote gets a note for the revision specified, or nil if there is no such note.
func (*Checkout) HeadRevision ¶
func (*Checkout) ManifestDir ¶
ManifestDir returns the path to the manifests files
func (*Checkout) MoveSyncTagAndPush ¶
func (*Checkout) NoteRevList ¶
type CommitAction ¶
CommitAction - struct holding commit information
type Config ¶
type Config struct { Branch string // branch we're syncing to Path string // path within the repo containing files we care about SyncTag string NotesRef string UserName string UserEmail string SetAuthor bool SkipMessage string DevOpsTag string GitUrl string GitPollInterval time.Duration }
Config holds some values we use when working in the working clone of a repo.
type GitRepoStatus ¶
type GitRepoStatus string
GitRepoStatus represents the progress made synchronising with a git repo. These are given below in expected order, but the status may go backwards if e.g., a deploy key is deleted.
const ( RepoNoConfig GitRepoStatus = "unconfigured" // configuration is empty RepoNew GitRepoStatus = "new" // no attempt made to clone it yet RepoCloned GitRepoStatus = "cloned" // has been read (cloned); no attempt made to write RepoReady GitRepoStatus = "ready" // has been written to, so ready to sync )
type PollInterval ¶
type Remote ¶
type Remote struct {
URL string // clone from here
}
Remote points at a git repo somewhere.
type Repo ¶
type Repo struct { Env string C chan struct{} RefreshChan chan struct{} SyncChan chan struct{} // contains filtered or unexported fields }
func (*Repo) Clean ¶
func (r *Repo) Clean()
Clean removes the mirrored repo. Syncing may continue with a new directory, so you may need to stop that first.
func (*Repo) CommitsBefore ¶
func (*Repo) CommitsBetween ¶
func (*Repo) Dir ¶
Dir returns the local directory into which the repo has been cloned, if it has been cloned.
func (*Repo) Notify ¶
func (r *Repo) Notify()
Notify tells the repo that it should fetch from the origin as soon as possible. It does not block.
func (*Repo) Start ¶
func (r *Repo) Start(shutdown <-chan struct{}, repoRefreshShutdown chan struct{}, done *sync.WaitGroup) error
Start begins synchronising the repo by cloning it, then fetching the required tags and so on.
func (*Repo) Status ¶
func (r *Repo) Status() (GitRepoStatus, error)
Status reports that readiness status of this Git repo: whether it has been cloned, whether it is writable, and if not, the error stopping it getting to the next state.