gits

package
v1.3.62 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindBitBucketCloud  = "bitbucketcloud"
	KindBitBucketServer = "bitbucketserver"
	KindGitea           = "gitea"
	KindGitlab          = "gitlab"
	KindGitHub          = "github"
	KindUnknown         = "unknown"

	BitbucketCloudURL = "https://bitbucket.org"
)
View Source
const (
	GitHubHost = "github.com"
	GitHubURL  = "https://github.com"
)
View Source
const (
	CommitStatusPending CommitStatus = "pending"
	CommitSatusSuccess               = "success"
	CommitStatusError                = "error"
	CommitStatusFailure              = "failure"
)

Variables

View Source
var (

	// ConventionalCommitTitles textual descriptions for
	// Conventional Commit types: https://conventionalcommits.org/
	ConventionalCommitTitles = map[string]*CommitGroup{
		"feat":     createCommitGroup("New Features"),
		"fix":      createCommitGroup("Bug Fixes"),
		"perf":     createCommitGroup("Performance Improvements"),
		"refactor": createCommitGroup("Code Refactoring"),
		"docs":     createCommitGroup("Documentation"),
		"test":     createCommitGroup("Tests"),
		"revert":   createCommitGroup("Reverts"),
		"style":    createCommitGroup("Styles"),
		"chore":    createCommitGroup("Chores"),
		"":         createCommitGroup(""),
	}
)

Functions

func BitBucketCloudAccessTokenURL

func BitBucketCloudAccessTokenURL(url string, username string) string

func BitBucketServerAccessTokenURL

func BitBucketServerAccessTokenURL(url string) string

func GenerateMarkdown

func GenerateMarkdown(releaseSpec *v1.ReleaseSpec, gitInfo *GitRepositoryInfo) (string, error)

GenerateMarkdown generates the markdown document for the commits

func GetHost

func GetHost(gitProvider GitProvider) (string, error)

GetHost returns the Git Provider hostname, e.g github.com

func GitHubAccessTokenURL

func GitHubAccessTokenURL(url string) string

func GitHubEnterpriseApiEndpointURL

func GitHubEnterpriseApiEndpointURL(u string) string

func GiteaAccessTokenURL

func GiteaAccessTokenURL(url string) string

func GitlabAccessTokenURL

func GitlabAccessTokenURL(url string) string

GitlabAccessTokenURL returns the URL to click on to generate a personal access token for the git provider

func IsGitHubServerURL

func IsGitHubServerURL(u string) bool

func IsGitRepoStatusFailed

func IsGitRepoStatusFailed(statuses ...*GitRepoStatus) bool

IsGitRepoStatusFailed returns true if any of the statuses have failed

func IsGitRepoStatusSuccess

func IsGitRepoStatusSuccess(statuses ...*GitRepoStatus) bool

IsGitRepoStatusSuccess returns true if all the statuses are successful

func PickOrganisation

func PickOrganisation(orgLister OrganisationLister, userName string) (string, error)

PickOrganisation picks an organisations login if there is one available

func ProviderAccessTokenURL

func ProviderAccessTokenURL(kind string, url string, username string) string

func ReleaseDownloadCount

func ReleaseDownloadCount(releases []*GitRelease) int

ReleaseDownloadCount returns the total number of downloads for the given set of releases

func SaasGitKind

func SaasGitKind(gitServiceUrl string) string

SaasGitKind returns the kind for SaaS git providers or "" if the URL could not be deduced

Types

type BitbucketCloudProvider

type BitbucketCloudProvider struct {
	Client   *bitbucket.APIClient
	Username string
	Context  context.Context

	Server auth.AuthServer
	User   auth.UserAuth
	Git    Gitter
}

BitbucketCloudProvider implements GitProvider interface for bitbucket.org

func (*BitbucketCloudProvider) AddPRComment

func (b *BitbucketCloudProvider) AddPRComment(pr *GitPullRequest, comment string) error

func (*BitbucketCloudProvider) CreateIssue

func (b *BitbucketCloudProvider) CreateIssue(owner string, repo string, issue *GitIssue) (*GitIssue, error)

func (*BitbucketCloudProvider) CreateIssueComment

func (b *BitbucketCloudProvider) CreateIssueComment(owner string, repo string, number int, comment string) error

func (*BitbucketCloudProvider) CreatePullRequest

func (b *BitbucketCloudProvider) CreatePullRequest(
	data *GitPullRequestArguments,
) (*GitPullRequest, error)

func (*BitbucketCloudProvider) CreateRepository

func (b *BitbucketCloudProvider) CreateRepository(
	org string,
	name string,
	private bool,
) (*GitRepository, error)

func (*BitbucketCloudProvider) CreateWebHook

func (b *BitbucketCloudProvider) CreateWebHook(data *GitWebHookArguments) error

func (*BitbucketCloudProvider) CurrentUsername

func (p *BitbucketCloudProvider) CurrentUsername() string

func (*BitbucketCloudProvider) DeleteRepository

func (b *BitbucketCloudProvider) DeleteRepository(org string, name string) error

func (*BitbucketCloudProvider) ForkRepository

func (b *BitbucketCloudProvider) ForkRepository(
	originalOrg string,
	name string,
	destinationOrg string,
) (*GitRepository, error)

func (*BitbucketCloudProvider) GetIssue

func (b *BitbucketCloudProvider) GetIssue(org string, name string, number int) (*GitIssue, error)

func (*BitbucketCloudProvider) GetPullRequest

func (p *BitbucketCloudProvider) GetPullRequest(owner string, repoInfo *GitRepositoryInfo, number int) (*GitPullRequest, error)

func (*BitbucketCloudProvider) GetPullRequestCommits

func (b *BitbucketCloudProvider) GetPullRequestCommits(owner string, repository *GitRepositoryInfo, number int) ([]*GitCommit, error)

func (*BitbucketCloudProvider) GetRepository

func (b *BitbucketCloudProvider) GetRepository(
	org string,
	name string,
) (*GitRepository, error)

func (*BitbucketCloudProvider) GitIssueToBitbucketIssue

func (b *BitbucketCloudProvider) GitIssueToBitbucketIssue(gIssue GitIssue) bitbucket.Issue

func (*BitbucketCloudProvider) HasIssues

func (b *BitbucketCloudProvider) HasIssues() bool

func (*BitbucketCloudProvider) IsBitbucketCloud

func (b *BitbucketCloudProvider) IsBitbucketCloud() bool

func (*BitbucketCloudProvider) IsBitbucketServer

func (b *BitbucketCloudProvider) IsBitbucketServer() bool

func (*BitbucketCloudProvider) IsGitHub

func (b *BitbucketCloudProvider) IsGitHub() bool

func (*BitbucketCloudProvider) IsGitea

func (b *BitbucketCloudProvider) IsGitea() bool

func (*BitbucketCloudProvider) IssueURL

func (p *BitbucketCloudProvider) IssueURL(org string, name string, number int, isPull bool) string

func (*BitbucketCloudProvider) JenkinsWebHookPath

func (b *BitbucketCloudProvider) JenkinsWebHookPath(gitURL string, secret string) string

Exposed by Jenkins plugin; this one is for https://wiki.jenkins.io/display/JENKINS/BitBucket+Plugin

func (*BitbucketCloudProvider) Kind

func (b *BitbucketCloudProvider) Kind() string

func (*BitbucketCloudProvider) Label

func (b *BitbucketCloudProvider) Label() string

func (*BitbucketCloudProvider) ListCommitStatus

func (b *BitbucketCloudProvider) ListCommitStatus(org string, repo string, sha string) ([]*GitRepoStatus, error)

func (*BitbucketCloudProvider) ListOrganisations

func (b *BitbucketCloudProvider) ListOrganisations() ([]GitOrganisation, error)

func (*BitbucketCloudProvider) ListReleases

func (p *BitbucketCloudProvider) ListReleases(org string, name string) ([]*GitRelease, error)

func (*BitbucketCloudProvider) ListRepositories

func (b *BitbucketCloudProvider) ListRepositories(org string) ([]*GitRepository, error)

func (*BitbucketCloudProvider) MergePullRequest

func (b *BitbucketCloudProvider) MergePullRequest(pr *GitPullRequest, message string) error

func (*BitbucketCloudProvider) PullRequestLastCommitStatus

