git

package
v0.0.0-...-fa6c17c Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitOptionsFromConfig

func CommitOptionsFromConfig(when time.Time) (*git.CommitOptions, error)

CommitOptionsFromConfig creates and returns a *git.CommitOptions with the Author field populated based on the user's ~/.gitconfig.

Types

type CommitOptions

type CommitOptions = git.CommitOptions

type Repository

type Repository struct {
	*git.Repository
	// contains filtered or unexported fields
}

Repository is a struct that provides a simplified interface to a git repository.

func New

func New(root string) (*Repository, error)

New creates and returns a new Repository rooted at the provided base path.

func (*Repository) Commit

func (r *Repository) Commit(msg string, opts *git.CommitOptions) (string, error)

Commit creates a new commit in the git repository.

It returns the sha of the commit.

func (*Repository) CreateAndSwitchBranch

func (r *Repository) CreateAndSwitchBranch(name string) error

CreateAndSwitchBranch switches from the current branch to the one with the name provided.

func (*Repository) WriteFile

func (r *Repository) WriteFile(name string, data []byte, perm os.FileMode) error

WriteFile writes data to the named file, creating it if necessary. If the file does not exist, WriteFile creates it with permissions perm (before umask); otherwise WriteFile truncates it before writing, without changing permissions.

The file is also "git added" to the current worktree.

Jump to

Keyboard shortcuts

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