Documentation ¶
Overview ¶
Package gitcmd has a bunch of convience functions to work with Git. Each machine should use it's own Git.
Index ¶
- type Git
- func (g *Git) BranchCurrent() string
- func (g *Git) Checkout() error
- func (g *Git) Hash() string
- func (g *Git) IsCheckedOut() bool
- func (g *Git) LsFile(name string) string
- func (g *Git) OfInterest(data []byte) bool
- func (g *Git) OriginURL() string
- func (g *Git) Pull() (bool, error)
- func (g *Git) Repo() string
- func (g *Git) Rollback(hash string) error
- func (g *Git) Stash() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
func (*Git) BranchCurrent ¶ added in v0.0.12
BranchCurrent shows the current branch. The working directory for the git command is set to PWD.
func (*Git) Checkout ¶
Checkout will do the initial check of the git repo. If the g.mount directory already exist and has a .git subdirectory, it will assume the checkout has been done during a previuos run.
func (*Git) Hash ¶
Hash returns the git hash of HEAD in the repo in g.mount. Empty string is returned in case of an error. The hash is always truncated to 8 hex digits.
func (*Git) IsCheckedOut ¶
IsCheckedOut will check g.mount and if it has an .git sub directory we assume the checkout has been done.
func (*Git) LsFile ¶ added in v0.0.12
LsFile return the relative path of name inside the git repository. The working directory for the git command is set to PWD.
func (*Git) OfInterest ¶
OfInterest will grep the diff stat for directories we care about. The returns boolen is true when we find a hit.
We do a git pull, but we want to know if things changed that are of interest. This is done by parsing the diffstat on the git pull, not the best way, but it works. Problem is here is to keep track _when_ things changed, i.e. we can look in the revlog, but then we need to track that we saw a change. Parsing the diff stat seems simpler and more atomic in that regard.
func (*Git) OriginURL ¶ added in v0.0.12
OriginURL returns the value of git config --get remote.origin.url The working directory for the git command is set to PWD.