Documentation
¶
Index ¶
- type Repository
- func (r *Repository) Checkout(branch string) error
- func (r *Repository) Commit(message string) error
- func (r *Repository) GetCurrentBranch() (string, error)
- func (r *Repository) GetHeadSHA() (string, error)
- func (r *Repository) GetRemoteInfo() (owner, repo string, err error)
- func (r *Repository) GetRemoteURL() (string, error)
- func (r *Repository) GetWorkDir() (string, error)
- func (r *Repository) HasChanges() (bool, error)
- func (r *Repository) HasChangesIncludingUntracked() (bool, error)
- func (r *Repository) Pull() error
- func (r *Repository) Push() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository represents a Git repository
func OpenRepository ¶
func OpenRepository(path string) (*Repository, error)
OpenRepository opens a git repository at the given path
func (*Repository) Checkout ¶
func (r *Repository) Checkout(branch string) error
Checkout switches to a different branch using git binary
func (*Repository) Commit ¶
func (r *Repository) Commit(message string) error
Commit creates a commit with all changes using git binary This ensures pre-commit hooks are executed
func (*Repository) GetCurrentBranch ¶
func (r *Repository) GetCurrentBranch() (string, error)
GetCurrentBranch returns the name of the current branch
func (*Repository) GetHeadSHA ¶
func (r *Repository) GetHeadSHA() (string, error)
GetHeadSHA returns the commit SHA of the current HEAD
func (*Repository) GetRemoteInfo ¶
func (r *Repository) GetRemoteInfo() (owner, repo string, err error)
GetRemoteInfo extracts owner and repo name from remote origin URL
func (*Repository) GetRemoteURL ¶
func (r *Repository) GetRemoteURL() (string, error)
GetRemoteURL returns the URL of the origin remote
func (*Repository) GetWorkDir ¶
func (r *Repository) GetWorkDir() (string, error)
GetWorkDir returns the working directory path of the repository
func (*Repository) HasChanges ¶
func (r *Repository) HasChanges() (bool, error)
HasChanges checks if there are uncommitted changes (modified or staged files only, ignoring untracked)
This is the "would a release/tag be built from a dirty tree?" question: a stray scratch file next to the source must not block `pr create`, `tag create` or `release create`. Use HasChangesIncludingUntracked to ask "is there anything to commit?".
func (*Repository) HasChangesIncludingUntracked ¶ added in v2.1.5
func (r *Repository) HasChangesIncludingUntracked() (bool, error)
HasChangesIncludingUntracked reports uncommitted changes the way Commit() sees them. Commit() runs `git add .`, so a brand-new file is something to commit; cpw asked HasChanges instead and answered "No changes to commit" while quietly leaving the user's new file behind (issue #180).
func (*Repository) Pull ¶
func (r *Repository) Pull() error
Pull pulls latest changes from remote using git binary
func (*Repository) Push ¶
func (r *Repository) Push() error
Push pushes commits to remote using git binary. Automatically sets upstream for new branches.