Documentation ¶
Index ¶
- Constants
- func Clone(url, username, password, path, branchName string) error
- func ParseGitAddress(s string) (host string, id string, err error)
- type AzdoGITProvider
- func (g *AzdoGITProvider) CreatePR(ctx context.Context, branchName string, auto bool, title, description string) (int, error)
- func (g *AzdoGITProvider) GetPRThatCausedCommit(ctx context.Context, sha string) (PullRequest, error)
- func (g *AzdoGITProvider) GetPRWithBranch(ctx context.Context, source, target string) (PullRequest, error)
- func (g *AzdoGITProvider) GetStatus(ctx context.Context, sha string, group string, env string) (CommitStatus, error)
- func (g *AzdoGITProvider) MergePR(ctx context.Context, id int, sha string) error
- func (g *AzdoGITProvider) SetStatus(ctx context.Context, sha string, group string, env string, succeeded bool) error
- type CommitStatus
- type GitHubGITProvider
- func (g *GitHubGITProvider) CreatePR(ctx context.Context, branchName string, auto bool, title, description string) (int, error)
- func (g *GitHubGITProvider) GetPRThatCausedCommit(ctx context.Context, sha string) (PullRequest, error)
- func (g *GitHubGITProvider) GetPRWithBranch(ctx context.Context, source, target string) (PullRequest, error)
- func (g *GitHubGITProvider) GetStatus(ctx context.Context, sha string, group string, env string) (CommitStatus, error)
- func (g *GitHubGITProvider) MergePR(ctx context.Context, id int, sha string) error
- func (g *GitHubGITProvider) SetStatus(ctx context.Context, sha string, group string, env string, succeeded bool) error
- type GitProvider
- type PRState
- func (p *PRState) AppKustomizationPath() string
- func (p *PRState) AppPath() string
- func (p *PRState) BranchName(includeEnv bool) string
- func (p *PRState) Description() (string, error)
- func (p *PRState) EnvKustomizationPath() string
- func (p *PRState) EnvPath() string
- func (p *PRState) GetPRType() PRType
- func (p *PRState) Title() string
- type PRType
- type ProviderType
- type PullRequest
- type Repository
- func (g *Repository) CreateBranch(branchName string, force bool) error
- func (g *Repository) CreateCommit(branchName, message string) (*git2go.Oid, error)
- func (g *Repository) CreatePR(ctx context.Context, branchName string, auto bool, title, description string) (int, error)
- func (g *Repository) FetchBranch(branchName string) (*git2go.Oid, error)
- func (g *Repository) GetBranchName() (string, error)
- func (g *Repository) GetCurrentCommit() (*git2go.Oid, error)
- func (g *Repository) GetLastCommitForBranch(branchName string) (*git2go.Oid, error)
- func (g *Repository) GetLastCommitForPath(path string) (*git2go.Commit, error)
- func (g *Repository) GetPRForCurrentBranch(ctx context.Context) (PullRequest, error)
- func (g *Repository) GetPRThatCausedCurrentCommit(ctx context.Context) (PullRequest, error)
- func (g *Repository) GetRootDir() string
- func (g *Repository) GetStatus(ctx context.Context, sha, group, env string) (CommitStatus, error)
- func (g *Repository) MergePR(ctx context.Context, id int, sha string) error
- func (g *Repository) Push(branchName string, force bool) error
Constants ¶
const ( DefaultUsername = "git" DefaultRemote = "origin" DefaultBranch = "main" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AzdoGITProvider ¶
type AzdoGITProvider struct {
// contains filtered or unexported fields
}
AdoGITProvider ...
func NewAzdoGITProvider ¶
func NewAzdoGITProvider(ctx context.Context, remoteURL, token string) (*AzdoGITProvider, error)
NewAdoGITProvider ...
func (*AzdoGITProvider) CreatePR ¶
func (g *AzdoGITProvider) CreatePR(ctx context.Context, branchName string, auto bool, title, description string) (int, error)
CreatePR ...
func (*AzdoGITProvider) GetPRThatCausedCommit ¶
func (g *AzdoGITProvider) GetPRThatCausedCommit(ctx context.Context, sha string) (PullRequest, error)
func (*AzdoGITProvider) GetPRWithBranch ¶
func (g *AzdoGITProvider) GetPRWithBranch(ctx context.Context, source, target string) (PullRequest, error)
func (*AzdoGITProvider) GetStatus ¶
func (g *AzdoGITProvider) GetStatus(ctx context.Context, sha string, group string, env string) (CommitStatus, error)
type CommitStatus ¶ added in v1.0.0
type CommitStatus struct {
Succeeded bool
}
type GitHubGITProvider ¶ added in v0.0.7
type GitHubGITProvider struct {
// contains filtered or unexported fields
}
GitHubGITProvider ...
func NewGitHubGITProvider ¶ added in v0.0.7
func NewGitHubGITProvider(ctx context.Context, remoteURL, token string) (*GitHubGITProvider, error)
NewGitHubGITProvider ...
func (*GitHubGITProvider) CreatePR ¶ added in v0.0.7
func (g *GitHubGITProvider) CreatePR(ctx context.Context, branchName string, auto bool, title, description string) (int, error)
CreatePR ...
func (*GitHubGITProvider) GetPRThatCausedCommit ¶ added in v0.0.7
func (g *GitHubGITProvider) GetPRThatCausedCommit(ctx context.Context, sha string) (PullRequest, error)
func (*GitHubGITProvider) GetPRWithBranch ¶ added in v0.0.7
func (g *GitHubGITProvider) GetPRWithBranch(ctx context.Context, source, target string) (PullRequest, error)
func (*GitHubGITProvider) GetStatus ¶ added in v0.0.7
func (g *GitHubGITProvider) GetStatus(ctx context.Context, sha string, group string, env string) (CommitStatus, error)
type GitProvider ¶
type GitProvider interface { GetStatus(ctx context.Context, sha, group, env string) (CommitStatus, error) SetStatus(ctx context.Context, sha string, group string, env string, succeeded bool) error CreatePR(ctx context.Context, branchName string, auto bool, title, description string) (int, error) GetPRWithBranch(ctx context.Context, source, target string) (PullRequest, error) GetPRThatCausedCommit(ctx context.Context, sha string) (PullRequest, error) MergePR(ctx context.Context, ID int, sha string) error }
func NewGitProvider ¶
func NewGitProvider(ctx context.Context, providerType ProviderType, remoteURL, token string) (GitProvider, error)
type PRState ¶
type PRState struct { Group string `json:"group"` App string `json:"app"` Tag string `json:"tag"` Env string `json:"env"` Sha string `json:"sha"` Feature string `json:"feature"` Type PRType `json:"type"` }
func NewPRState ¶ added in v1.0.0
NewPRState takes the content of a pull rquest description and coverts it to a PRState. No error will be returned if the description does not contain state metadata, but the bool value will be false.
func (*PRState) AppKustomizationPath ¶ added in v1.1.0
func (*PRState) BranchName ¶
func (*PRState) Description ¶
func (*PRState) EnvKustomizationPath ¶ added in v1.1.0
type ProviderType ¶
type ProviderType string
const ( ProviderTypeAzdo ProviderType = "azdo" ProviderTypeGitHub ProviderType = "github" )
type PullRequest ¶
func NewPullRequest ¶ added in v1.0.0
func NewPullRequest(id *int, title *string, description *string) (PullRequest, error)
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository represents a local git repository.
func LoadRepository ¶
func LoadRepository(ctx context.Context, path string, providerTypeString string, token string) (*Repository, error)
LoadRepository loads a local git repository.
func (*Repository) CreateBranch ¶
func (g *Repository) CreateBranch(branchName string, force bool) error
CreateBranch creates a branch.
func (*Repository) CreateCommit ¶
func (g *Repository) CreateCommit(branchName, message string) (*git2go.Oid, error)
CreateCommit creates a commit in the specfied branch with the current changes.
func (*Repository) CreatePR ¶
func (g *Repository) CreatePR(ctx context.Context, branchName string, auto bool, title, description string) (int, error)
CreatePR creates a PR for the branch. It assumes that the branch has been pushed.
func (*Repository) FetchBranch ¶ added in v1.0.0
func (g *Repository) FetchBranch(branchName string) (*git2go.Oid, error)
FetchDefaultBranch updates DefaultBranch with new commits from DefaultRemote.
func (*Repository) GetBranchName ¶ added in v0.0.6
func (g *Repository) GetBranchName() (string, error)
GetBranchName returns the branch name of for HEAD.
func (*Repository) GetCurrentCommit ¶
func (g *Repository) GetCurrentCommit() (*git2go.Oid, error)
GetCurrentCommit returns the commmit id for HEAD.
func (*Repository) GetLastCommitForBranch ¶
func (g *Repository) GetLastCommitForBranch(branchName string) (*git2go.Oid, error)
GetLastCommitForBranch returns the latest commit id for the branch.
func (*Repository) GetLastCommitForPath ¶ added in v1.1.0
func (g *Repository) GetLastCommitForPath(path string) (*git2go.Commit, error)
GetLastCommitForPath returns the last commit for the given path. All files and subdirectories will be considered if the path is a directory.
func (*Repository) GetPRForCurrentBranch ¶
func (g *Repository) GetPRForCurrentBranch(ctx context.Context) (PullRequest, error)
GetPRForCurrentBranch returns any active PR for the current branch.
func (*Repository) GetPRThatCausedCurrentCommit ¶
func (g *Repository) GetPRThatCausedCurrentCommit(ctx context.Context) (PullRequest, error)
GetPRThatCausedCurrentCommit finds the merged PR with resulted in the current commit.
func (*Repository) GetRootDir ¶
func (g *Repository) GetRootDir() string
GetRootDir returns the file path to the repository.
func (*Repository) GetStatus ¶
func (g *Repository) GetStatus(ctx context.Context, sha, group, env string) (CommitStatus, error)
GetStatus returns the status for the give commit.