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.



    This section is empty.


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


    func AddRemote

    func AddRemote(gitRepo, remote, remoteLocation string) error

      AddRemote adds a remote.

      func Checkout

      func Checkout(gitRepo, branch string) error

        Checkout checkouts a branch.

        func Clone

        func Clone(remote, dir string) error

          Clone clones the remote into the specified dir.

          func CommitAll

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

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

            func CommitEmpty

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

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

              func CreateBranch

              func CreateBranch(gitRepo, branch string) error

                CreateBranch creates a branch.

                func CreateTrackingBranch

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

                  CreateTrackingBranch creates a tracking branch.

                  func DeleteBranch

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

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

                    func GetCurrentBranch

                    func GetCurrentBranch(cwd string) string

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

                      func GetGitRepoRevision

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

                        GetGitRepoRevision finds and returns the revision of a branch.

                        func Init

                        func Init(gitRepo string, bare bool) error

                          Init initializes a repo.

                          func IsReachable

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

                            IsReachable determines whether one commit ref is reachable from another.

                            func IsSHA

                            func IsSHA(ref string) bool

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

                              func MatchBranchName

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

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

                                func MatchBranchNameWithNamespace

                                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

                                  func NormalizeRef(ref string) string

                                    NormalizeRef converts git branch refs into fully qualified form.

                                    func PushRef

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

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

                                      func RemoteBranches

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

                                        RemoteBranches returns a list of branches on the specified remote.

                                        func RemoteHasBranch

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

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

                                          func ResolveRemoteSymbolicRef

                                          func ResolveRemoteSymbolicRef(gitRepo, remote string, ref string) (string, error)

                                            ResolveRemoteSymbolicRef resolves the target of a symbolic ref.

                                            func RunGitIgnoreOutput

                                            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

                                              func StripRefs(ref string) string

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

                                                func StripRefsHead

                                                func StripRefsHead(ref string) string

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


                                                  type CommandOutput

                                                  type CommandOutput struct {
                                                  	Stdout string
                                                  	Stderr string

                                                  func RunGit

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

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

                                                    type GitOpts

                                                    type GitOpts struct {
                                                    	DryRun bool
                                                    	Force  bool

                                                    type RemoteRef

                                                    type RemoteRef struct {
                                                    	Remote string
                                                    	Ref    string

                                                      Struct representing a remote ref.

                                                      Source Files