func (b *BitbucketCloudProvider) PullRequestLastCommitStatus(pr *GitPullRequest) (string, error)

func (*BitbucketCloudProvider) RenameRepository

func (b *BitbucketCloudProvider) RenameRepository(
	org string,
	name string,
	newName string,
) (*GitRepository, error)

func (*BitbucketCloudProvider) SearchIssues

func (b *BitbucketCloudProvider) SearchIssues(org string, name string, query string) ([]*GitIssue, error)

func (*BitbucketCloudProvider) SearchIssuesClosedSince

func (b *BitbucketCloudProvider) SearchIssuesClosedSince(org string, name string, t time.Time) ([]*GitIssue, error)

func (*BitbucketCloudProvider) ServerURL

func (b *BitbucketCloudProvider) ServerURL() string

func (*BitbucketCloudProvider) UpdatePullRequestStatus

func (b *BitbucketCloudProvider) UpdatePullRequestStatus(pr *GitPullRequest) error

func (*BitbucketCloudProvider) UpdateRelease

func (b *BitbucketCloudProvider) UpdateRelease(owner string, repo string, tag string, releaseInfo *GitRelease) error

func (*BitbucketCloudProvider) UserAuth

func (p *BitbucketCloudProvider) UserAuth() auth.UserAuth

func (*BitbucketCloudProvider) UserInfo

func (p *BitbucketCloudProvider) UserInfo(username string) *GitUser

func (*BitbucketCloudProvider) ValidateRepositoryName

func (b *BitbucketCloudProvider) ValidateRepositoryName(org string, name string) error

type BitbucketServerProvider

type BitbucketServerProvider struct {
	Client   *bitbucket.APIClient
	Username string
	Context  context.Context

	Server auth.AuthServer
	User   auth.UserAuth
	Git    Gitter
}

BitbucketServerProvider implements GitProvider interface for a bitbucket server

func (*BitbucketServerProvider) AddPRComment

func (b *BitbucketServerProvider) AddPRComment(pr *GitPullRequest, comment string) error

func (*BitbucketServerProvider) CreateIssue

func (b *BitbucketServerProvider) CreateIssue(owner string, repo string, issue *GitIssue) (*GitIssue, error)

func (*BitbucketServerProvider) CreateIssueComment

func (b *BitbucketServerProvider) CreateIssueComment(owner string, repo string, number int, comment string) error

func (*BitbucketServerProvider) CreatePullRequest

func (b *BitbucketServerProvider) CreatePullRequest(data *GitPullRequestArguments) (*GitPullRequest, error)

func (*BitbucketServerProvider) CreateRepository

func (b *BitbucketServerProvider) CreateRepository(org, name string, private bool) (*GitRepository, error)

func (*BitbucketServerProvider) CreateWebHook

func (b *BitbucketServerProvider) CreateWebHook(data *GitWebHookArguments) error

func (*BitbucketServerProvider) CurrentUsername

func (b *BitbucketServerProvider) CurrentUsername() string

func (*BitbucketServerProvider) DeleteRepository

func (b *BitbucketServerProvider) DeleteRepository(org, name string) error

func (*BitbucketServerProvider) ForkRepository

func (b *BitbucketServerProvider) ForkRepository(originalOrg, name, destinationOrg string) (*GitRepository, error)

func (*BitbucketServerProvider) GetIssue

func (b *BitbucketServerProvider) GetIssue(org string, name string, number int) (*GitIssue, error)

func (*BitbucketServerProvider) GetPullRequest

func (b *BitbucketServerProvider) GetPullRequest(owner string, repo *GitRepositoryInfo, number int) (*GitPullRequest, error)

func (*BitbucketServerProvider) GetPullRequestCommits

func (b *BitbucketServerProvider) GetPullRequestCommits(owner string, repository *GitRepositoryInfo, number int) ([]*GitCommit, error)

func (*BitbucketServerProvider) GetRepository

func (b *BitbucketServerProvider) GetRepository(org string, name string) (*GitRepository, error)

func (*BitbucketServerProvider) HasIssues

func (b *BitbucketServerProvider) HasIssues() bool

func (*BitbucketServerProvider) IsBitbucketCloud

func (b *BitbucketServerProvider) IsBitbucketCloud() bool

func (*BitbucketServerProvider) IsBitbucketServer

func (b *BitbucketServerProvider) IsBitbucketServer() bool

func (*BitbucketServerProvider) IsGitHub

func (b *BitbucketServerProvider) IsGitHub() bool

func (*BitbucketServerProvider) IsGitea

func (b *BitbucketServerProvider) IsGitea() bool

func (*BitbucketServerProvider) IssueURL

func (b *BitbucketServerProvider) IssueURL(org string, name string, number int, isPull bool) string

func (*BitbucketServerProvider) JenkinsWebHookPath

func (b *BitbucketServerProvider) JenkinsWebHookPath(gitURL string, secret string) string

Exposed by Jenkins plugin; this one is for https://wiki.jenkins.io/display/JENKINS/BitBucket+Plugin

func (*BitbucketServerProvider) Kind

func (b *BitbucketServerProvider) Kind() string

func (*BitbucketServerProvider) Label

func (b *BitbucketServerProvider) Label() string

func (*BitbucketServerProvider) ListCommitStatus

func (b *BitbucketServerProvider) ListCommitStatus(org, repo, sha string) ([]*GitRepoStatus, error)

func (*BitbucketServerProvider) ListOrganisations

func (b *BitbucketServerProvider) ListOrganisations() ([]GitOrganisation, error)

func (*BitbucketServerProvider) ListReleases

func (p *BitbucketServerProvider) ListReleases(org string, name string) ([]*GitRelease, error)

func (*BitbucketServerProvider) ListRepositories

func (b *BitbucketServerProvider) ListRepositories(org string) ([]*GitRepository, error)

func (*BitbucketServerProvider) MergePullRequest

func (b *BitbucketServerProvider) MergePullRequest(pr *GitPullRequest, message string) error

func (*BitbucketServerProvider) PullRequestLastCommitStatus

func (b *BitbucketServerProvider) PullRequestLastCommitStatus(pr *GitPullRequest) (string, error)

func (*BitbucketServerProvider) RenameRepository

func (b *BitbucketServerProvider) RenameRepository(org, name, newName string) (*GitRepository, error)

func (*BitbucketServerProvider) SearchIssues

func (b *BitbucketServerProvider) SearchIssues(org string, name string, query string) ([]*GitIssue, error)

func (*BitbucketServerProvider) SearchIssuesClosedSince

func (b *BitbucketServerProvider) SearchIssuesClosedSince(org string, name string, t time.Time) ([]*GitIssue, error)

func (*BitbucketServerProvider) ServerURL

func (b *BitbucketServerProvider) ServerURL() string

func (*BitbucketServerProvider) UpdatePullRequestStatus

func (b *BitbucketServerProvider) UpdatePullRequestStatus(pr *GitPullRequest) error

func (*BitbucketServerProvider) UpdateRelease

func (b *BitbucketServerProvider) UpdateRelease(owner string, repo string, tag string, releaseInfo *GitRelease) error

func (*BitbucketServerProvider) UserAuth

func (b *BitbucketServerProvider) UserAuth() auth.UserAuth

func (*BitbucketServerProvider) UserInfo

func (b *BitbucketServerProvider) UserInfo(username string) *GitUser

func (*BitbucketServerProvider) ValidateRepositoryName

func (b *BitbucketServerProvider) ValidateRepositoryName(org, name string) error

type CommitGroup

type CommitGroup struct {
	Title string
	Order int
}

func ConventionalCommitTypeToTitle

func ConventionalCommitTypeToTitle(kind string) *CommitGroup

ConventionalCommitTypeToTitle returns the title of the conventional commit type see: https://conventionalcommits.org/

type CommitInfo

type CommitInfo struct {
	Kind    string
	Feature string
	Message string
	// contains filtered or unexported fields
}

func ParseCommit

func ParseCommit(message string) *CommitInfo

ParseCommit parses a conventional commit see: https://conventionalcommits.org/

func (*CommitInfo) Group

func (c *CommitInfo) Group() *CommitGroup

func (*CommitInfo) Order

func (c *CommitInfo) Order() int

func (*CommitInfo) Title

func (c *CommitInfo) Title() string

type CommitStatus

type CommitStatus string

type CreateRepoData

