package git
import "github.com/shuLhan/share/lib/git"
Package git provide a wrapper for git command line interface.
Index ¶
- func CheckoutRevision(repoDir, remoteName, branch, revision string) error
- func Clone(remoteURL, dest string) (err error)
- func FetchAll(repoDir string) (err error)
- func FetchTags(repoDir string) error
- func GetRemoteURL(repoDir, remoteName string) (url string, err error)
- func GetTag(repoDir, revision string) (tag string, err error)
- func LatestCommit(repoDir, ref string) (commit string, err error)
- func LatestTag(repoDir string) (tag string, err error)
- func LatestVersion(repoDir string) (version string, err error)
- func ListTags(repoDir string) (tags []string, err error)
- func LogRevisions(repoDir, prevRevision, nextRevision string) error
- func RemoteBranches(repoDir string) ([]string, error)
- func RemoteChange(repoDir, oldName, newName, newURL string) error
Functions ¶
func CheckoutRevision ¶
CheckoutRevision will set the HEAD to specific revision on specific branch. Any untracked files and directories will be removed before checking out existing branch or creating new branch. If remoteName is empty, it will use default reference "origin". If branch is empty, it will use default branch "master". If revision is empty, it will do nothing.
This function assume that repository is up-to-date with remote. Client may call FetchAll() before, to prevent checking out revision that may not exist.
func Clone ¶
Clone the repository into destination directory.
If destination directory is not empty it will return an error.
func FetchAll ¶
FetchAll will fetch the latest commits and tags from remote.
func FetchTags ¶
FetchTags will fetch all tags from remote.
func GetRemoteURL ¶
GetRemoteURL return remote URL or error if repository is not git or url is empty. If remoteName is empty, it will be set to default ("origin").
func GetTag ¶
GetTag get the tag from revision. If revision is empty it's default to "HEAD".
func LatestCommit ¶
LatestCommit get the latest commit hash in short format from "ref". If ref is empty, its default to "origin/master".
func LatestTag ¶
LatestTag get latest tag.
func LatestVersion ¶
LatestVersion will try to get latest tag from repository. If it's fail get the latest commit hash.
func ListTags ¶
ListTags get all tags from repository.
func LogRevisions ¶
LogRevisions get commits between two revisions.
func RemoteBranches ¶
RemoteBranches return list of remote branches.
func RemoteChange ¶
RemoteChange change current repository remote name (e.g. "origin") to new remote name and URL.
Source Files ¶
- Version
- v0.53.1 (latest)
- Published
- Mar 2, 2024
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 5 days ago –
Tools for package owners.