Documentation ¶
Overview ¶
Package gitwatch provides a simple tool to first clone a set of git repositories to a local directory and then periodically check them all for any updates.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRepoDirectory ¶
GetRepoDirectory the directory name for a repository.
Types ¶
type Event ¶
type Event struct { URL string Path string Timestamp time.Time // contains filtered or unexported fields }
Event represents an update detected on one of the watched repositories
func GetEventFromRepo ¶
GetEventFromRepo reads a locally cloned git repository and returns an event based on the most recent commit.
type Repository ¶
type Repository struct { URL string // local or remote repository URL to watch Branch string // the name of the branch to use `master` being default Directory string // the directory name to clone the repository to, relative from the session's directory Auth transport.AuthMethod // authentication method for git operations // contains filtered or unexported fields }
Repository represents a Git repository address and branch name
type Session ¶
type Session struct { Repositories []Repository // list of local or remote repository URLs to watch Interval time.Duration // the interval between remote checks Directory string // the directory to store repositories Auth transport.AuthMethod // authentication method for git operations InitialEvent bool // if true, an event for each repo will be emitted upon construction AllowDeletion bool // if true, repository will be deleted upon error and re-cloned UseForce bool // if true, use force-pull when pulling changes, wiping any local changes InitialDone chan struct{} // if InitialEvent true, this is pushed to after initial setup done Events chan Event // when a change is detected, events are pushed here Errors chan error // when an error occurs, errors come here instead of halting the loop // contains filtered or unexported fields }
Session represents a git watch session configuration
func New ¶
func New( ctx context.Context, repos []Repository, interval time.Duration, dir string, auth transport.AuthMethod, initialEvent bool, ) (session *Session, err error)
New constructs a new git watch session on the given repositories The `auth` parameter is the default authentication method. Elements of the `repos` list may specify their own authentication methods, which override this value when set.
func (*Session) Add ¶ added in v1.4.0
func (s *Session) Add(r Repository) (err error)
Add will add a new repository to the list. Works even after the watcher daemon has already been started.
func (*Session) GetEventFromRepoChanges ¶
func (s *Session) GetEventFromRepoChanges(repo *git.Repository, branch string, auth transport.AuthMethod) (event *Event, err error)
GetEventFromRepoChanges reads a locally cloned git repository an returns an event only if an attempted fetch resulted in new changes in the working tree.