type CreateRepoData struct {
	Organisation string
	RepoName     string
	FullName     string
	PrivateRepo  bool
	User         *auth.UserAuth
	GitProvider  GitProvider
}

func PickNewGitRepository

func PickNewGitRepository(out io.Writer, batchMode bool, authConfigSvc auth.AuthConfigService, defaultRepoName string,
	repoOptions *GitRepositoryOptions, server *auth.AuthServer, userAuth *auth.UserAuth, git Gitter) (*CreateRepoData, error)

func (*CreateRepoData) CreateRepository

func (d *CreateRepoData) CreateRepository() (*GitRepository, error)

CreateRepository creates the repository - failing if it already exists

func (*CreateRepoData) GetRepository

func (d *CreateRepoData) GetRepository() (*GitRepository, error)

GetRepository returns the repository if it already exists

type FakeCommit

type FakeCommit struct {
	Commit *GitCommit
	Status CommitStatus
}

type FakeIssue

type FakeIssue struct {
	Issue   *GitIssue
	Comment string
}

type FakeProvider

type FakeProvider struct {
	Server             auth.AuthServer
	User               auth.UserAuth
	Organizations      []GitOrganisation
	Repositories       map[string][]*FakeRepository
	ForkedRepositories map[string][]*FakeRepository
	Type               FakeProviderType
	Users              []*GitUser
}

func (*FakeProvider) AddPRComment

func (f *FakeProvider) AddPRComment(pr *GitPullRequest, comment string) error

func (*FakeProvider) CreateIssue

func (f *FakeProvider) CreateIssue(owner string, repoName string, issue *GitIssue) (*GitIssue, error)

func (*FakeProvider) CreateIssueComment

func (f *FakeProvider) CreateIssueComment(owner string, repoName string, number int, comment string) error

func (*FakeProvider) CreatePullRequest

func (f *FakeProvider) CreatePullRequest(data *GitPullRequestArguments) (*GitPullRequest, error)

func (*FakeProvider) CreateRepository

func (f *FakeProvider) CreateRepository(org string, name string, private bool) (*GitRepository, error)

func (*FakeProvider) CreateWebHook

func (f *FakeProvider) CreateWebHook(data *GitWebHookArguments) error

func (*FakeProvider) CurrentUsername

func (f *FakeProvider) CurrentUsername() string

func (*FakeProvider) DeleteRepository

func (f *FakeProvider) DeleteRepository(org string, name string) error

func (*FakeProvider) ForkRepository

func (f *FakeProvider) ForkRepository(originalOrg string, name string, destinationOrg string) (*GitRepository, error)

func (*FakeProvider) GetIssue

func (f *FakeProvider) GetIssue(org string, name string, number int) (*GitIssue, error)

func (*FakeProvider) GetPullRequest

func (f *FakeProvider) GetPullRequest(owner string, repo *GitRepositoryInfo, number int) (*GitPullRequest, error)

func (*FakeProvider) GetPullRequestCommits

func (f *FakeProvider) GetPullRequestCommits(owner string, repo *GitRepositoryInfo, number int) ([]*GitCommit, error)

func (*FakeProvider) GetRepository

func (f *FakeProvider) GetRepository(org string, name string) (*GitRepository, error)

func (*FakeProvider) HasIssues

func (f *FakeProvider) HasIssues() bool

func (*FakeProvider) IsBitbucketCloud

func (f *FakeProvider) IsBitbucketCloud() bool

func (*FakeProvider) IsBitbucketServer

func (f *FakeProvider) IsBitbucketServer() bool

func (*FakeProvider) IsGitHub

func (f *FakeProvider) IsGitHub() bool

func (*FakeProvider) IsGitea

func (f *FakeProvider) IsGitea() bool

func (*FakeProvider) IssueURL

func (f *FakeProvider) IssueURL(org string, name string, number int, isPull bool) string

func (*FakeProvider) JenkinsWebHookPath

func (f *FakeProvider) JenkinsWebHookPath(gitURL string, secret string) string

func (*FakeProvider) Kind

func (f *FakeProvider) Kind() string

func (*FakeProvider) Label

func (f *FakeProvider) Label() string

func (*FakeProvider) ListCommitStatus

func (f *FakeProvider) ListCommitStatus(org string, repoName string, sha string) ([]*GitRepoStatus, error)

func (*FakeProvider) ListOrganisations

func (f *FakeProvider) ListOrganisations() ([]GitOrganisation, error)

func (*FakeProvider) ListReleases

func (f *FakeProvider) ListReleases(org string, name string) ([]*GitRelease, error)

func (*FakeProvider) ListRepositories

func (f *FakeProvider) ListRepositories(org string) ([]*GitRepository, error)

func (*FakeProvider) MergePullRequest

func (f *FakeProvider) MergePullRequest(pr *GitPullRequest, message string) error

func (*FakeProvider) PullRequestLastCommitStatus

func (f *FakeProvider) PullRequestLastCommitStatus(pr *GitPullRequest) (string, error)

func (*FakeProvider) RenameRepository

func (f *FakeProvider) RenameRepository(org string, name string, newName string) (*GitRepository, error)

func (*FakeProvider) SearchIssues

func (f *FakeProvider) SearchIssues(org string, name string, query string) ([]*GitIssue, error)

func (*FakeProvider) SearchIssuesClosedSince

func (f *FakeProvider) SearchIssuesClosedSince(org string, name string, t time.Time) ([]*GitIssue, error)

func (*FakeProvider) ServerURL

func (f *FakeProvider) ServerURL() string

func (*FakeProvider) UpdatePullRequestStatus

func (f *FakeProvider) UpdatePullRequestStatus(pr *GitPullRequest) error

func (*FakeProvider) UpdateRelease

func (f *FakeProvider) UpdateRelease(owner string, repoName string, tag string, releaseInfo *GitRelease) error

func (*FakeProvider) UserAuth

func (f *FakeProvider) UserAuth() auth.UserAuth

func (*FakeProvider) UserInfo

func (f *FakeProvider) UserInfo(username string) *GitUser

func (*FakeProvider) ValidateRepositoryName

func (f *FakeProvider) ValidateRepositoryName(org string, name string) error

type FakeProviderType

type FakeProviderType int
const (
	GitHub FakeProviderType = iota
	Gitlab
	Gitea
	BitbucketCloud
	BitbucketServer
)

type FakePullRequest

type FakePullRequest struct {
	PullRequest *GitPullRequest
	Commits     []*FakeCommit
	Comment     string
}

type FakeRepository

type FakeRepository struct {
	GitRepo      *GitRepository
	PullRequests map[int]*FakePullRequest
	Issues       map[int]*FakeIssue
	Commits      []*FakeCommit

	Releases map[string]*GitRelease
	// contains filtered or unexported fields
}

type GitCLI

type GitCLI struct{}

GitCLI implements common git actions based on git CLI

func NewGitCLI

func NewGitCLI() *GitCLI

NewGitCLI creates a new GitCLI instance

func (*GitCLI) Add

func (g *GitCLI) Add(dir string, args ...string) error

Add does a git add for all the given arguments

func (*GitCLI) AddCommmit

func (g *GitCLI) AddCommmit(dir string, msg string) error

AddCommit perform an add and commit of the changes from the repository at the given directory with the given messages

func (*GitCLI) AddRemote

func (g *GitCLI) AddRemote(dir string, name string, url string) error

AddRemote adds a remote repository at the given URL and with the given name

func (*GitCLI) Branch

func (g *GitCLI) Branch(dir string) (string, error)

Branch returns the current branch of the repository located at the given directory

func (*GitCLI) Checkout

func (g *GitCLI) Checkout(dir string, branch string) error

Checkout checks out the given branch

func (*GitCLI) CheckoutRemoteBranch

func (g *GitCLI) CheckoutRemoteBranch(dir string, branch string) error

CheckoutRemoteBranch checks out the given remote tracking branch

func (*GitCLI) Clone

func (g *GitCLI) Clone(url string, dir string) error

Clone clones the given git URL into the given directory

func (*GitCLI) CloneOrPull

func (g *GitCLI) CloneOrPull(url string, dir string) error

CloneOrPull clones the given git URL or pull if it already exists

func (*GitCLI) CommitDir

func (g *GitCLI) CommitDir(dir string, message string) error

CommitDir commits all changes from the given directory

func (*GitCLI) CommitIfChanges

