Documentation
¶
Index ¶
- func IsRepo(path string) bool
- type CommitInfo
- type FileStatus
- type PermalinkStyle
- type Repo
- func (r *Repo) Branch() (string, error)
- func (r *Repo) BranchList() ([]string, error)
- func (r *Repo) CopyPermalink(filePath string, line int) (string, error)
- func (r *Repo) CurrentRemoteURL() (string, error)
- func (r *Repo) FileStatusAt(relPath string) (FileStatus, error)
- func (r *Repo) FileURL(filePath string) (string, error)
- func (r *Repo) HeadHash() (string, error)
- func (r *Repo) IsClean() (bool, error)
- func (r *Repo) Log(n int) ([]CommitInfo, error)
- func (r *Repo) Permalink(filePath string, line int) (string, error)
- func (r *Repo) PermalinkForBranch(filePath string, branch string, line int) (string, error)
- func (r *Repo) PermalinkForRange(filePath string, startLine, endLine int) (string, error)
- func (r *Repo) Remotes() (map[string]string, error)
- func (r *Repo) Root() string
- func (r *Repo) Status() ([]FileStatus, error)
- func (r *Repo) Tags() ([]string, error)
- type StatusCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CommitInfo ¶
CommitInfo holds metadata for a single commit.
type FileStatus ¶
type FileStatus struct {
Path string
Staging StatusCode
Worktree StatusCode
}
FileStatus represents the git status of a single file.
type PermalinkStyle ¶
type PermalinkStyle int
PermalinkStyle determines the URL format for generated links.
const ( PermalinkGitHub PermalinkStyle = iota PermalinkGitLab PermalinkBitbucket PermalinkGitea PermalinkCodeberg )
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo wraps a go-git repository with convenience methods.
func Open ¶
Open opens the git repository at or above the given path. Repeated calls for the same absolute path return a cached Repo.
func (*Repo) BranchList ¶
BranchList returns all local branch names.
func (*Repo) CopyPermalink ¶
CopyPermalink generates a permalink and copies it to the clipboard. Returns the link string even if clipboard is unavailable.
func (*Repo) CurrentRemoteURL ¶
CurrentRemoteURL returns the fetch URL for the "origin" remote.
func (*Repo) FileStatusAt ¶
func (r *Repo) FileStatusAt(relPath string) (FileStatus, error)
FileStatusAt returns the git status for a specific file path relative to the repo root.
func (*Repo) Log ¶
func (r *Repo) Log(n int) ([]CommitInfo, error)
Log returns the last n commits from HEAD.
func (*Repo) PermalinkForBranch ¶
PermalinkForBranch generates a URL using a branch name instead of a commit hash.
func (*Repo) PermalinkForRange ¶
PermalinkForRange generates a permanent URL to a file with a line range.
func (*Repo) Status ¶
func (r *Repo) Status() ([]FileStatus, error)
Status returns the working tree status for all files.
type StatusCode ¶
type StatusCode byte
StatusCode maps to go-git status codes.
const ( Unmodified StatusCode = ' ' Modified StatusCode = 'M' Added StatusCode = 'A' Deleted StatusCode = 'D' Renamed StatusCode = 'R' Copied StatusCode = 'C' Untracked StatusCode = '?' )