Documentation
¶
Index ¶
- func InvokeAllHooks(client *http.Client, store hooks.WebhookStore, event string, ...) error
- type Branch
- type Commit
- type CommitInfo
- type GitRepository
- func (repo *GitRepository) FileExists(id string) (bool, error)
- func (repo *GitRepository) FileExistsByCommit(commitId, filepath string) (bool, error)
- func (repo *GitRepository) GetBranches() ([]Branch, error)
- func (repo *GitRepository) GetCommit(commitId string) (*Commit, error)
- func (repo *GitRepository) GetCommits(branch string, start string) ([]CommitInfo, error)
- func (repo *GitRepository) GetFile(id string) ([]byte, error)
- func (repo *GitRepository) GetFileByCommit(commitId, filepath string) ([]byte, error)
- func (repo *GitRepository) GetName() string
- func (repo *GitRepository) GetPath() string
- func (repo *GitRepository) GetScm() string
- func (repo *GitRepository) InstallHooks(cfgPath string, force bool) (err error)
- func (repo *GitRepository) ParseEventPayload(event string, input io.Reader) (events.Payload, error)
- type HgRepository
- func (repo *HgRepository) Client() (*hg.HgClient, error)
- func (repo *HgRepository) FileExists(filepath string) (bool, error)
- func (repo *HgRepository) FileExistsByCommit(changeset, filepath string) (bool, error)
- func (repo *HgRepository) GetBranches() ([]Branch, error)
- func (repo *HgRepository) GetCommit(commitId string) (*Commit, error)
- func (repo *HgRepository) GetCommits(branch string, start string) ([]CommitInfo, error)
- func (repo *HgRepository) GetFile(filepath string) ([]byte, error)
- func (repo *HgRepository) GetFileByCommit(changeset, filepath string) ([]byte, error)
- func (repo *HgRepository) GetName() string
- func (repo *HgRepository) GetPath() string
- func (repo *HgRepository) GetScm() string
- func (repo *HgRepository) InstallHooks(cfgPath string, force bool) error
- func (repo *HgRepository) Log(client *hg.HgClient, fields, revisions []string, args ...string) ([][]string, error)
- func (repo *HgRepository) ParseEventPayload(event string, input io.Reader) (events.Payload, error)
- type Repository
- type RepositoryInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InvokeAllHooks ¶
func InvokeAllHooks( client *http.Client, store hooks.WebhookStore, event string, repository Repository, payload events.Payload, ) error
Invoke all webhooks that match the given event and repository.
Types ¶
type Branch ¶
type Branch struct { // The name of the branch. Name string `json:"name"` // The commit ID the branch points to. Id string `json:"id"` }
Information about a branch in an SCM.
type Commit ¶
type Commit struct { // Commit metadata. CommitInfo // The contents of the diff. Diff string `json:"diff"` }
A commit with metadata and a diff.
type CommitInfo ¶
type CommitInfo struct { // The author of the commit. Author string `json:"author"` // The unique identifier of the commit. Id string `json:"id"` // The date the commit was authored. Date string `json:"date"` // The commit's message. Message string `json:"message"` // The unique identifier of the parent commit. ParentId string `json:"parent_id"` }
Metadata about a commit.
type GitRepository ¶
type GitRepository struct {
RepositoryInfo
}
GitRepository extends RepositoryInfo and is meant to represent a Git Repository.
func (*GitRepository) FileExists ¶
func (repo *GitRepository) FileExists(id string) (bool, error)
FileExists is a Repository implementation that returns whether a file exists in the GitRepository based on the file revision sha.
It returns true if the file exists, false otherwise. On failure, the error will also be returned.
func (*GitRepository) FileExistsByCommit ¶
func (repo *GitRepository) FileExistsByCommit(commitId, filepath string) (bool, error)
FileExistsByCommit is a Repository implementation that returns whether a file exists in the GitRepository based on a commit sha and the file path.
It returns true if the file exists, false otherwise. On failure, the error will also be returned.
func (*GitRepository) GetBranches ¶
func (repo *GitRepository) GetBranches() ([]Branch, error)
GetBranches is a Repository implementation that returns all the branches in the repository.
On failure, the error will also be returned.
func (*GitRepository) GetCommit ¶
func (repo *GitRepository) GetCommit(commitId string) (*Commit, error)
GetCommit is a Repository implementation that returns the commit information in the repository for the specified commit id.
On failure, the error will also be returned.
func (*GitRepository) GetCommits ¶
func (repo *GitRepository) GetCommits(branch string, start string) ([]CommitInfo, error)
GetCommits is a Repository implementation that returns all the commits in the repository for the specified branch. It also takes an optional start commit sha, which will return all commits starting from the start commit sha instead.
On failure, the error will also be returned.
func (*GitRepository) GetFile ¶
func (repo *GitRepository) GetFile(id string) ([]byte, error)
GetFile is a Repository implementation that returns the contents of a file in the GitRepository based on the file revision sha.
On success, it returns the file contents in a byte array. On failure, the error will be returned.
func (*GitRepository) GetFileByCommit ¶
func (repo *GitRepository) GetFileByCommit(commitId, filepath string) ([]byte, error)
GetFileByCommit is a Repository implementation that returns the contents of a file in the GitRepository based on a commit sha and the file path.
On success, it returns the file contents in a byte array. On failure, the error will be returned.
func (*GitRepository) GetName ¶
func (repo *GitRepository) GetName() string
GetName is a Repository implementation that returns the name of the GitRepository.
func (*GitRepository) GetPath ¶
func (repo *GitRepository) GetPath() string
GetPath is a Repository implementation that returns the path of the GitRepository.
func (*GitRepository) GetScm ¶
func (repo *GitRepository) GetScm() string
func (*GitRepository) InstallHooks ¶
func (repo *GitRepository) InstallHooks(cfgPath string, force bool) (err error)
Install all hooks for the given repository.
func (*GitRepository) ParseEventPayload ¶
type HgRepository ¶
type HgRepository struct {
RepositoryInfo
}
A Mercurial repository.
func (*HgRepository) Client ¶
func (repo *HgRepository) Client() (*hg.HgClient, error)
Create a new client for the repository.
The caller is responsible for calling Client.Disconnect() when finished.
func (*HgRepository) FileExists ¶
func (repo *HgRepository) FileExists(filepath string) (bool, error)
Return whther or not a file exists.
It returns true if the file exists, false otherwise. On failure, the error will also be returned.
func (*HgRepository) FileExistsByCommit ¶
func (repo *HgRepository) FileExistsByCommit(changeset, filepath string) (bool, error)
Return whether or not a file exists at a given changeset.
It returns true if the file exists, false otherwise. On failure, the error will also be returned.
func (*HgRepository) GetBranches ¶
func (repo *HgRepository) GetBranches() ([]Branch, error)
Return the branches of the repository.
This returns both Mercurial branches and bookmarks.
On failure, the error will also be returned.
func (*HgRepository) GetCommit ¶
func (repo *HgRepository) GetCommit(commitId string) (*Commit, error)
Return a commit and its diff.
On failure, the error will also be returned.
func (*HgRepository) GetCommits ¶
func (repo *HgRepository) GetCommits(branch string, start string) ([]CommitInfo, error)
Return commits from a given starting point.
If `start` is non-empty, that will be used as the starting point. Otherwise `branch` will be used.
On failure, the error will also be returned.
func (*HgRepository) GetFile ¶
func (repo *HgRepository) GetFile(filepath string) ([]byte, error)
Return the contents of the requested file.
On success, it returns the file contents in a byte array. On failure, the error will be returned.
func (*HgRepository) GetFileByCommit ¶
func (repo *HgRepository) GetFileByCommit(changeset, filepath string) ([]byte, error)
Return the contents of the requested file at the given changeset.
On success, it returns the file contents in a byte array. On failure, the error will be returned.
func (*HgRepository) GetName ¶
func (repo *HgRepository) GetName() string
Return the name of the repository.
func (*HgRepository) GetPath ¶
func (repo *HgRepository) GetPath() string
Return the path of the repository.
func (*HgRepository) GetScm ¶
func (repo *HgRepository) GetScm() string
Return the name of the SCM tool.
This will always be `"hg"`.
func (*HgRepository) InstallHooks ¶
func (repo *HgRepository) InstallHooks(cfgPath string, force bool) error
func (*HgRepository) Log ¶
func (repo *HgRepository) Log(client *hg.HgClient, fields, revisions []string, args ...string) ([][]string, error)
A convencience method for calling `hg log` and extracting the results.
`client` may be nil, in which case a client will be allocated for the call to log that will be deallocated once the emthod finishes. Otherwise, the provided client will be used.
`fields` is a list of template parameters. They will be used to generate the `--template` argument to `hg log`. [Details on templating in Mercurial]1.
The returned list is a list of the values corresponding the to the template parameters in `fields` for each revision in `revisions`.
func (*HgRepository) ParseEventPayload ¶
type Repository ¶
type Repository interface { // GetName returns the name of the repository. GetName() string // GetPath returns the path of the repository. GetPath() string // Return the name of the SCM. GetScm() string // GetFile takes a file ID and returns the file contents as a byte array. // If an error occurs, it will also be returned. GetFile(id string) ([]byte, error) // GetFileByCommit takes a commit and a file path pair, and returns the // file contents as a byte array. If an error occurs, it will also be // returned. GetFileByCommit(commit, filepath string) ([]byte, error) // FileExists takes a file ID and returns true if the file is found in the // repository; false otherwise. If an error occurs, it will also be // returned. FileExists(id string) (bool, error) // FileExistsByCommit takes a commit and file path pair, and returns true // if the file is found in the repository; false otherwise. If an error // occurs, it will also be returned. FileExistsByCommit(commit, filepath string) (bool, error) // GetBranches returns all the branches in the repository as a JSON byte // array. If an error occurs, it will also be returned. GetBranches() ([]Branch, error) // GetCommit returns all the commits in the repository starting at the // specified branch as a JSON byte array. It also takes an optional start // commit id, which will return all commits starting from the start commit // id instead. If an error occurs, it will also be returned. GetCommits(branch string, start string) ([]CommitInfo, error) // GetCommit returns the commit in the repository provided by the commit // id as a JSON byte array. If an error occurs, it will also be returned. GetCommit(commitId string) (*Commit, error) // Parse the raw payload from the given event. ParseEventPayload(event string, input io.Reader) (events.Payload, error) // Install scripts to trigger webhooks. InstallHooks(cfgPath string, force bool) error }
Repository is an interface that contains functions to perform actions on repositories, such as getting the file contents or checking if a file exists.
type RepositoryInfo ¶
RepositoryInfo is a generic representation of a repository, containing a name and a path to the repository.