func (g *GitCLI) CommitIfChanges(dir string, message string) error

CommiIfChanges does a commit if there are any changes in the repository at the given directory

func (*GitCLI) ConvertToValidBranchName

func (g *GitCLI) ConvertToValidBranchName(name string) string

ConvertToValidBranchName converts the given branch name into a valid git branch string replacing any dodgy characters

func (*GitCLI) CreateBranch

func (g *GitCLI) CreateBranch(dir string, branch string) error

CreateBranch creates a branch with the given name in the git repository from the given directory

func (*GitCLI) CreatePushURL

func (g *GitCLI) CreatePushURL(cloneURL string, userAuth *auth.UserAuth) (string, error)

CreatePushURL creates the git repository URL with the username and password encoded for HTTPS based URLs

func (*GitCLI) CreateTag

func (g *GitCLI) CreateTag(dir string, tag string, msg string) error

CreateTag creates a tag with the given name and message in the repository at the given directory

func (*GitCLI) DiscoverRemoteGitURL

func (g *GitCLI) DiscoverRemoteGitURL(gitConf string) (string, error)

DiscoverRemoteGitURL discovers the remote git URL from the given git configuration

func (*GitCLI) DiscoverUpstreamGitURL

func (g *GitCLI) DiscoverUpstreamGitURL(gitConf string) (string, error)

DiscoverUpstreamGitURL discovers the upstream git URL from the given git configuration

func (*GitCLI) Email

func (g *GitCLI) Email(dir string) (string, error)

Email returns the email from the git configuration

func (*GitCLI) FetchTags

func (g *GitCLI) FetchTags(dir string) error

FetchTags fetches all the tags

func (*GitCLI) FindGitConfigDir

func (g *GitCLI) FindGitConfigDir(dir string) (string, string, error)

FindGitConfigDir tries to find the `.git` directory either in the current directory or in parent directories

func (*GitCLI) ForcePushBranch

func (g *GitCLI) ForcePushBranch(dir string, localBranch string, remoteBranch string) error

ForcePushBranch does a force push of the local branch into the remote branch of the repository at the given directory

func (*GitCLI) GetAuthorEmailForCommit

func (g *GitCLI) GetAuthorEmailForCommit(dir string, sha string) (string, error)

GetAuthorEmailForCommit returns the author email from commit message with the given SHA

func (*GitCLI) GetCurrentGitTagSHA

func (g *GitCLI) GetCurrentGitTagSHA(dir string) (string, error)

GetCurrentGitTagSHA return the SHA of the current git tag from the repository at the given directory

func (*GitCLI) GetPreviousGitTagSHA

func (g *GitCLI) GetPreviousGitTagSHA(dir string) (string, error)

GetPreviousGitTagSHA returns the previous git tag from the repository at the given directory

func (*GitCLI) GetRemoteUrl

func (g *GitCLI) GetRemoteUrl(config *gitcfg.Config, name string) string

GetRemoteUrl returns the remote URL from the given git config

func (*GitCLI) GetRevisionBeforeDate

func (g *GitCLI) GetRevisionBeforeDate(dir string, t time.Time) (string, error)

GetRevisionBeforeDate returns the revision before the given date

func (*GitCLI) GetRevisionBeforeDateText

func (g *GitCLI) GetRevisionBeforeDateText(dir string, dateText string) (string, error)

GetRevisionBeforeDateText returns the revision before the given date in format "MonthName dayNumber year"

func (*GitCLI) HasChanges

func (g *GitCLI) HasChanges(dir string) (bool, error)

HasChanges indicates if there are any changes in the repository from the given directory

func (*GitCLI) Info

func (g *GitCLI) Info(dir string) (*GitRepositoryInfo, error)

Info returns the git info of the repository at the given directory

func (*GitCLI) Init

func (g *GitCLI) Init(dir string) error

Init inits a git repository into the given directory

func (*GitCLI) IsFork

func (g *GitCLI) IsFork(gitProvider GitProvider, gitInfo *GitRepositoryInfo, dir string) (bool, error)

IsFork indicates if the repository at the given directory is a fork

func (*GitCLI) PrintCreateRepositoryGenerateAccessToken

func (g *GitCLI) PrintCreateRepositoryGenerateAccessToken(server *auth.AuthServer, username string, o io.Writer)

PrintCreateRepositoryGenerateAccessToken prints the access token URL of a git repository

func (*GitCLI) Pull

func (g *GitCLI) Pull(dir string) error

Pull pulls the git repository in the given directory

func (*GitCLI) PullUpstream

func (g *GitCLI) PullUpstream(dir string) error

PullUpstream pulls the remote upstream branch into master branch into the given directory

func (*GitCLI) Push

func (g *GitCLI) Push(dir string) error

Push pushes the changes from the repository at the given directory

func (*GitCLI) PushMaster

func (g *GitCLI) PushMaster(dir string) error

PushMaster pushes the master branch into the origin

func (*GitCLI) PushTag

func (g *GitCLI) PushTag(dir string, tag string) error

Pushtag pushes the given tag into the origin

func (*GitCLI) RemoteBranchNames

func (g *GitCLI) RemoteBranchNames(dir string, prefix string) ([]string, error)

RemoteBranches returns all remote branches with the given prefix

func (*GitCLI) RemoteBranches

func (g *GitCLI) RemoteBranches(dir string) ([]string, error)

RemoteBranches returns the remote branches

func (*GitCLI) Remove

func (g *GitCLI) Remove(dir, fileName string) error

Remove removes the given file from a git repository located at the given directory

func (*GitCLI) RepoName

func (g *GitCLI) RepoName(org, repoName string) string

RepoName formats the repository names based on the organization

func (*GitCLI) Server

func (g *GitCLI) Server(dir string) (string, error)

Server returns the git server of the repository at the given directory

func (*GitCLI) SetEmail

func (g *GitCLI) SetEmail(dir string, email string) error

SetEmail sets the given email in the git configuration

func (*GitCLI) SetRemoteURL

func (g *GitCLI) SetRemoteURL(dir string, name string, gitURL string) error

SetRemoteURL sets the remote URL of the remote with the given name

func (*GitCLI) SetUsername

func (g *GitCLI) SetUsername(dir string, username string) error

SetUsername sets the username in the git configuration

func (*GitCLI) Stash

func (g *GitCLI) Stash(dir string) error

Stash stashes the current changes from the given directory

func (*GitCLI) Status

func (g *GitCLI) Status(dir string) error

Status returns the status of the git repository at the given directory

func (*GitCLI) Tags

func (g *GitCLI) Tags(dir string) ([]string, error)

Tags returns all tags from the repository at the given directory

func (*GitCLI) ToGitLabels

func (g *GitCLI) ToGitLabels(names []string) []GitLabel

ToGitLabels converts the list of label names into an array of GitLabels

func (*GitCLI) UpdateRemote

func (g *GitCLI) UpdateRemote(dir, url string) error

UpdateRemote updates the URL of the remote repository

func (*GitCLI) Username

func (g *GitCLI) Username(dir string) (string, error)

Username return the username from the git configuration

func (*GitCLI) Version

func (g *GitCLI) Version() (string, error)

Version returns the git version

type GitCommit

type GitCommit struct {
	SHA       string
	Message   string
	Author    *GitUser
	URL       string
	Branch    string
	Committer *GitUser
}

type GitFake

type GitFake struct {
	Remotes        []GitRemote
	Branches       []string
	BranchesRemote []string
	CurrentBranch  string
	AccessTokenURL string
	RepoInfo       GitRepositoryInfo
	Fork           bool
	GitVersion     string
	UserInfo       GitUser
	Commits        []GitCommit
	Changes        bool
	GitTags        []GitTag
	Revision       string
}

func (*GitFake) Add

func (g *GitFake) Add(dir string, args ...string) error

func (*GitFake) AddCommmit

func (g *GitFake) AddCommmit(dir string, msg string) error

func (*GitFake) AddRemote

func (g *GitFake) AddRemote(dir string, name string, url string) error

func (*GitFake) Branch

func (g *GitFake) Branch(dir string) (string, error)

func (*GitFake) Checkout

func (g *GitFake) Checkout(dir string, branch string) error

func (*GitFake) CheckoutRemoteBranch

func (g *GitFake) CheckoutRemoteBranch(dir string, branch string) error

func (*GitFake) Clone

func (g *GitFake) Clone(url string, directory string) error

