git

package
v0.53.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Overview

Package git provide a wrapper for git command line interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckoutRevision

func CheckoutRevision(repoDir, remoteName, branch, revision string) error

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

func Clone(remoteURL, dest string) (err error)

Clone the repository into destination directory.

If destination directory is not empty it will return an error.

func FetchAll

func FetchAll(repoDir string) (err error)

FetchAll will fetch the latest commits and tags from remote.

func FetchTags

func FetchTags(repoDir string) error

FetchTags will fetch all tags from remote.

func GetRemoteURL

func GetRemoteURL(repoDir, remoteName string) (url string, err error)

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

func GetTag(repoDir, revision string) (tag string, err error)

GetTag get the tag from revision. If revision is empty it's default to "HEAD".

func LatestCommit

func LatestCommit(repoDir, ref string) (commit string, err error)

LatestCommit get the latest commit hash in short format from "ref". If ref is empty, its default to "origin/master".

func LatestTag

func LatestTag(repoDir string) (tag string, err error)

LatestTag get latest tag.

func LatestVersion

func LatestVersion(repoDir string) (version string, err error)

LatestVersion will try to get latest tag from repository. If it's fail get the latest commit hash.

func ListTags

func ListTags(repoDir string) (tags []string, err error)

ListTags get all tags from repository.

func LogRevisions

func LogRevisions(repoDir, prevRevision, nextRevision string) error

LogRevisions get commits between two revisions.

func RemoteBranches

func RemoteBranches(repoDir string) ([]string, error)

RemoteBranches return list of remote branches.

func RemoteChange

func RemoteChange(repoDir, oldName, newName, newURL string) error

RemoteChange change current repository remote name (e.g. "origin") to new remote name and URL.

Types

This section is empty.

Jump to

Keyboard shortcuts

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