Documentation ¶
Overview ¶
Package git contains various commands that shell out to git
Index ¶
- type Config
- type DiffEntry
- type Divert
- func (d *Divert) Begin(spec DivertSpec) (err error)
- func (d *Divert) CleanSpec() (err error)
- func (d *Divert) Cleanup(spec DivertSpec) (err error)
- func (d *Divert) Commit(spec DivertSpec, message string) (err error)
- func (d *Divert) IsInProgress() (res bool, err error)
- func (d *Divert) PrepareBegin(branch string, names ...string) (res DivertSpec, err error)
- func (d *Divert) ReadSpec() (res DivertSpec, err error)
- type DivertSpec
- type Git
- func (g *Git) Add(filenames ...string) (err error)
- func (g *Git) BranchRecreate(branch string) (err error)
- func (g *Git) Cat(oid string) (res io.Reader, err error)
- func (g *Git) Checkout(what string, filenames ...string) (err error)
- func (g *Git) CleanHook(name string) (err error)
- func (g *Git) Commit(message string) (err error)
- func (g *Git) Diff(filenames ...string) (res io.Reader, err error)
- func (g *Git) DiffFiles(filenames ...string) (res []string, err error)
- func (g *Git) DiffIndex(filenames ...string) (res []string, err error)
- func (g *Git) FilterByAttr(diff string, filenames ...string) (res []string, err error)
- func (g *Git) GetBranches() (current string, other []string, err error)
- func (g *Git) GetHook(name string) (res string, err error)
- func (g *Git) GetOID(filename string) (res string, err error)
- func (g *Git) GetRevParse(what string) (res string, err error)
- func (g *Git) LsTree(what string, paths ...string) (res []string, err error)
- func (g *Git) ManifestsFromDiff(r io.Reader) (res lists.BlobMap, err error)
- func (g *Git) Push(upstream, branch string) (err error)
- func (g *Git) Reset(to string) (err error)
- func (g *Git) Run(sub string, arg ...string) (res string, err error)
- func (g *Git) SetConfig(key, val string) (err error)
- func (g *Git) SetHook(name string, contents string) (err error)
- func (g *Git) UnsetConfig(key string) (err error)
- func (g *Git) UpdateIndex(what ...string) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiffEntry ¶
type DiffEntry struct { // Git OID to get cached manifest OID string // bar BLOB ID ID string // BLOB filename Filename string }
Extracted diff entry
type Divert ¶
type Divert struct {
*Git
}
Divert is ability to temporary switch branch preserving all blobs in working tree.
# Reset index and HEAD to otherbranch git reset otherbranch # make commit for otherbranch git add file-to-commit git commit "edited file" # force recreate otherbranch to here git branch -f otherbranch # Go back to where we were before # (two commits ago, the reset and the commit) git reset HEAD@{2}
func (*Divert) Begin ¶
func (d *Divert) Begin(spec DivertSpec) (err error)
Begin diversion to on branch where "names" is git-specific <tree-ish>
func (*Divert) Commit ¶
func (d *Divert) Commit(spec DivertSpec, message string) (err error)
Finish diversion.
func (*Divert) IsInProgress ¶
Is divert in progress
func (*Divert) PrepareBegin ¶
func (d *Divert) PrepareBegin(branch string, names ...string) (res DivertSpec, err error)
Consistency checks before begin diversion and return spec
func (*Divert) ReadSpec ¶
func (d *Divert) ReadSpec() (res DivertSpec, err error)
type DivertSpec ¶
type DivertSpec struct { // Home ref Head string // Replaced files ToRecover []string // Target branch TargetBranch string // Target files TargetFiles []string }
Diversion spec
type Git ¶
Git wrapper. TODO: use native git (https://github.com/gogits/git)
This wrapper always run git in repository root
func (*Git) BranchRecreate ¶
git branch -f <branch>
func (*Git) FilterByAttr ¶
Filter files by diff attribute
$ git check-attr diff <files> | grep "diff: <diff>"
This command takes and returns filenames relative to CWD
func (*Git) ManifestsFromDiff ¶
Extract manifests from diff
$ git diff --staged --cached -U99999999999999 --no-prefix diff --git fix/aa.txt fix/aa.txt index 5afd5028d71cfadf73c0e3abd70f852d67357909..63c202a03152c8635eb78dcfef35859f0c68f5cf 100644 --- fix/aa.txt +++ fix/aa.txt @@ -1,10 +1,10 @@ BAR:MANIFEST -id aba7aeb8a7948dd0cdb8eeb9239e5d1dab2bd840f13930f86f6e67ba40ea5350 -size 4 +id f627c8f9355399ef45e1a6b6e5a9e6a3abcb3e1b6255603357bffa9f2211ba7e +size 6 -id aba7aeb8a7948dd0cdb8eeb9239e5d1dab2bd840f13930f86f6e67ba40ea5350 -size 4 +id f627c8f9355399ef45e1a6b6e5a9e6a3abcb3e1b6255603357bffa9f2211ba7e +size 6 offset 0 ... diff --git fix/aa2.txt fix/aa2.txt new file mode 100644 index 0000000000000000000000000000000000000000..63c202a03152c8635eb78dcfef35859f0c68f5cf --- /dev/null +++ fix/aa2.txt <--- Start consuming @@ -0,0 +1,10 @@ <--- if consuming - next line +BAR:MANIFEST <--- Start consuming manifest by "" and "+" + +id f627c8f9355399ef45e1a6b6e5a9e6a3abcb3e1b6255603357bffa9f2211ba7e +size 6 + + +id f627c8f9355399ef45e1a6b6e5a9e6a3abcb3e1b6255603357bffa9f2211ba7e +size 6 +offset 0 +
func (*Git) UpdateIndex ¶
Refresh files in git index (use after squash or blow)