func (*GitFake) CloneOrPull

func (g *GitFake) CloneOrPull(url string, directory string) error

func (*GitFake) CommitDir

func (g *GitFake) CommitDir(dir string, message string) error

func (*GitFake) CommitIfChanges

func (g *GitFake) CommitIfChanges(dir string, message string) error

func (*GitFake) ConvertToValidBranchName

func (g *GitFake) ConvertToValidBranchName(name string) string

func (*GitFake) CreateBranch

func (g *GitFake) CreateBranch(dir string, branch string) error

func (*GitFake) CreatePushURL

func (g *GitFake) CreatePushURL(cloneURL string, userAuth *auth.UserAuth) (string, error)

func (*GitFake) CreateTag

func (g *GitFake) CreateTag(dir string, tag string, msg string) error

func (*GitFake) DiscoverRemoteGitURL

func (g *GitFake) DiscoverRemoteGitURL(gitConf string) (string, error)

func (*GitFake) DiscoverUpstreamGitURL

func (g *GitFake) DiscoverUpstreamGitURL(gitConf string) (string, error)

func (*GitFake) Email

func (g *GitFake) Email(dir string) (string, error)

func (*GitFake) FetchTags

func (g *GitFake) FetchTags(dir string) error

func (*GitFake) FindGitConfigDir

func (g *GitFake) FindGitConfigDir(dir string) (string, string, error)

func (*GitFake) ForcePushBranch

func (g *GitFake) ForcePushBranch(dir string, localBranch string, remoteBranch string) error

func (*GitFake) GetAuthorEmailForCommit

func (g *GitFake) GetAuthorEmailForCommit(dir string, sha string) (string, error)

func (*GitFake) GetCurrentGitTagSHA

func (g *GitFake) GetCurrentGitTagSHA(dir string) (string, error)

func (*GitFake) GetPreviousGitTagSHA

func (g *GitFake) GetPreviousGitTagSHA(dir string) (string, error)

func (*GitFake) GetRemoteUrl

func (g *GitFake) GetRemoteUrl(config *gitcfg.Config, name string) string

func (*GitFake) GetRevisionBeforeDate

func (g *GitFake) GetRevisionBeforeDate(dir string, t time.Time) (string, error)

func (*GitFake) GetRevisionBeforeDateText

func (g *GitFake) GetRevisionBeforeDateText(dir string, dateText string) (string, error)

func (*GitFake) HasChanges

func (g *GitFake) HasChanges(dir string) (bool, error)

func (*GitFake) Info

func (g *GitFake) Info(dir string) (*GitRepositoryInfo, error)

func (*GitFake) Init

func (g *GitFake) Init(dir string) error

func (*GitFake) IsFork

func (g *GitFake) IsFork(gitProvider GitProvider, gitInfo *GitRepositoryInfo, dir string) (bool, error)

func (*GitFake) PrintCreateRepositoryGenerateAccessToken

func (g *GitFake) PrintCreateRepositoryGenerateAccessToken(server *auth.AuthServer, username string, o io.Writer)

func (*GitFake) Pull

func (g *GitFake) Pull(dir string) error

func (*GitFake) PullUpstream

func (g *GitFake) PullUpstream(dir string) error

func (*GitFake) Push

func (g *GitFake) Push(dir string) error

func (*GitFake) PushMaster

func (g *GitFake) PushMaster(dir string) error

func (*GitFake) PushTag

func (g *GitFake) PushTag(dir string, tag string) error

func (*GitFake) RemoteBranchNames

func (g *GitFake) RemoteBranchNames(dir string, prefix string) ([]string, error)

func (*GitFake) RemoteBranches

func (g *GitFake) RemoteBranches(dir string) ([]string, error)

func (*GitFake) Remove

func (g *GitFake) Remove(dir string, fileName string) error

func (*GitFake) RepoName

func (g *GitFake) RepoName(org string, repoName string) string

func (*GitFake) Server

func (g *GitFake) Server(dir string) (string, error)

func (*GitFake) SetEmail

func (g *GitFake) SetEmail(dir string, email string) error

func (*GitFake) SetRemoteURL

func (g *GitFake) SetRemoteURL(dir string, name string, gitURL string) error

func (*GitFake) SetUsername

func (g *GitFake) SetUsername(dir string, username string) error

func (*GitFake) Stash

func (g *GitFake) Stash(dir string) error

func (*GitFake) Status

func (g *GitFake) Status(dir string) error

func (*GitFake) Tags

func (g *GitFake) Tags(dir string) ([]string, error)

func (*GitFake) ToGitLabels

func (g *GitFake) ToGitLabels(names []string) []GitLabel

func (*GitFake) UpdateRemote

func (g *GitFake) UpdateRemote(dir string, url string) error

func (*GitFake) Username

func (g *GitFake) Username(dir string) (string, error)

func (*GitFake) Version

func (g *GitFake) Version() (string, error)

type GitHubProvider

type GitHubProvider struct {
	Username string
	Client   *github.Client
	Context  context.Context

	Server auth.AuthServer
	User   auth.UserAuth
	Git    Gitter
}

func (*GitHubProvider) AddPRComment

func (p *GitHubProvider) AddPRComment(pr *GitPullRequest, comment string) error

func (*GitHubProvider) CreateIssue

func (p *GitHubProvider) CreateIssue(owner string, repo string, issue *GitIssue) (*GitIssue, error)

func (*GitHubProvider) CreateIssueComment

func (p *GitHubProvider) CreateIssueComment(owner string, repo string, number int, comment string) error

func (*GitHubProvider) CreatePullRequest

func (p *GitHubProvider) CreatePullRequest(data *GitPullRequestArguments) (*GitPullRequest, error)

func (*GitHubProvider) CreateRepository

func (p *GitHubProvider) CreateRepository(org string, name string, private bool) (*GitRepository, error)

func (*GitHubProvider) CreateWebHook

func (p *GitHubProvider) CreateWebHook(data *GitWebHookArguments) error

func (*GitHubProvider) CurrentUsername

func (p *GitHubProvider) CurrentUsername() string

func (*GitHubProvider) DeleteRepository

func (p *GitHubProvider) DeleteRepository(org string, name string) error

func (*GitHubProvider) ForkRepository

func (p *GitHubProvider) ForkRepository(originalOrg string, name string, destinationOrg string) (*GitRepository, error)

func (*GitHubProvider) GetEnterpriseApiURL

func (p *GitHubProvider) GetEnterpriseApiURL() string

GetEnterpriseApiURL returns the github enterprise API URL or blank if this provider is for the https://github.com service

func (*GitHubProvider) GetIssue

func (p *GitHubProvider) GetIssue(org string, name string, number int) (*GitIssue, error)

func (*GitHubProvider) GetPullRequest

func (p *GitHubProvider) GetPullRequest(owner string, repo *GitRepositoryInfo, number int) (*GitPullRequest, error)

func (*GitHubProvider) GetPullRequestCommits

func (p *GitHubProvider) GetPullRequestCommits(owner string, repository *GitRepositoryInfo, number int) ([]*GitCommit, error)

func (*GitHubProvider) GetRepository

func (p *GitHubProvider) GetRepository(org string, name string) (*GitRepository, error)

func (*GitHubProvider) HasIssues

func (p *GitHubProvider) HasIssues() bool

func (*GitHubProvider) IsBitbucketCloud

func (p *GitHubProvider) IsBitbucketCloud() bool

func (*GitHubProvider) IsBitbucketServer

func (p *GitHubProvider) IsBitbucketServer() bool

func (*GitHubProvider) IsGitHub

func (p *GitHubProvider) IsGitHub() bool

func (*GitHubProvider) IsGitea

func (p *GitHubProvider) IsGitea() bool

func (*GitHubProvider) IssueURL

func (p *GitHubProvider) IssueURL(org string, name string, number int, isPull bool) string

func (*GitHubProvider) JenkinsWebHookPath

func (p *GitHubProvider) JenkinsWebHookPath(gitURL string, secret string) string

func (*GitHubProvider) Kind

func (p *GitHubProvider) Kind() string

func (*GitHubProvider) Label

func (p *GitHubProvider) Label() string

func (*GitHubProvider) ListCommitStatus

func (p *GitHubProvider) ListCommitStatus(org string, repo string, sha string) ([]*GitRepoStatus, error)

