gogit

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAuthUser    = "anonymous"
	DefaultTrunkBranch = "main"
	DefaultRemoteName  = "origin"
	DefaultGitUser     = "kuesta"
	DefaultGitEmail    = "kuesta@example.com"
)

Variables

This section is empty.

Functions

func IsBothWorktreeAndStagingTrackedAndChanged

func IsBothWorktreeAndStagingTrackedAndChanged(st extgogit.FileStatus) bool

IsBothWorktreeAndStagingTrackedAndChanged returns true if both stating and worktree statuses of the given file are tracked and changed.

func IsEitherWorktreeOrStagingTrackedAndChanged

func IsEitherWorktreeOrStagingTrackedAndChanged(st extgogit.FileStatus) bool

IsEitherWorktreeOrStagingTrackedAndChanged returns true if either stating or worktree status of the given file is tracked and changed.

func IsTrackedAndChanged

func IsTrackedAndChanged(c extgogit.StatusCode) bool

IsTrackedAndChanged returns true if git file status is neither untracked nor unmodified.

Types

type CheckoutOpts

type CheckoutOpts func(o *extgogit.CheckoutOptions)

CheckoutOpts enables modification of the go-git CheckoutOptions.

func CheckoutOptsCreateNew

func CheckoutOptsCreateNew() CheckoutOpts

func CheckoutOptsSoftReset

func CheckoutOptsSoftReset() CheckoutOpts

func CheckoutOptsTo

func CheckoutOptsTo(branch string) CheckoutOpts

type CloneOpts

type CloneOpts func(o *extgogit.CloneOptions)

CloneOpts enables modification of the go-git CheckoutOptions.

type CommitOpts

type CommitOpts func(o *extgogit.CommitOptions)

CommitOpts enables modification of the go-git CommitOptions.

type Git

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

func NewGit

func NewGit(o *GitOptions) (*Git, error)

NewGit creates Git with a go-git repository.

func NewGitWithoutRepo

func NewGitWithoutRepo(o *GitOptions) *Git

NewGitWithoutRepo creates Git without setting up a go-git repository.

func (*Git) Add

func (g *Git) Add(path string) error

Add executes `git add` for all created/modified/deleted files included in the given path.

func (*Git) BasicAuth

func (g *Git) BasicAuth() *gogithttp.BasicAuth

BasicAuth returns the go-git BasicAuth if git token is provided, otherwise nil.

func (*Git) Branch

func (g *Git) Branch() (string, error)

Branch returns the current branch name.

func (*Git) Branches

func (g *Git) Branches() ([]*plumbing.Reference, error)

Branches returns the all branch names at the local repo.

func (*Git) Checkout

func (g *Git) Checkout(opts ...CheckoutOpts) (*extgogit.Worktree, error)

Checkout switches git branch to the given one and returns git worktree.

func (*Git) Clone

func (g *Git) Clone(opts ...CloneOpts) (*extgogit.Repository, error)

Clone clones remote git repo to the given local path.

func (*Git) Commit

func (g *Git) Commit(msg string, opts ...CommitOpts) (plumbing.Hash, error)

Commit execute `git commit -m` with given message.

func (*Git) Head

func (g *Git) Head() (*object.Commit, error)

Head returns the object.Commit of the current repository head.

func (*Git) Options

func (g *Git) Options() *GitOptions

Options returns internal GitOptions.

func (*Git) Pull

func (g *Git) Pull(opts ...PullOpts) error

Pull pulls the specified git branch from remote to local.

func (*Git) Push

func (g *Git) Push(opts ...PushOpts) error

Push pushes the specified git branch to remote. If branch is empty, it pushes the branch set by GitOptions.TrunkBranch.

func (*Git) Remote

func (g *Git) Remote(name string) (*GitRemote, error)

Remote returns GitRemote of the supplied remote name. If not supplied, it returns the one of GitOptions.RemoteName.

func (*Git) RemoveBranch

func (g *Git) RemoveBranch(rn plumbing.ReferenceName) error

RemoveBranch removes the local branch.

func (*Git) RemoveGoneBranches

func (g *Git) RemoveGoneBranches() error

RemoveGoneBranches removes all gone branches.

func (*Git) Repo

func (g *Git) Repo() *extgogit.Repository

Repo returns internal go-git repository.

func (*Git) Reset

func (g *Git) Reset(opts ...ResetOpts) error

Reset runs git-reset with supplied options.

func (*Git) SetUpstream

func (g *Git) SetUpstream(branch string) error

SetUpstream writes branch remote setting to .git/config.

func (*Git) Signature

func (g *Git) Signature() *object.Signature

Signature returns the go-git Signature using user given User/Email or default one.

type GitOptions

type GitOptions struct {
	RepoUrl     string
	Token       string
	Path        string `validate:"required"`
	TrunkBranch string
	RemoteName  string
	User        string
	Email       string
	// contains filtered or unexported fields
}

func (*GitOptions) ShouldCloneIfNotExist

func (g *GitOptions) ShouldCloneIfNotExist() *GitOptions

func (*GitOptions) Validate

func (g *GitOptions) Validate() error

Validate validates exposed fields according to the `validate` tag.

type GitRemote

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

func (*GitRemote) BasicAuth

func (r *GitRemote) BasicAuth() *gogithttp.BasicAuth

BasicAuth returns the go-git BasicAuth if git token is provided, otherwise nil.

func (*GitRemote) Branches

func (r *GitRemote) Branches(opts ...ListOpts) ([]*plumbing.Reference, error)

Branches lists the branches of the remote repository.

func (*GitRemote) Name

func (r *GitRemote) Name() string

func (*GitRemote) RemoveBranch

func (r *GitRemote) RemoveBranch(rn plumbing.ReferenceName, opts ...PushOpts) error

RemoveBranch removes the remote branch.

type ListOpts

type ListOpts func(o *extgogit.ListOptions)

ListOpts enables modification of the go-git ListOptions.

type PullOpts

type PullOpts func(o *extgogit.PullOptions)

PullOpts enables modification of the go-git PullOptions.

func PullOptsReference

func PullOptsReference(name plumbing.ReferenceName) PullOpts

type PushOpts

type PushOpts func(o *extgogit.PushOptions)

PushOpts enables modification of the go-git PushOptions.

func PushOptBranch

func PushOptBranch(branch string) PushOpts

type ResetOpts

type ResetOpts func(o *extgogit.ResetOptions)

ResetOpts enables modification of the go-git ResetOptions.

func ResetOptsHard

func ResetOptsHard() ResetOpts

Jump to

Keyboard shortcuts

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