Rename 'dep' to 'hoard', where appropriate

This commit is contained in:
sam boyer 2017-01-08 20:06:34 -05:00 коммит произвёл Jess Frazelle
Родитель 9faa37b6ea
Коммит 302ad3eaf7
12 изменённых файлов: 60 добавлений и 60 удалений

Просмотреть файл

@ -12,7 +12,7 @@ import (
)
func TestDeriveManifestAndLock(t *testing.T) {
dir, err := ioutil.TempDir("", "dep")
dir, err := ioutil.TempDir("", "hoard")
if err != nil {
t.Fatal(err)
}
@ -56,7 +56,7 @@ func TestDeriveManifestAndLock(t *testing.T) {
}
func TestDeriveManifestAndLockDoesNotExist(t *testing.T) {
dir, err := ioutil.TempDir("", "dep")
dir, err := ioutil.TempDir("", "hoard")
if err != nil {
t.Fatal(err)
}

Просмотреть файл

@ -36,7 +36,7 @@ func newContext() (*ctx, error) {
}
func (c *ctx) sourceManager() (*gps.SourceMgr, error) {
return gps.NewSourceManager(analyzer{}, filepath.Join(c.GOPATH, "pkg", "depcache"))
return gps.NewSourceManager(analyzer{}, filepath.Join(c.GOPATH, "pkg", "hoard"))
}
// loadProject searches for a project root from the provided path, then loads
@ -69,7 +69,7 @@ func (c *ctx) loadProject(path string) (*project, error) {
mf, err := os.Open(mp)
if err != nil {
if os.IsNotExist(err) {
// TODO: list possible solutions? (dep init, cd $project)
// TODO: list possible solutions? (hoard init, cd $project)
return nil, fmt.Errorf("no %v found in project root %v", manifestName, p.absroot)
}
// Unable to read the manifest file

Просмотреть файл

@ -30,7 +30,7 @@ func TestSplitAbsoluteProjectRoot(t *testing.T) {
tg.tempDir("src")
tg.setenv("GOPATH", tg.path("."))
depCtx := &ctx{GOPATH: tg.path(".")}
hoardCtx := &ctx{GOPATH: tg.path(".")}
importPaths := []string{
"github.com/pkg/errors",
@ -38,8 +38,8 @@ func TestSplitAbsoluteProjectRoot(t *testing.T) {
}
for _, ip := range importPaths {
fullpath := filepath.Join(depCtx.GOPATH, "src", ip)
pr, err := depCtx.splitAbsoluteProjectRoot(fullpath)
fullpath := filepath.Join(hoardCtx.GOPATH, "src", ip)
pr, err := hoardCtx.splitAbsoluteProjectRoot(fullpath)
if err != nil {
t.Fatal(err)
}
@ -49,7 +49,7 @@ func TestSplitAbsoluteProjectRoot(t *testing.T) {
}
// test where it should return error
pr, err := depCtx.splitAbsoluteProjectRoot("tra/la/la/la")
pr, err := hoardCtx.splitAbsoluteProjectRoot("tra/la/la/la")
if err == nil {
t.Fatalf("should have gotten error but did not for tra/la/la/la: %s", pr)
}
@ -61,7 +61,7 @@ func TestAbsoluteProjectRoot(t *testing.T) {
tg.tempDir("src")
tg.setenv("GOPATH", tg.path("."))
depCtx := &ctx{GOPATH: tg.path(".")}
hoardCtx := &ctx{GOPATH: tg.path(".")}
importPaths := map[string]bool{
"github.com/pkg/errors": true,
@ -75,7 +75,7 @@ func TestAbsoluteProjectRoot(t *testing.T) {
}
for i, ok := range importPaths {
pr, err := depCtx.absoluteProjectRoot(i)
pr, err := hoardCtx.absoluteProjectRoot(i)
if ok {
tg.must(err)
expected := tg.path(filepath.Join("src", i))
@ -92,7 +92,7 @@ func TestAbsoluteProjectRoot(t *testing.T) {
// test that a file fails
tg.tempFile("src/thing/thing.go", "hello world")
_, err := depCtx.absoluteProjectRoot("thing/thing.go")
_, err := hoardCtx.absoluteProjectRoot("thing/thing.go")
if err == nil {
t.Fatal("error should not be nil for a file found")
}
@ -107,7 +107,7 @@ func TestVersionInWorkspace(t *testing.T) {
tg.tempDir("src")
tg.setenv("GOPATH", tg.path("."))
depCtx := &ctx{GOPATH: tg.path(".")}
hoardCtx := &ctx{GOPATH: tg.path(".")}
importPaths := map[string]struct {
rev gps.Version
@ -134,7 +134,7 @@ func TestVersionInWorkspace(t *testing.T) {
tg.runGit(repoDir, "checkout", info.rev.String())
}
v, err := depCtx.versionInWorkspace(gps.ProjectRoot(ip))
v, err := hoardCtx.versionInWorkspace(gps.ProjectRoot(ip))
tg.must(err)
if v != info.rev {

Просмотреть файл

@ -25,14 +25,14 @@ func init() {
}
}
// The TestMain function creates a dep command for testing purposes and
// The TestMain function creates a hoard command for testing purposes and
// deletes it after the tests have been run.
// Most of this is taken from https://github.com/golang/go/blob/master/src/cmd/go/go_test.go and reused here.
func TestMain(m *testing.M) {
args := []string{"build", "-o", "testdep" + exeSuffix}
args := []string{"build", "-o", "testhoard" + exeSuffix}
out, err := exec.Command("go", args...).CombinedOutput()
if err != nil {
fmt.Fprintf(os.Stderr, "building testdep failed: %v\n%s", err, out)
fmt.Fprintf(os.Stderr, "building testhoard failed: %v\n%s", err, out)
os.Exit(2)
}
@ -45,11 +45,11 @@ func TestMain(m *testing.M) {
// those systems. Set CCACHE_DIR to cope. Issue 17668.
os.Setenv("CCACHE_DIR", filepath.Join(home, ".ccache"))
}
os.Setenv("HOME", "/test-dep-home-does-not-exist")
os.Setenv("HOME", "/test-hoard-home-does-not-exist")
r := m.Run()
os.Remove("testdep" + exeSuffix)
os.Remove("testhoard" + exeSuffix)
os.Exit(r)
}
@ -164,12 +164,12 @@ func (tg *testgoData) doRun(args []string) error {
}
}
}
tg.t.Logf("running testdep %v", args)
tg.t.Logf("running testhoard %v", args)
var prog string
if tg.wd == "" {
prog = "./testdep" + exeSuffix
prog = "./testhoard" + exeSuffix
} else {
prog = filepath.Join(tg.wd, "testdep"+exeSuffix)
prog = filepath.Join(tg.wd, "testhoard"+exeSuffix)
}
args = append(args[:1], append([]string{"-v"}, args[1:]...)...)
cmd := exec.Command(prog, args...)

Просмотреть файл

@ -35,41 +35,41 @@ Package spec:
Examples:
dep ensure Populate vendor from existing manifest and lock
dep ensure github.com/pkg/foo@^1.0.1 Update a specific dependency to a specific version
hoard ensure Populate vendor from existing manifest and lock
hoard ensure github.com/pkg/foo@^1.0.1 Update a specific dependency to a specific version
For more detailed usage examples, see dep ensure -examples.
For more detailed usage examples, see hoard ensure -examples.
`
const ensureExamples = `
dep ensure
hoard ensure
Solve the project's dependency graph, and place all dependencies in the
vendor folder. If a dependency is in the lock file, use the version
specified there. Otherwise, use the most recent version that can satisfy the
constraints in the manifest file.
dep ensure -update
hoard ensure -update
Update all dependencies to the latest versions allowed by the manifest, ignoring
any versions specified in the lock file. Update the lock file with any
changes.
dep ensure github.com/pkg/foo@^1.0.1
hoard ensure github.com/pkg/foo@^1.0.1
Same as above, but choose any release >= 1.0.1, < 2.0.0. If a constraint was
previously set in the manifest, this resets it. This form of constraint
strikes a good balance of safety and flexibility, and should be preferred
for libraries.
dep ensure github.com/pkg/foo@~1.0.1
hoard ensure github.com/pkg/foo@~1.0.1
Same as above, but choose any release matching 1.0.x, preferring latest.
dep ensure github.com/pkg/foo:git.internal.com/alt/foo
hoard ensure github.com/pkg/foo:git.internal.com/alt/foo
Fetch the dependency from a different location.
dep ensure -override github.com/pkg/foo@^1.0.1
hoard ensure -override github.com/pkg/foo@^1.0.1
Forcefully and transitively override any constraint for this dependency.
Overrides are powerful, but harmful in the long term. They should be used
@ -105,12 +105,12 @@ func (cmd *ensureCommand) Run(args []string) error {
return errors.New("Cannot pass -update and itemized project list (for now)")
}
p, err := depContext.loadProject("")
p, err := hoardContext.loadProject("")
if err != nil {
return err
}
sm, err := depContext.sourceManager()
sm, err := hoardContext.sourceManager()
if err != nil {
return err
}

Просмотреть файл

@ -118,7 +118,7 @@ func TestDeduceConstraint(t *testing.T) {
}
func TestCopyFolder(t *testing.T) {
dir, err := ioutil.TempDir("", "dep")
dir, err := ioutil.TempDir("", "hoard")
if err != nil {
t.Fatal(err)
}
@ -179,7 +179,7 @@ func TestCopyFolder(t *testing.T) {
}
func TestCopyFile(t *testing.T) {
dir, err := ioutil.TempDir("", "dep")
dir, err := ioutil.TempDir("", "hoard")
if err != nil {
t.Fatal(err)
}

14
init.go
Просмотреть файл

@ -28,7 +28,7 @@ but it will be solved-for, and will appear in the lock.
Note: init may use the network to solve the dependency graph.
Note: init does NOT vendor dependencies at the moment. See dep ensure.
Note: init does NOT vendor dependencies at the moment. See hoard ensure.
`
func (cmd *initCommand) Name() string { return "init" }
@ -76,7 +76,7 @@ func (cmd *initCommand) Run(args []string) error {
return fmt.Errorf("Invalid state: manifest %q does not exist, but lock %q does.", mf, lf)
}
cpr, err := depContext.splitAbsoluteProjectRoot(root)
cpr, err := hoardContext.splitAbsoluteProjectRoot(root)
if err != nil {
return errors.Wrap(err, "determineProjectRoot")
}
@ -86,7 +86,7 @@ func (cmd *initCommand) Run(args []string) error {
return errors.Wrap(err, "gps.ListPackages")
}
vlogf("Found %d dependencies.", len(pkgT.Packages))
sm, err := depContext.sourceManager()
sm, err := hoardContext.sourceManager()
if err != nil {
return errors.Wrap(err, "getSourceManager")
}
@ -296,7 +296,7 @@ func getProjectData(pkgT gps.PackageTree, cpr string, sm *gps.SourceMgr) (projec
vlogf("Package %q has import %q, analyzing...", v.P.ImportPath, ip)
dependencies[pr] = []string{ip}
v, err := depContext.versionInWorkspace(pr)
v, err := hoardContext.versionInWorkspace(pr)
if err != nil {
notondisk[pr] = true
vlogf("Could not determine version for %q, omitting from generated manifest", pr)
@ -317,7 +317,7 @@ func getProjectData(pkgT gps.PackageTree, cpr string, sm *gps.SourceMgr) (projec
}
}
vlogf("Analyzing transitive dependencies...")
vlogf("Analyzing transitive imports...")
// Explore the packages we've found for transitive deps, either
// completing the lock or identifying (more) missing projects that we'll
// need to ask gps to solve for us.
@ -357,7 +357,7 @@ func getProjectData(pkgT gps.PackageTree, cpr string, sm *gps.SourceMgr) (projec
// It's fine if the root does not exist - it indicates that this
// project is not present in the workspace, and so we need to
// solve to deal with this dep.
r := filepath.Join(depContext.GOPATH, "src", string(pr))
r := filepath.Join(hoardContext.GOPATH, "src", string(pr))
_, err := os.Lstat(r)
if os.IsNotExist(err) {
colors[pkg] = black
@ -396,7 +396,7 @@ func getProjectData(pkgT gps.PackageTree, cpr string, sm *gps.SourceMgr) (projec
// whether we're first seeing it here, in the transitive
// exploration, or if it arose in the direct dep parts
if _, in := ondisk[pr]; !in {
v, err := depContext.versionInWorkspace(pr)
v, err := hoardContext.versionInWorkspace(pr)
if err != nil {
colors[pkg] = black
notondisk[pr] = true

Просмотреть файл

@ -70,7 +70,7 @@ func readLock(r io.Reader) (*lock, error) {
id := gps.ProjectIdentifier{
ProjectRoot: gps.ProjectRoot(ld.Name),
Source: ld.Repository,
Source: ld.Repository,
}
l.P[i] = gps.NewLockedProject(id, v, ld.Packages)
}
@ -135,14 +135,14 @@ func (l *lock) MarshalJSON() ([]byte, error) {
return buf.Bytes(), err
}
// lockFromInterface converts an arbitrary gps.Lock to dep's representation of a
// lock. If the input is already dep's *lock, the input is returned directly.
// lockFromInterface converts an arbitrary gps.Lock to hoard's representation of a
// lock. If the input is already hoard's *lock, the input is returned directly.
//
// Data is defensively copied wherever necessary to ensure the resulting *lock
// shares no memory with the original lock.
//
// As gps.Solution is a superset of gps.Lock, this can also be used to convert
// solutions to dep's lock form.
// solutions to hoard's lock format.
func lockFromInterface(in gps.Lock) *lock {
if in == nil {
return nil

16
main.go
Просмотреть файл

@ -23,8 +23,8 @@ const (
)
var (
depContext *ctx
verbose = flag.Bool("v", false, "enable verbose logging")
hoardContext *ctx
verbose = flag.Bool("v", false, "enable verbose logging")
)
type command interface {
@ -37,14 +37,14 @@ type command interface {
}
func main() {
// Set up the dep context.
// Set up the hoard context.
// TODO(pb): can this be deglobalized, pretty please?
dc, err := newContext()
hc, err := newContext()
if err != nil {
fmt.Fprint(os.Stderr, err.Error())
os.Exit(1)
}
depContext = dc
hoardContext = hc
// Build the list of available commands.
commands := []command{
@ -55,7 +55,7 @@ func main() {
}
usage := func() {
fmt.Fprintln(os.Stderr, "Usage: dep <command>")
fmt.Fprintln(os.Stderr, "Usage: hoard <command>")
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, "Commands:")
fmt.Fprintln(os.Stderr)
@ -125,7 +125,7 @@ func resetUsage(fs *flag.FlagSet, name, args, longHelp string) {
})
flagWriter.Flush()
fs.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: dep %s %s\n", name, args)
fmt.Fprintf(os.Stderr, "Usage: hoard %s %s\n", name, args)
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, strings.TrimSpace(longHelp))
fmt.Fprintln(os.Stderr)
@ -201,7 +201,7 @@ func (p *project) makeParams() gps.SolveParameters {
func logf(format string, args ...interface{}) {
// TODO: something else?
fmt.Fprintf(os.Stderr, "dep: "+format+"\n", args...)
fmt.Fprintf(os.Stderr, "hoard: "+format+"\n", args...)
}
func vlogf(format string, args ...interface{}) {

Просмотреть файл

@ -42,19 +42,19 @@ type removeCommand struct {
}
func (cmd *removeCommand) Run(args []string) error {
p, err := depContext.loadProject("")
p, err := hoardContext.loadProject("")
if err != nil {
return err
}
sm, err := depContext.sourceManager()
sm, err := hoardContext.sourceManager()
if err != nil {
return err
}
sm.UseDefaultSignalHandling()
defer sm.Release()
cpr, err := depContext.splitAbsoluteProjectRoot(p.absroot)
cpr, err := hoardContext.splitAbsoluteProjectRoot(p.absroot)
if err != nil {
return errors.Wrap(err, "determineProjectRoot")
}

Просмотреть файл

@ -64,12 +64,12 @@ type statusCommand struct {
}
func (cmd *statusCommand) Run(args []string) error {
p, err := depContext.loadProject("")
p, err := hoardContext.loadProject("")
if err != nil {
return err
}
sm, err := depContext.sourceManager()
sm, err := hoardContext.sourceManager()
if err != nil {
return err
}

Просмотреть файл

@ -32,7 +32,7 @@ type safeWriter struct {
// tree, to a temp dir, then moves them into place if and only if all the write
// operations succeeded. It also does its best to roll back if any moves fail.
//
// This mostly guarantees that dep cannot exit with a partial write that would
// This mostly guarantees that hoard cannot exit with a partial write that would
// leave an undefined state on disk.
//
// - If a sw.m is provided, it will be written to the standard manifest file
@ -101,7 +101,7 @@ func (sw safeWriter) writeAllSafe(forceVendor bool) error {
lpath := filepath.Join(sw.root, lockName)
vpath := filepath.Join(sw.root, "vendor")
td, err := ioutil.TempDir(os.TempDir(), "dep")
td, err := ioutil.TempDir(os.TempDir(), "hoard")
if err != nil {
return errors.Wrap(err, "error while creating temp dir for writing manifest/lock/vendor")
}