func (*GitHubProvider) ListOrganisations

func (p *GitHubProvider) ListOrganisations() ([]GitOrganisation, error)

func (*GitHubProvider) ListReleases

func (p *GitHubProvider) ListReleases(org string, name string) ([]*GitRelease, error)

func (*GitHubProvider) ListRepositories

func (p *GitHubProvider) ListRepositories(org string) ([]*GitRepository, error)

func (*GitHubProvider) MergePullRequest

func (p *GitHubProvider) MergePullRequest(pr *GitPullRequest, message string) error

func (*GitHubProvider) PullRequestLastCommitStatus

func (p *GitHubProvider) PullRequestLastCommitStatus(pr *GitPullRequest) (string, error)

func (*GitHubProvider) RenameRepository

func (p *GitHubProvider) RenameRepository(org string, name string, newName string) (*GitRepository, error)

func (*GitHubProvider) SearchIssues

func (p *GitHubProvider) SearchIssues(org string, name string, filter string) ([]*GitIssue, error)

func (*GitHubProvider) SearchIssuesClosedSince

func (p *GitHubProvider) SearchIssuesClosedSince(org string, name string, t time.Time) ([]*GitIssue, error)

func (*GitHubProvider) ServerURL

func (p *GitHubProvider) ServerURL() string

func (*GitHubProvider) UpdatePullRequestStatus

func (p *GitHubProvider) UpdatePullRequestStatus(pr *GitPullRequest) error

func (*GitHubProvider) UpdateRelease

func (p *GitHubProvider) UpdateRelease(owner string, repo string, tag string, releaseInfo *GitRelease) error

func (*GitHubProvider) UserAuth

func (p *GitHubProvider) UserAuth() auth.UserAuth

func (*GitHubProvider) UserInfo

func (p *GitHubProvider) UserInfo(username string) *GitUser

func (*GitHubProvider) ValidateRepositoryName

func (p *GitHubProvider) ValidateRepositoryName(org string, name string) error

type GitIssue

type GitIssue struct {
	URL           string
	Owner         string
	Repo          string
	Number        *int
	Key           string
	Title         string
	Body          string
	State         *string
	Labels        []GitLabel
	StatusesURL   *string
	IssueURL      *string
	CreatedAt     *time.Time
	UpdatedAt     *time.Time
	ClosedAt      *time.Time
	IsPullRequest bool
	User          *GitUser
	ClosedBy      *GitUser
	Assignees     []GitUser
}

func BitbucketIssueToGitIssue

func BitbucketIssueToGitIssue(bIssue bitbucket.Issue) *GitIssue

func FilterIssuesClosedSince

func FilterIssuesClosedSince(issues []*GitIssue, t time.Time) []*GitIssue

FilterIssuesClosedSince returns a filtered slice of all the issues closed since the given date

func (*GitIssue) IsClosedSince

func (i *GitIssue) IsClosedSince(t time.Time) bool

IsClosedSince returns true if the issue has been closed since the given da

func (*GitIssue) Name

func (i *GitIssue) Name() string

Name returns the textual name of the issue

type GitLabel

type GitLabel struct {
	URL   string
	Name  string
	Color string
}

type GitOrganisation

type GitOrganisation struct {
	Login string
}

type GitProvider

type GitProvider interface {
	OrganisationLister

	ListRepositories(org string) ([]*GitRepository, error)

	CreateRepository(org string, name string, private bool) (*GitRepository, error)

	GetRepository(org string, name string) (*GitRepository, error)

	DeleteRepository(org string, name string) error

	ForkRepository(originalOrg string, name string, destinationOrg string) (*GitRepository, error)

	RenameRepository(org string, name string, newName string) (*GitRepository, error)

	ValidateRepositoryName(org string, name string) error

	CreatePullRequest(data *GitPullRequestArguments) (*GitPullRequest, error)

	UpdatePullRequestStatus(pr *GitPullRequest) error

	GetPullRequest(owner string, repo *GitRepositoryInfo, number int) (*GitPullRequest, error)

	GetPullRequestCommits(owner string, repo *GitRepositoryInfo, number int) ([]*GitCommit, error)

	PullRequestLastCommitStatus(pr *GitPullRequest) (string, error)

	ListCommitStatus(org string, repo string, sha string) ([]*GitRepoStatus, error)

	MergePullRequest(pr *GitPullRequest, message string) error

	CreateWebHook(data *GitWebHookArguments) error

	IsGitHub() bool

	IsGitea() bool

	IsBitbucketCloud() bool

	IsBitbucketServer() bool

	Kind() string

	GetIssue(org string, name string, number int) (*GitIssue, error)

	IssueURL(org string, name string, number int, isPull bool) string

	SearchIssues(org string, name string, query string) ([]*GitIssue, error)

	SearchIssuesClosedSince(org string, name string, t time.Time) ([]*GitIssue, error)

	CreateIssue(owner string, repo string, issue *GitIssue) (*GitIssue, error)

	HasIssues() bool

	AddPRComment(pr *GitPullRequest, comment string) error

	CreateIssueComment(owner string, repo string, number int, comment string) error

	UpdateRelease(owner string, repo string, tag string, releaseInfo *GitRelease) error

	ListReleases(org string, name string) ([]*GitRelease, error)

	JenkinsWebHookPath(gitURL string, secret string) string

	// Label returns the git service label or name
	Label() string

	// ServerURL returns the git server URL
	ServerURL() string

	// Returns the current username
	CurrentUsername() string

	// Returns the current user auth
	UserAuth() auth.UserAuth

	// Returns user info, if possible
	UserInfo(username string) *GitUser
}

func CreateProvider

func CreateProvider(server *auth.AuthServer, user *auth.UserAuth, git Gitter) (GitProvider, error)

func CreateProviderForURL

func CreateProviderForURL(authConfigSvc auth.AuthConfigService, gitKind string, hostUrl string, git Gitter) (GitProvider, error)

CreateProviderForURL creates the git provider for the given git kind and host URL

func NewBitbucketCloudProvider

func NewBitbucketCloudProvider(server *auth.AuthServer, user *auth.UserAuth, git Gitter) (GitProvider, error)

func NewBitbucketServerProvider

func NewBitbucketServerProvider(server *auth.AuthServer, user *auth.UserAuth, git Gitter) (GitProvider, error)

func NewGitHubProvider

func NewGitHubProvider(server *auth.AuthServer, user *auth.UserAuth, git Gitter) (GitProvider, error)

func NewGiteaProvider

func NewGiteaProvider(server *auth.AuthServer, user *auth.UserAuth, git Gitter) (GitProvider, error)

func NewGitlabProvider

func NewGitlabProvider(server *auth.AuthServer, user *auth.UserAuth, git Gitter) (GitProvider, error)

type GitPullRequest

type GitPullRequest struct {
	URL            string
	Author         *GitUser
	Owner          string
	Repo           string
	Number         *int
	Mergeable      *bool
	Merged         *bool
	HeadRef        *string
	State          *string
	StatusesURL    *string
	IssueURL       *string
	DiffURL        *string
	MergeCommitSHA *string
	ClosedAt       *time.Time
	MergedAt       *time.Time
	LastCommitSha  string
	Title          string
	Body           string
}

func (*GitPullRequest) IsClosed

func (pr *GitPullRequest) IsClosed() bool

IsClosed returns true if the PullRequest has been closed

type GitPullRequestArguments

type GitPullRequestArguments struct {
	Title             string
	Body              string
	Head              string
	Base              string
	GitRepositoryInfo *GitRepositoryInfo
}

type GitRelease

type GitRelease struct {
	Name          string
	TagName       string
	Body          string
	URL           string
	HTMLURL       string
	DownloadCount int
}

type GitRemote

type GitRemote struct {
	Name string
	URL  string
}

type GitRepoStatus

type GitRepoStatus struct {
	ID      string
	Context string
	URL     string

	// State is the current state of the repository. Possible values are:
	// pending, success, error, or failure.
	State string `json:"state,omitempty"`

	// TargetURL is the URL of the page representing this status
	TargetURL string `json:"target_url,omitempty"`

	// Description is a short high level summary of the status.
	Description string
}

func (*GitRepoStatus) IsFailed

func (s *GitRepoStatus) IsFailed() bool

func (*GitRepoStatus) IsSuccess

func (s *GitRepoStatus) IsSuccess() bool

