Documentation ¶
Index ¶
- Constants
- Variables
- func Diff(src, dest []Sub) (insertion, deletion []Sub, update []Delta)
- func Equals(src, dest []Sub) bool
- func Patch(d *Sub, delta Delta) (changed bool, err error)
- func Sort(sbrs []Sub)
- func UpdateAll(subs []Sub, upd ...Delta) (changed bool, err error)
- func WriteTo(w io.Writer, sbr []Sub)
- type Checkouter
- func (ch *Checkouter) Checkout() (digest []byte, err error)
- func (ch *Checkouter) Prune(d Sub) (err error)
- func (ch *Checkouter) PullAll() (err error)
- func (ch *Checkouter) PullTop() (err error)
- func (c *Checkouter) SetFastForwardOnly(ffo bool)
- func (c *Checkouter) SetPrune(prune bool)
- func (c *Checkouter) SetRebase(rebase bool)
- func (ch *Checkouter) UpdateBranch(delta Delta) (updated bool, err error)
- func (ch *Checkouter) UpdateRemote(delta Delta) (updated bool, err error)
- func (ch *Checkouter) UpdateRepository(delta Delta) (updated bool, err error)
- type Delta
- type Sub
- type Workspace
Examples ¶
Constants ¶
const (
SbrFile = ".sbr"
)
Variables ¶
var (
ErrNoSbrfile = errors.New("Not in an 'sbr' workspace")
)
Functions ¶
Types ¶
type Checkouter ¶
type Checkouter struct {
// contains filtered or unexported fields
}
Checkouter holds all methods to change the workspace content
func NewCheckouter ¶
func NewCheckouter(workspace *Workspace, w io.Writer) *Checkouter
NewCheckouter creates a checkouter. logs are reported into w
func (*Checkouter) Checkout ¶
func (ch *Checkouter) Checkout() (digest []byte, err error)
Checkout the current workspace
it's a Pull Top and clone/prune/pull each subrepositories
func (*Checkouter) PullAll ¶
func (ch *Checkouter) PullAll() (err error)
func (*Checkouter) PullTop ¶
func (ch *Checkouter) PullTop() (err error)
PullTop launches a git pull --ff-only on the Wd top git
func (*Checkouter) SetFastForwardOnly ¶
func (c *Checkouter) SetFastForwardOnly(ffo bool)
func (*Checkouter) SetPrune ¶
func (c *Checkouter) SetPrune(prune bool)
func (*Checkouter) SetRebase ¶
func (c *Checkouter) SetRebase(rebase bool)
func (*Checkouter) UpdateBranch ¶
func (ch *Checkouter) UpdateBranch(delta Delta) (updated bool, err error)
Update branch on actual git repo if needed
func (*Checkouter) UpdateRemote ¶
func (ch *Checkouter) UpdateRemote(delta Delta) (updated bool, err error)
Update remote updates the remote origin
func (*Checkouter) UpdateRepository ¶
func (ch *Checkouter) UpdateRepository(delta Delta) (updated bool, err error)
Update a repository according to changes described in delta
type Sub ¶
type Sub struct {
// contains filtered or unexported fields
}
Sub type contains all the information about a sub.
func ReadFrom ¶
ReadFrom read subrepository definitions fom reader
the initial currentBranch is 'master'
Example ¶
ExampleWorkspace_ReadFrom test several version of a .sbr that all should be readable and generate the same "normalized" version.
//this is a normalize sample of .sbr normalized := `"src/github.com/ericaro/mrepo" "git@github.com:ericaro/mrepo.git" "mdev" "src/github.com/ericaro/mrepo_dev" "git@github.com:ericaro/mrepo.git" "src/github.com/ericaro/mrepo_dev2" "git@github.com:ericaro/mrepo2.git" "mprod" "src/github.com/ericaro/mrepo_prod" "git@github.com:ericaro/mrepo.git" "src/github.com/ericaro/mrepoa" "git@github.com:ericaro/mrepoa.git" ` //this is a human-edited version, that should be identical humanized := ` "src/github.com/ericaro/mrepo" "git@github.com:ericaro/mrepo.git" "toto" "src/github.com/ericaro/mrepo_prod" "git@github.com:ericaro/mrepo.git" "mprod" "src/github.com/ericaro/mrepo_dev" "git@github.com:ericaro/mrepo.git" "mdev" "src/github.com/ericaro/mrepo_dev2" "git@github.com:ericaro/mrepo2.git" "mdev" "mprod" "src/github.com/ericaro/mrepoa" "git@github.com:ericaro/mrepoa.git" ` //and this is a human edited legacy version (order is messy) legacy := ` "src/github.com/ericaro/mrepo" "git@github.com:ericaro/mrepo.git" "master" "src/github.com/ericaro/mrepo_prod" "git@github.com:ericaro/mrepo.git" "mprod" "src/github.com/ericaro/mrepo_dev" "git@github.com:ericaro/mrepo.git" "mdev" "src/github.com/ericaro/mrepo_dev2" "git@github.com:ericaro/mrepo2.git" "mdev" "src/github.com/ericaro/mrepoa" "git@github.com:ericaro/mrepoa.git" "mprod" ` // all shall give the same normalize form normalizer := func(sbr string) string { sbrs, _ := ReadFrom(strings.NewReader(sbr)) buf := new(bytes.Buffer) WriteTo(buf, sbrs) return buf.String() } if n := normalizer(normalized); n != normalized { fmt.Printf("normalization should be invariant:\n%q\n%q\n", n, normalized) } if n := normalizer(humanized); n != normalized { fmt.Printf("humanized should lead to same result:\n%q\n%q\n", n, normalized) } if n := normalizer(legacy); n != normalized { fmt.Printf("humanized should lead to same result:\n%q\n%q\n", n, normalized) } fmt.Printf("Ok\n")
Output: Ok
func ReadFromBranch ¶
ReadFromBranch read subrepository definitions from reader
type Workspace ¶
type Workspace struct {
// contains filtered or unexported fields
}
func FindWorkspace ¶
FindWorkspace get the current working dir and search for a .sbr file upwards
FindWorkspace(os.Getwd() )
func NewWorkspace ¶
NewWorkspace creates a new Workspace for a working dir.
func (*Workspace) ScanRel ¶
ScanRel extract only the path of the subrepositories (faster than the whole dependency)