gittools

package module
v0.0.0-...-d86d4a8 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: MIT Imports: 6 Imported by: 2

README

go-gittools

Package gittools provides an interface to querying and invoking the locally installed git executable.

Installation

go-gittools can be installed using the standard Go approach:

go get github.com/denormal/go-gittools

License

Copyright (c) 2016 Denormal Limited

MIT License

Documentation

Overview

Package gittools provides an interface to querying and invoking the locally installed git executable.

Index

Constants

This section is empty.

Variables

View Source
var (
	MissingGitError         = errors.New("git executable not found")
	MissingWorkingCopyError = errors.New("git working copy not found")
)

Functions

func Git

func Git() (string, error)

Git returns the absolute path to the locally installed git executable, if found. Otherwise, Git will return an error.

func GitDir

func GitDir(path string) (string, error)

GitDir returns the git directory for the working copy in which path is located, or an error if the path cannot be resolved, or is not located within a working copy. If path is "", the current working directory of the process will be used.

func HasGit

func HasGit() bool

HasGit returns true if the host system has git installed and if the git executable is located within the current user's PATH.

func InWorkingCopy

func InWorkingCopy() (bool, error)

InWorkingCopy returns true if the current directory is within a git working copy.

func IsWorkingCopy

func IsWorkingCopy(path string) (bool, error)

IsWorkingCopy returns true if path is within a git working copy. If path is "", the current working directory of the process will be used.

func Run

func Run(args ...string) ([]byte, error)

Run attempts to execute the git command in the current process working directory with args arguments. If git is executed successfully, the slice of bytes output to STDOUT by git will be returned, otherwise an error will be returned.

func RunInPath

func RunInPath(path string, args ...string) ([]byte, error)

RunInPath attempts to execute the git command from the path directory (or the parent of path if path represents a file), with args arguments. If git is executed successfully, the slice of bytes output to STDOUT by git will be returned, otherwise an error will be returned. If path is the empty string, the current process working directory will be used.

func Version

func Version() (string, error)

Version returns the version string for the installed git executable, or an error if this cannot be determined.

func WorkingCopy

func WorkingCopy(path string) (string, error)

WorkingCopy returns the root of the working copy to which path belongs, if path is within a git working copy. If path is "", the current working directory of the process will be used.

Types

This section is empty.

Jump to

Keyboard shortcuts

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