type GitRepository

type GitRepository struct {
	Name             string
	AllowMergeCommit bool
	HTMLURL          string
	CloneURL         string
	SSHURL           string
	Language         string
	Fork             bool
	Stars            int
}

func BitbucketRepositoryToGitRepository

func BitbucketRepositoryToGitRepository(bRepo bitbucket.Repository) *GitRepository

func BitbucketServerRepositoryToGitRepository

func BitbucketServerRepositoryToGitRepository(bRepo bitbucket.Repository) *GitRepository

func PickRepositories

func PickRepositories(provider GitProvider, owner string, message string, selectAll bool, filter string) ([]*GitRepository, error)

type GitRepositoryInfo

type GitRepositoryInfo struct {
	URL          string
	Scheme       string
	Host         string
	Organisation string
	Name         string
	Project      string
}

func ParseGitURL

func ParseGitURL(text string) (*GitRepositoryInfo, error)

ParseGitURL attempts to parse the given text as a URL or git URL-like string to determine the protocol, host, organisation and name

func (*GitRepositoryInfo) CreateProvider

func (i *GitRepositoryInfo) CreateProvider(authConfigSvc auth.AuthConfigService, gitKind string, git Gitter) (GitProvider, error)

func (*GitRepositoryInfo) CreateProviderForUser

func (i *GitRepositoryInfo) CreateProviderForUser(server *auth.AuthServer, user *auth.UserAuth, gitKind string, git Gitter) (GitProvider, error)

func (*GitRepositoryInfo) HostURL

func (i *GitRepositoryInfo) HostURL() string

HostURL returns the URL to the host

func (*GitRepositoryInfo) HostURLWithoutUser

func (i *GitRepositoryInfo) HostURLWithoutUser() string

func (*GitRepositoryInfo) HttpCloneURL

func (i *GitRepositoryInfo) HttpCloneURL() string

HttpCloneURL returns the HTTPS git URL this repository

func (*GitRepositoryInfo) HttpURL

func (i *GitRepositoryInfo) HttpURL() string

HttpURL returns the URL to browse this repository in a web browser

func (*GitRepositoryInfo) HttpsURL

func (i *GitRepositoryInfo) HttpsURL() string

HttpsURL returns the URL to browse this repository in a web browser

func (*GitRepositoryInfo) IsGitHub

func (i *GitRepositoryInfo) IsGitHub() bool

func (*GitRepositoryInfo) PickOrCreateProvider

func (i *GitRepositoryInfo) PickOrCreateProvider(authConfigSvc auth.AuthConfigService, message string, batchMode bool, gitKind string, git Gitter) (GitProvider, error)

func (*GitRepositoryInfo) PipelinePath

func (i *GitRepositoryInfo) PipelinePath() string

PipelinePath returns the pipeline path for the master branch which can be used to query pipeline logs in `jx get build logs myPipelinePath`

func (*GitRepositoryInfo) PullRequestURL

func (i *GitRepositoryInfo) PullRequestURL(prName string) string

PullRequestURL returns the URL of a pull request of the given name/number

type GitRepositoryOptions

type GitRepositoryOptions struct {
	ServerURL string
	Username  string
	ApiToken  string
	Owner     string
}

type GitTag

type GitTag struct {
	Name    string
	Message string
}

type GitUser

type GitUser struct {
	URL       string
	Login     string
	Name      string
	Email     string
	AvatarURL string
}

type GitWebHookArguments

type GitWebHookArguments struct {
	Owner  string
	Repo   *GitRepositoryInfo
	URL    string
	Secret string
}

type GiteaProvider

type GiteaProvider struct {
	Username string
	Client   *gitea.Client

	Server auth.AuthServer
	User   auth.UserAuth
	Git    Gitter
}

func (*GiteaProvider) AddPRComment

func (p *GiteaProvider) AddPRComment(pr *GitPullRequest, comment string) error

func (*GiteaProvider) CreateIssue

func (p *GiteaProvider) CreateIssue(owner string, repo string, issue *GitIssue) (*GitIssue, error)

func (*GiteaProvider) CreateIssueComment

func (p *GiteaProvider) CreateIssueComment(owner string, repo string, number int, comment string) error

func (*GiteaProvider) CreatePullRequest

func (p *GiteaProvider) CreatePullRequest(data *GitPullRequestArguments) (*GitPullRequest, error)

func (*GiteaProvider) CreateRepository

func (p *GiteaProvider) CreateRepository(org string, name string, private bool) (*GitRepository, error)

func (*GiteaProvider) CreateWebHook

func (p *GiteaProvider) CreateWebHook(data *GitWebHookArguments) error

func (*GiteaProvider) CurrentUsername

func (p *GiteaProvider) CurrentUsername() string

func (*GiteaProvider) DeleteRepository

func (p *GiteaProvider) DeleteRepository(org string, name string) error

func (*GiteaProvider) ForkRepository

func (p *GiteaProvider) ForkRepository(originalOrg string, name string, destinationOrg string) (*GitRepository, error)

func (*GiteaProvider) GetIssue

func (p *GiteaProvider) GetIssue(org string, name string, number int) (*GitIssue, error)

func (*GiteaProvider) GetPullRequest

func (p *GiteaProvider) GetPullRequest(owner string, repo *GitRepositoryInfo, number int) (*GitPullRequest, error)

func (*GiteaProvider) GetPullRequestCommits

func (p *GiteaProvider) GetPullRequestCommits(owner string, repository *GitRepositoryInfo, number int) ([]*GitCommit, error)

func (*GiteaProvider) GetRepository

func (p *GiteaProvider) GetRepository(org string, name string) (*GitRepository, error)

func (*GiteaProvider) HasIssues

func (p *GiteaProvider) HasIssues() bool

func (*GiteaProvider) IsBitbucketCloud

func (p *GiteaProvider) IsBitbucketCloud() bool

func (*GiteaProvider) IsBitbucketServer

func (p *GiteaProvider) IsBitbucketServer() bool

func (*GiteaProvider) IsGitHub

func (p *GiteaProvider) IsGitHub() bool

func (*GiteaProvider) IsGitea

func (p *GiteaProvider) IsGitea() bool

func (*GiteaProvider) IssueURL

func (p *GiteaProvider) IssueURL(org string, name string, number int, isPull bool) string

func (*GiteaProvider) JenkinsWebHookPath

func (p *GiteaProvider) JenkinsWebHookPath(gitURL string, secret string) string

func (*GiteaProvider) Kind

func (p *GiteaProvider) Kind() string

func (*GiteaProvider) Label

func (p *GiteaProvider) Label() string

func (*GiteaProvider) ListCommitStatus

func (p *GiteaProvider) ListCommitStatus(org string, repo string, sha string) ([]*GitRepoStatus, error)

func (*GiteaProvider) ListOrganisations

func (p *GiteaProvider) ListOrganisations() ([]GitOrganisation, error)

func (*GiteaProvider) ListReleases

func (p *GiteaProvider) ListReleases(org string, name string) ([]*GitRelease, error)

func (*GiteaProvider) ListRepositories

func (p *GiteaProvider) ListRepositories(org string) ([]*GitRepository, error)

func (*GiteaProvider) MergePullRequest

func (p *GiteaProvider) MergePullRequest(pr *GitPullRequest, message string) error

func (*GiteaProvider) PullRequestLastCommitStatus

func (p *GiteaProvider) PullRequestLastCommitStatus(pr *GitPullRequest) (string, error)

func (*GiteaProvider) RenameRepository

func (p *GiteaProvider) RenameRepository(org string, name string, newName string) (*GitRepository, error)

func (*GiteaProvider) SearchIssues

func (p *GiteaProvider) SearchIssues(org string, name string, filter string) ([]*GitIssue, error)

func (*GiteaProvider) SearchIssuesClosedSince

func (p *GiteaProvider) SearchIssuesClosedSince(org string, name string, t time.Time) ([]*GitIssue, error)

func (*GiteaProvider) ServerURL

func (p *GiteaProvider) ServerURL() string

func (*GiteaProvider) UpdatePullRequestStatus

func (p *GiteaProvider) UpdatePullRequestStatus(pr *GitPullRequest) error

func (*GiteaProvider) UpdateRelease

func (p *GiteaProvider) UpdateRelease(owner string, repo string, tag string, releaseInfo *GitRelease) error

func (*GiteaProvider) UserAuth

