git

package module
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitHubTokenName       = "GITHUB_TOKEN"
	GitHubDefaultHostname = "github.com"
)
View Source
const (
	GitLabTokenName       = "GITLAB_TOKEN"
	GitLabDefaultHostname = "gitlab.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GitLabProvider

type GitLabProvider struct {
	BasePath   *string
	IsPersonal bool
	IsPrivate  bool
}

GitLabProvider represents a GitLab API wrapper

func (*GitLabProvider) AddDeployKey

func (p *GitLabProvider) AddDeployKey(ctx context.Context, r *Repository, key, keyName string) (bool, error)

AddDeployKey returns false if the key exists and the content is the same

func (*GitLabProvider) AddTeam

func (p *GitLabProvider) AddTeam(ctx context.Context, r *Repository, name, permission string) (bool, error)

AddTeam returns false if the team is already assigned to the repository

func (*GitLabProvider) CreateRepository

func (p *GitLabProvider) CreateRepository(ctx context.Context, r *Repository) (bool, error)

CreateRepository returns false if the repository already exists

func (*GitLabProvider) DeleteRepository

func (p *GitLabProvider) DeleteRepository(ctx context.Context, r *Repository) error

DeleteRepository is not supported by GitLab

type GithubProvider

type GithubProvider struct {
	IsPrivate  bool
	IsPersonal bool
}

GithubProvider represents a GitHub API wrapper

func (*GithubProvider) AddDeployKey

func (p *GithubProvider) AddDeployKey(ctx context.Context, r *Repository, key, keyName string) (bool, error)

AddDeployKey returns false if the key exists and the content is the same

func (*GithubProvider) AddTeam

func (p *GithubProvider) AddTeam(ctx context.Context, r *Repository, name, permission string) (bool, error)

AddTeam returns false if the team is already assigned to the repository

func (*GithubProvider) CreateRepository

func (p *GithubProvider) CreateRepository(ctx context.Context, r *Repository) (bool, error)

CreateRepository returns false if the repository exists

func (*GithubProvider) DeleteRepository

func (p *GithubProvider) DeleteRepository(ctx context.Context, r *Repository) error

DeleteRepository deletes the GitHub repository

type Provider

type Provider interface {
	CreateRepository(ctx context.Context, r *Repository) (bool, error)
	DeleteRepository(ctx context.Context, r *Repository) error
	AddTeam(ctx context.Context, r *Repository, name, permission string) (bool, error)
	AddDeployKey(ctx context.Context, r *Repository, key, keyName string) (bool, error)
}

Provider is the interface that a git provider should implement

type Repository

type Repository struct {
	Name        string
	Owner       string
	Host        string
	SSHHost     string
	Token       string
	AuthorName  string
	AuthorEmail string
	// contains filtered or unexported fields
}

Repository represents a git repository wrapper

func NewRepository

func NewRepository(name, owner, host, token, authorName, authorEmail string) (*Repository, error)

NewRepository returns a git repository wrapper

func (*Repository) Checkout

func (r *Repository) Checkout(ctx context.Context, branch, path string) error

Checkout repository branch at specified path

func (*Repository) Commit

func (r *Repository) Commit(ctx context.Context, path, message string) (bool, error)

Commit changes for the specified path, returns false if no changes are detected

func (*Repository) GetSSH

func (r *Repository) GetSSH() string

GetSSH returns the repository SSH address

func (*Repository) GetURL

func (r *Repository) GetURL() string

GetURL returns the repository HTTPS address

func (*Repository) Push

func (r *Repository) Push(ctx context.Context) error

Push commits to origin

Jump to

Keyboard shortcuts

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