gitcmd

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 13 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, branch, mount, user string, dirs []string) *Git

New returns a pointer to an intialized Git.

func (*Git) BranchCurrent added in v0.0.12

func (g *Git) BranchCurrent() string

BranchCurrent shows the current branch. The working directory for the git command is set to PWD.

func (*Git) Checkout

func (g *Git) Checkout() error

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

func (g *Git) Hash() string

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

func (g *Git) IsCheckedOut() bool

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

func (g *Git) LsFile(name string) string

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

func (g *Git) OfInterest(data []byte) 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) OriginURL added in v0.0.12

func (g *Git) OriginURL() string

OriginURL returns the value of git config --get remote.origin.url The working directory for the git command is set to PWD.

func (*Git) Pull

func (g *Git) Pull() (bool, error)

Pull pulls from upstream. If the returned bool is true there were updates.

func (*Git) Repo

func (g *Git) Repo() string

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 added in v0.0.8

func (g *Git) Stash() error

Stash runs a git stash

Jump to

Keyboard shortcuts

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