extract little rootedPaths helper
This commit is contained in:
parent
de8c915678
commit
1a4b2cf9b8
@ -18,23 +18,7 @@ import (
|
|||||||
|
|
||||||
func checkoutCommand(cmd *cobra.Command, args []string) {
|
func checkoutCommand(cmd *cobra.Command, args []string) {
|
||||||
requireInRepo()
|
requireInRepo()
|
||||||
|
filter := filepathfilter.New(rootedPaths(args), nil)
|
||||||
// Parameters are filters
|
|
||||||
// firstly convert any pathspecs to the root of the repo, in case this is being executed in a sub-folder
|
|
||||||
var rootedpaths []string
|
|
||||||
|
|
||||||
inchan := make(chan string, 1)
|
|
||||||
outchan, err := lfs.ConvertCwdFilesRelativeToRepo(inchan)
|
|
||||||
if err != nil {
|
|
||||||
Panic(err, "Could not checkout")
|
|
||||||
}
|
|
||||||
for _, arg := range args {
|
|
||||||
inchan <- arg
|
|
||||||
rootedpaths = append(rootedpaths, <-outchan)
|
|
||||||
}
|
|
||||||
close(inchan)
|
|
||||||
|
|
||||||
filter := filepathfilter.New(rootedpaths, nil)
|
|
||||||
checkoutWithIncludeExclude(filter)
|
checkoutWithIncludeExclude(filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,6 +177,25 @@ func checkoutWithChan(in <-chan *lfs.WrappedPointer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parameters are filters
|
||||||
|
// firstly convert any pathspecs to the root of the repo, in case this is being
|
||||||
|
// executed in a sub-folder
|
||||||
|
func rootedPaths(args []string) []string {
|
||||||
|
inchan := make(chan string, 1)
|
||||||
|
outchan, err := lfs.ConvertCwdFilesRelativeToRepo(inchan)
|
||||||
|
if err != nil {
|
||||||
|
Panic(err, "Could not checkout")
|
||||||
|
}
|
||||||
|
|
||||||
|
rootedpaths := make([]string, 0, len(args))
|
||||||
|
for _, arg := range args {
|
||||||
|
inchan <- arg
|
||||||
|
rootedpaths = append(rootedpaths, <-outchan)
|
||||||
|
}
|
||||||
|
close(inchan)
|
||||||
|
return rootedpaths
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterCommand("checkout", checkoutCommand, nil)
|
RegisterCommand("checkout", checkoutCommand, nil)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user