func (p *GiteaProvider) UserAuth() auth.UserAuth

func (*GiteaProvider) UserInfo

func (p *GiteaProvider) UserInfo(username string) *GitUser

func (*GiteaProvider) ValidateRepositoryName

func (p *GiteaProvider) ValidateRepositoryName(org string, name string) error

type GitlabProvider

type GitlabProvider struct {
	Username string
	Client   *gitlab.Client
	Context  context.Context

	Server auth.AuthServer
	User   auth.UserAuth
	Git    Gitter
}

func (*GitlabProvider) AddPRComment

func (g *GitlabProvider) AddPRComment(pr *GitPullRequest, comment string) error

func (*GitlabProvider) CreateIssue

func (g *GitlabProvider) CreateIssue(owner string, repo string, issue *GitIssue) (*GitIssue, error)

func (*GitlabProvider) CreateIssueComment

func (g *GitlabProvider) CreateIssueComment(owner string, repo string, number int, comment string) error

func (*GitlabProvider) CreatePullRequest

func (g *GitlabProvider) CreatePullRequest(data *GitPullRequestArguments) (*GitPullRequest, error)

func (*GitlabProvider) CreateRepository

func (g *GitlabProvider) CreateRepository(org string, name string, private bool) (*GitRepository, error)

func (*GitlabProvider) CreateWebHook

func (g *GitlabProvider) CreateWebHook(data *GitWebHookArguments) error

func (*GitlabProvider) CurrentUsername

func (p *GitlabProvider) CurrentUsername() string

func (*GitlabProvider) DeleteRepository

func (g *GitlabProvider) DeleteRepository(org, name string) error

func (*GitlabProvider) ForkRepository

func (g *GitlabProvider) ForkRepository(originalOrg, name, destinationOrg string) (*GitRepository, error)

func (*GitlabProvider) GetIssue

func (g *GitlabProvider) GetIssue(org, repo string, number int) (*GitIssue, error)

func (*GitlabProvider) GetPullRequest

func (p *GitlabProvider) GetPullRequest(owner string, repo *GitRepositoryInfo, number int) (*GitPullRequest, error)

func (*GitlabProvider) GetPullRequestCommits

func (p *GitlabProvider) GetPullRequestCommits(owner string, repository *GitRepositoryInfo, number int) ([]*GitCommit, error)

func (*GitlabProvider) GetRepository

func (g *GitlabProvider) GetRepository(org, name string) (*GitRepository, error)

func (*GitlabProvider) HasIssues

func (g *GitlabProvider) HasIssues() bool

func (*GitlabProvider) IsBitbucketCloud

func (g *GitlabProvider) IsBitbucketCloud() bool

func (*GitlabProvider) IsBitbucketServer

func (g *GitlabProvider) IsBitbucketServer() bool

func (*GitlabProvider) IsGitHub

func (g *GitlabProvider) IsGitHub() bool

func (*GitlabProvider) IsGitea

func (g *GitlabProvider) IsGitea() bool

func (*GitlabProvider) IssueURL

func (p *GitlabProvider) IssueURL(org string, name string, number int, isPull bool) string

func (*GitlabProvider) JenkinsWebHookPath

func (g *GitlabProvider) JenkinsWebHookPath(gitURL string, secret string) string

func (*GitlabProvider) Kind

func (g *GitlabProvider) Kind() string

func (*GitlabProvider) Label

func (g *GitlabProvider) Label() string

func (*GitlabProvider) ListCommitStatus

func (g *GitlabProvider) ListCommitStatus(org string, repo string, sha string) ([]*GitRepoStatus, error)

func (*GitlabProvider) ListOrganisations

func (g *GitlabProvider) ListOrganisations() ([]GitOrganisation, error)

func (*GitlabProvider) ListReleases

func (g *GitlabProvider) ListReleases(org string, name string) ([]*GitRelease, error)

func (*GitlabProvider) ListRepositories

func (g *GitlabProvider) ListRepositories(org string) ([]*GitRepository, error)

func (*GitlabProvider) MergePullRequest

func (g *GitlabProvider) MergePullRequest(pr *GitPullRequest, message string) error

func (*GitlabProvider) PullRequestLastCommitStatus

func (g *GitlabProvider) PullRequestLastCommitStatus(pr *GitPullRequest) (string, error)

func (*GitlabProvider) RenameRepository

func (g *GitlabProvider) RenameRepository(org, name, newName string) (*GitRepository, error)

func (*GitlabProvider) SearchIssues

func (g *GitlabProvider) SearchIssues(org, repo, query string) ([]*GitIssue, error)

func (*GitlabProvider) SearchIssuesClosedSince

func (g *GitlabProvider) SearchIssuesClosedSince(org string, repo string, t time.Time) ([]*GitIssue, error)

func (*GitlabProvider) ServerURL

func (p *GitlabProvider) ServerURL() string

func (*GitlabProvider) UpdatePullRequestStatus

func (g *GitlabProvider) UpdatePullRequestStatus(pr *GitPullRequest) error

func (*GitlabProvider) UpdateRelease

func (g *GitlabProvider) UpdateRelease(owner string, repo string, tag string, releaseInfo *GitRelease) error

func (*GitlabProvider) UserAuth

func (p *GitlabProvider) UserAuth() auth.UserAuth

func (*GitlabProvider) UserInfo

func (p *GitlabProvider) UserInfo(username string) *GitUser

func (*GitlabProvider) ValidateRepositoryName

func (g *GitlabProvider) ValidateRepositoryName(org, name string) error

type Gitter

type Gitter interface {
	FindGitConfigDir(dir string) (string, string, error)
	ToGitLabels(names []string) []GitLabel
	PrintCreateRepositoryGenerateAccessToken(server *auth.AuthServer, username string, o io.Writer)

	Status(dir string) error
	Server(dir string) (string, error)
	Info(dir string) (*GitRepositoryInfo, error)
	IsFork(gitProvider GitProvider, gitInfo *GitRepositoryInfo, dir string) (bool, error)
	Version() (string, error)
	RepoName(org, repoName string) string

	Username(dir string) (string, error)
	SetUsername(dir string, username string) error
	Email(dir string) (string, error)
	SetEmail(dir string, email string) error
	GetAuthorEmailForCommit(dir string, sha string) (string, error)

	Init(dir string) error
	Clone(url string, directory string) error
	Push(dir string) error
	PushMaster(dir string) error
	PushTag(dir string, tag string) error
	CreatePushURL(cloneURL string, userAuth *auth.UserAuth) (string, error)
	ForcePushBranch(dir string, localBranch string, remoteBranch string) error
	CloneOrPull(url string, directory string) error
	Pull(dir string) error
	PullUpstream(dir string) error

	AddRemote(dir string, name string, url string) error
	SetRemoteURL(dir string, name string, gitURL string) error
	UpdateRemote(dir, url string) error
	DiscoverRemoteGitURL(gitConf string) (string, error)
	DiscoverUpstreamGitURL(gitConf string) (string, error)
	RemoteBranches(dir string) ([]string, error)
	RemoteBranchNames(dir string, prefix string) ([]string, error)
	GetRemoteUrl(config *gitcfg.Config, name string) string

	Branch(dir string) (string, error)
	CreateBranch(dir string, branch string) error
	CheckoutRemoteBranch(dir string, branch string) error
	Checkout(dir string, branch string) error
	ConvertToValidBranchName(name string) string

	Stash(dir string) error

	Remove(dir, fileName string) error
	Add(dir string, args ...string) error

	CommitIfChanges(dir string, message string) error
	CommitDir(dir string, message string) error
	AddCommmit(dir string, msg string) error
	HasChanges(dir string) (bool, error)

	GetPreviousGitTagSHA(dir string) (string, error)
	GetCurrentGitTagSHA(dir string) (string, error)
	FetchTags(dir string) error
	Tags(dir string) ([]string, error)
	CreateTag(dir string, tag string, msg string) error

	GetRevisionBeforeDate(dir string, t time.Time) (string, error)
	GetRevisionBeforeDateText(dir string, dateText string) (string, error)
}

Gitter defines common git actions used by Jenkins X

type GroupAndCommitInfos

type GroupAndCommitInfos struct {
	// contains filtered or unexported fields
}

type OrganisationLister

type OrganisationLister interface {
	ListOrganisations() ([]GitOrganisation, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL