go: go.chromium.org/chromiumos/infra/go/internal/git Index | Files

package git

import "go.chromium.org/chromiumos/infra/go/internal/git"

Copyright 2019 The Chromium OS Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.


Package Files



var (
    CommandRunnerImpl cmd.CommandRunner = cmd.RealCommandRunner{}

func AddRemote Uses

func AddRemote(gitRepo, remote, remoteLocation string) error

AddRemote adds a remote.

func Checkout Uses

func Checkout(gitRepo, branch string) error

Checkout checkouts a branch.

func Clone Uses

func Clone(remote, dir string) error

Clone clones the remote into the specified dir.

func CommitAll Uses

func CommitAll(gitRepo, commitMsg string) (string, error)

CommitAll adds all local changes and commits them. Returns the sha1 of the commit.

func CommitEmpty Uses

func CommitEmpty(gitRepo, commitMsg string) (string, error)

CommitEmpty makes an empty commit (assuming nothing is staged). Returns the sha1 of the commit.

func CreateBranch Uses

func CreateBranch(gitRepo, branch string) error

CreateBranch creates a branch.

func CreateTrackingBranch Uses

func CreateTrackingBranch(gitRepo, branch string, remoteRef RemoteRef) error

CreateTrackingBranch creates a tracking branch.

func DeleteBranch Uses

func DeleteBranch(gitRepo, branch string, force bool) error

DeleteBranch checks out to master and then deletes the current branch.

func GetCurrentBranch Uses

func GetCurrentBranch(cwd string) string

GetCurrentBranch returns current branch of a repo, and an empty string if repo is on detached HEAD.

func GetGitRepoRevision Uses

func GetGitRepoRevision(cwd, branch string) (string, error)

GetGitRepoRevision finds and returns the revision of a branch.

func Init Uses

func Init(gitRepo string, bare bool) error

Init initializes a repo.

func IsReachable Uses

func IsReachable(cwd, to_ref, from_ref string) (bool, error)

IsReachable determines whether one commit ref is reachable from another.

func IsSHA Uses

func IsSHA(ref string) bool

IsSHA checks whether or not the given ref is a SHA.

func MatchBranchName Uses

func MatchBranchName(gitRepo string, pattern *regexp.Regexp) ([]string, error)

MatchBranchName returns the names of branches who match the specified regular expression.

func MatchBranchNameWithNamespace Uses

func MatchBranchNameWithNamespace(gitRepo string, pattern, namespace *regexp.Regexp) ([]string, error)

MatchBranchNameWithNamespace returns the names of branches who match the specified pattern and start with the specified namespace.

func NormalizeRef Uses

func NormalizeRef(ref string) string

NormalizeRef converts git branch refs into fully qualified form.

func PushRef Uses

func PushRef(gitRepo, localRef string, pushTo RemoteRef, opts GitOpts) error

PushRef pushes the specified local ref to the specified remote ref.

func RemoteBranches Uses

func RemoteBranches(gitRepo, remote string) ([]string, error)

RemoteBranches returns a list of branches on the specified remote.

func RemoteHasBranch Uses

func RemoteHasBranch(gitRepo, remote, branch string) (bool, error)

RemoteHasBranch checks whether or not a branch exists on a remote.

func RunGitIgnoreOutput Uses

func RunGitIgnoreOutput(gitRepo string, cmd []string) error

RunGitIgnore the specified git command in the specified repo and returns only an error, not the command output.

func StripRefs Uses

func StripRefs(ref string) string

StripRefs removes leading 'refs/heads/', 'refs/remotes/[^/]+/' from a ref name.

func StripRefsHead Uses

func StripRefsHead(ref string) string

StripRefsHead removes leading 'refs/heads/' from a ref name.

type CommandOutput Uses

type CommandOutput struct {
    Stdout string
    Stderr string

func RunGit Uses

func RunGit(gitRepo string, cmd []string) (CommandOutput, error)

RunGit the specified git command in the specified repo. It returns stdout and stderr.

type GitOpts Uses

type GitOpts struct {
    DryRun bool
    Force  bool

type RemoteRef Uses

type RemoteRef struct {
    Remote string
    Ref    string

Struct representing a remote ref.

Package git imports 8 packages (graph) and is imported by 6 packages. Updated 2021-01-26. Refresh now. Tools for package owners.