Documentation ¶
Index ¶
- Constants
- func ReadFileFromRevision(repoPath, revision, filePath string) ([]byte, error)
- type DatedTag
- type GitHandler
- type GoGit
- func (g GoGit) Add(files []string, workingDir string) error
- func (g GoGit) Branches(workingDir string) (branches []string, err error)
- func (g GoGit) Checkout(username, password, branch, remoteBranch, workingDir string, forceReset bool) error
- func (g GoGit) Clone(username, password, URL, workingDir string, withSubmodules *bool) error
- func (g GoGit) Commit(user, email, message, workingDir string, signingKey string, passphrase string) error
- func (g GoGit) GetChangedFiles(workingDir string) ([]string, error)
- func (g GoGit) IsLocalBranchPublished(baseBranch, workingBranch, username, password, workingDir string) (bool, error)
- func (g GoGit) IsSimilarBranch(a, b, workingDir string) (bool, error)
- func (g GoGit) NewBranch(branch, workingDir string) (bool, error)
- func (g GoGit) NewTag(tag, message, workingDir string) (bool, error)
- func (g GoGit) Push(username string, password string, workingDir string, force bool) error
- func (g GoGit) PushBranch(branch string, username string, password string, workingDir string, force bool) error
- func (g GoGit) PushTag(tag string, username string, password string, workingDir string, force bool) error
- func (g GoGit) RemoteURLs(workingDir string) (map[string]string, error)
- func (g GoGit) SanitizeBranchName(branch string) string
- func (g GoGit) TagHashes(workingDir string) (hashes []string, err error)
- func (g GoGit) TagRefs(workingDir string) (tags []DatedTag, err error)
- func (g GoGit) Tags(workingDir string) (names []string, err error)
- type MockGit
Constants ¶
const (
DefaultRemoteReferenceName = "origin"
)
Variables ¶
This section is empty.
Functions ¶
func ReadFileFromRevision ¶ added in v0.59.0
ReadFileFromRevision reads a file from a git repository at a given revision.
Types ¶
type GitHandler ¶ added in v0.28.0
type GitHandler interface { Add(files []string, workingDir string) error Checkout(username, password, branch, remoteBranch, workingDir string, forceReset bool) error Clone(username, password, URL, workingDir string, withSubmodules *bool) error Commit(user, email, message, workingDir string, signingKey string, passphrase string) error GetChangedFiles(workingDir string) ([]string, error) IsSimilarBranch(a, b, workingDir string) (bool, error) IsLocalBranchPublished(baseBranch, workingBranch, username, password, workingDir string) (bool, error) NewTag(tag, message, workingDir string) (bool, error) NewBranch(branch, workingDir string) (bool, error) Push(username string, password string, workingDir string, force bool) error PushTag(tag string, username string, password string, workingDir string, force bool) error PushBranch(branch string, username string, password string, workingDir string, force bool) error RemoteURLs(workingDir string) (map[string]string, error) SanitizeBranchName(branch string) string Tags(workingDir string) (tags []string, err error) TagHashes(workingDir string) (hashes []string, err error) TagRefs(workingDir string) (refs []DatedTag, err error) Branches(workingDir string) (branches []string, err error) }
type GoGit ¶ added in v0.28.0
type GoGit struct { }
func (GoGit) Branches ¶ added in v0.44.0
Tags return a list of git tags ordered by latest commit time
func (GoGit) Checkout ¶ added in v0.28.0
func (g GoGit) Checkout(username, password, branch, remoteBranch, workingDir string, forceReset bool) error
Checkout create and then uses a temporary git branch.
func (GoGit) Commit ¶ added in v0.28.0
func (g GoGit) Commit(user, email, message, workingDir string, signingKey string, passphrase string) error
Commit run `git commit`.
func (GoGit) GetChangedFiles ¶ added in v0.28.0
func (GoGit) IsLocalBranchPublished ¶ added in v0.45.0
func (g GoGit) IsLocalBranchPublished(baseBranch, workingBranch, username, password, workingDir string) (bool, error)
IsLocalBranchPublished checks if the local working branch, contains any changes which should be published.
- `git diff` is not yet supported by the go-git library. https://github.com/go-git/go-git/issues/36
We retrieve:
- the latest commit from the local working branch
- the latest commit from the base branch
- the latest commit from the remote working branch if it exists.
Based on those three information we decide if local changes should be published.
If local working branch == local base branch and no remote working branch => This means that base branch and working are similar so nothing need to be pushed
If local working branch == local base branch != remote working branch => This means that at some point the remote branch diverge from base branch
If local working branch == local base branch == remote working branch => This means that everything is up to date
returns true if both the remote and local reference are similar.
func (GoGit) IsSimilarBranch ¶ added in v0.28.0
IsSimilarBranch checks that the last commits of the two branches are similar then return true if it's the case
func (GoGit) NewBranch ¶ added in v0.44.0
NewBranch create a tag then return a boolean to indicate if the tag was created or not.
func (GoGit) NewTag ¶ added in v0.28.0
NewTag create a tag then return a boolean to indicate if the tag was created or not.
func (GoGit) PushBranch ¶ added in v0.44.0
func (g GoGit) PushBranch(branch string, username string, password string, workingDir string, force bool) error
PushBranch publish a single branch created locally
func (GoGit) PushTag ¶ added in v0.28.0
func (g GoGit) PushTag(tag string, username string, password string, workingDir string, force bool) error
PushTag publish a single tag created locally
func (GoGit) RemoteURLs ¶ added in v0.28.0
RemoteURLs returns the list of remote URLs
func (GoGit) SanitizeBranchName ¶ added in v0.28.0
SanitizeBranchName replace wrong character in the branch name
func (GoGit) TagHashes ¶ added in v0.49.0
TagHashes returns a list of the commit hashes for git tags ordered by creation time