gits

package
v1.0.53 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitHubHost = "github.com"
)

Variables

This section is empty.

Functions

func ConvertToValidBranchName

func ConvertToValidBranchName(name string) string

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

func DiscoverRemoteGitURL added in v1.0.13

func DiscoverRemoteGitURL(gitConf string) (string, error)

func FindGitConfigDir

func FindGitConfigDir(dir string) (string, string, error)

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

func GetRemoteUrl added in v1.0.13

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

func GitAdd

func GitAdd(dir string, args ...string) error

func GitClone

func GitClone(url string, directory string) error

GitClone clones the given git URL into the given directory

func GitCmd

func GitCmd(dir string, args ...string) error

func GitCommit

func GitCommit(dir string, message string) error

func GitCommitIfChanges

func GitCommitIfChanges(dir string, message string) error

func GitCreatePushURL

func GitCreatePushURL(cloneURL string, userAuth *auth.UserAuth) (string, error)

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

func GitGetRemoteBranchNames added in v1.0.14

func GitGetRemoteBranchNames(dir string, prefix string) ([]string, error)

func GitHubAccessTokenURL added in v1.0.16

func GitHubAccessTokenURL(url string) string

func GitInit

func GitInit(dir string) error

func GitPush

func GitPush(dir string) error

func GitRepoName

func GitRepoName(org, repoName string) string

func GitStatus

func GitStatus(dir string) error

func GiteaAccessTokenURL added in v1.0.16

func GiteaAccessTokenURL(url string) string

func HasChanges

func HasChanges(dir string) (bool, error)

func PickOrganisation

func PickOrganisation(provider GitProvider, userName string) (string, error)

PickOrganisation picks an organisations login if there is one available

func PrintCreateRepositoryGenerateAccessToken added in v1.0.40

func PrintCreateRepositoryGenerateAccessToken(server *auth.AuthServer, o io.Writer)

func ProviderAccessTokenURL added in v1.0.16

func ProviderAccessTokenURL(kind string, url string) string

func SetRemoteURL

func SetRemoteURL(dir string, name string, gitURL string) error

Types

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) (*CreateRepoData, error)

func (*CreateRepoData) CreateRepository

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

type GitHubProvider

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

	Server auth.AuthServer
	User   auth.UserAuth
}

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 added in v1.0.6

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

func (*GitHubProvider) DeleteRepository added in v1.0.6

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) IsGitHub

func (p *GitHubProvider) IsGitHub() bool

func (*GitHubProvider) JenkinsWebHookPath added in v1.0.6

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

func (*GitHubProvider) Label added in v1.0.16

func (p *GitHubProvider) Label() string

func (*GitHubProvider) ListOrganisations

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

func (*GitHubProvider) ListRepositories added in v1.0.6

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

func (*GitHubProvider) RenameRepository

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

func (*GitHubProvider) ValidateRepositoryName

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

type GitOrganisation

type GitOrganisation struct {
	Login string
}

type GitProvider

type GitProvider interface {
	ListOrganisations() ([]GitOrganisation, error)

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

	CreateRepository(org string, name string, private bool) (*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)

	CreateWebHook(data *GitWebHookArguments) error

	IsGitHub() bool

	JenkinsWebHookPath(gitURL string, secret string) string

	Label() string
}

func CreateProvider

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

func NewGitHubProvider

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

func NewGiteaProvider added in v1.0.16

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

type GitPullRequest

type GitPullRequest struct {
	URL string
}

type GitPullRequestArguments

type GitPullRequestArguments struct {
	Owner string
	Repo  string
	Title string
	Body  string
	Head  string
	Base  string
}

type GitRepository

type GitRepository struct {
	Name             string
	AllowMergeCommit bool
	HTMLURL          string
	CloneURL         string
	SSHURL           string
}

func PickRepositories added in v1.0.6

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
}

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) CreateProviderForUser

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

func (*GitRepositoryInfo) IsGitHub

func (i *GitRepositoryInfo) IsGitHub() bool

func (*GitRepositoryInfo) PickOrCreateProvider

func (i *GitRepositoryInfo) PickOrCreateProvider(authConfigSvc auth.AuthConfigService, message string) (GitProvider, error)

type GitRepositoryOptions added in v1.0.37

type GitRepositoryOptions struct {
	ServerURL string
	Username  string
	ApiToken  string
}

type GitWebHookArguments added in v1.0.6

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

type GiteaProvider added in v1.0.16

type GiteaProvider struct {
	Username string
	Client   *gitea.Client

	Server auth.AuthServer
	User   auth.UserAuth
}

func (*GiteaProvider) CreatePullRequest added in v1.0.16

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

func (*GiteaProvider) CreateRepository added in v1.0.16

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

func (*GiteaProvider) CreateWebHook added in v1.0.16

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

func (*GiteaProvider) DeleteRepository added in v1.0.16

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

func (*GiteaProvider) ForkRepository added in v1.0.16

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

func (*GiteaProvider) IsGitHub added in v1.0.16

func (p *GiteaProvider) IsGitHub() bool

func (*GiteaProvider) JenkinsWebHookPath added in v1.0.16

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

func (*GiteaProvider) Label added in v1.0.16

func (p *GiteaProvider) Label() string

func (*GiteaProvider) ListOrganisations added in v1.0.16

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

func (*GiteaProvider) ListRepositories added in v1.0.16

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

func (*GiteaProvider) RenameRepository added in v1.0.16

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

func (*GiteaProvider) ValidateRepositoryName added in v1.0.16

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

Jump to

Keyboard shortcuts

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