git

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package gitcmd has a bunch of convience functions to work with Git. Each machine should use it's own Git.

Index

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 New

func New(upstream, user, branch, directory string) *Git

New returns a pointer to an intialized Git.

func (*Git) Branch

func (g *Git) Branch(br string) error

func (*Git) Checkout

func (g *Git) Checkout() error

Checkout will do the initial check of the git repo. If the g.dir directory already exist and has a .git subdirectory, it will assume the checkout has been done during a previuos run.

func (*Git) Hash

func (g *Git) Hash() string

Hash returns the git hash of HEAD in the repo in g.dir. Empty string is returned in case of an error. The hash is always truncated to 8 hex digits.

func (*Git) IsCheckedOut

func (g *Git) IsCheckedOut() bool

func (*Git) OfInterest

func (g *Git) OfInterest(data []byte, names []string) bool

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) Pull

func (g *Git) Pull(names []string) (bool, error)

Pull pulls from upstream. If the returned bool is true there were updates if on the files named in names.

func (*Git) RemoveAll added in v0.0.2

func (g *Git) RemoveAll() error

func (*Git) Rollback

func (g *Git) Rollback(hash string) error

Rollback checks out commit <hash>, and return nil if no errors are encountered.

func (*Git) Stash

func (g *Git) Stash() error

Jump to

Keyboard shortcuts

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