Rename rebuild to restore to match the gb-vendor command
diff --git a/README.md b/README.md
index bd120e2..a43e2fc 100644
--- a/README.md
+++ b/README.md
@@ -65,7 +65,7 @@
vendor/**
!vendor/manifest
-When you check out the source again, you can then run `gvt rebuild` to fetch all the dependencies at the revisions specified in the `vendor/manifest` file.
+When you check out the source again, you can then run `gvt restore` to fetch all the dependencies at the revisions specified in the `vendor/manifest` file.
Please consider that this approach has the following consequences:
diff --git a/alldocs.go b/alldocs.go
index bb5e889..fe7563c 100644
--- a/alldocs.go
+++ b/alldocs.go
@@ -10,7 +10,7 @@
The commands are:
fetch fetch a remote dependency
- rebuild rebuild dependencies from manifest
+ restore restore dependencies from manifest
update update a local dependency
list list dependencies one per line
delete delete a local dependency
@@ -43,12 +43,12 @@
-precaire
allow the use of insecure protocols.
-Rebuild dependencies from manifest
+Restore dependencies from manifest
Usage:
- gvt rebuild
+ gvt restore
-rebuild fetches the dependencies listed in the manifest.
+restore fetches the dependencies listed in the manifest.
It's meant for workflows that don't include checking in to VCS the vendored
source, for example if .gitignore includes lines like
@@ -56,7 +56,7 @@
vendor/**
!vendor/manifest
-Note that such a setup requires "gvt rebuild" to build the source, relies on
+Note that such a setup requires "gvt restore" to build the source, relies on
the availability of the dependencies repositories and breaks "go get".
Flags:
diff --git a/gbvendor/repo.go b/gbvendor/repo.go
index eb52e84..5a52c2b 100644
--- a/gbvendor/repo.go
+++ b/gbvendor/repo.go
@@ -477,7 +477,7 @@
}
func cleanPath(path string) error {
- if files, _ := ioutil.ReadDir(path); len(files) > 0 || filepath.Base(path) == "src" {
+ if files, _ := ioutil.ReadDir(path); len(files) > 0 || filepath.Base(path) == "vendor" {
return nil
}
parent := filepath.Dir(path)
diff --git a/main.go b/main.go
index 6245927..93c8ef8 100644
--- a/main.go
+++ b/main.go
@@ -24,7 +24,7 @@
var commands = []*Command{
cmdFetch,
- cmdRebuild,
+ cmdRestore,
cmdUpdate,
cmdList,
cmdDelete,
@@ -40,6 +40,9 @@
case args[0] == "help":
help(args[1:])
return
+ case args[0] == "rebuild":
+ // rebuild was renamed restore, alias for backwards compatibility
+ args[0] = "restore"
}
for _, command := range commands {
diff --git a/rebuild.go b/restore.go
similarity index 79%
rename from rebuild.go
rename to restore.go
index 449747c..eedeaf5 100644
--- a/rebuild.go
+++ b/restore.go
@@ -18,16 +18,16 @@
rbConnections uint // Count of concurrent download connections
)
-func addRebuildFlags(fs *flag.FlagSet) {
+func addRestoreFlags(fs *flag.FlagSet) {
fs.BoolVar(&rbInsecure, "precaire", false, "allow the use of insecure protocols")
fs.UintVar(&rbConnections, "connections", 8, "count of parallel download connections")
}
-var cmdRebuild = &Command{
- Name: "rebuild",
- UsageLine: "rebuild",
- Short: "rebuild dependencies from manifest",
- Long: `rebuild fetches the dependencies listed in the manifest.
+var cmdRestore = &Command{
+ Name: "restore",
+ UsageLine: "restore [-precaire] [-connections N]",
+ Short: "restore dependencies from manifest",
+ Long: `restore fetches the dependencies listed in the manifest.
It's meant for workflows that don't include checking in to VCS the vendored
source, for example if .gitignore includes lines like
@@ -35,7 +35,7 @@
vendor/**
!vendor/manifest
-Note that such a setup requires "gvt rebuild" to build the source, relies on
+Note that such a setup requires "gvt restore" to build the source, relies on
the availability of the dependencies repositories and breaks "go get".
Flags:
@@ -47,15 +47,15 @@
Run: func(args []string) error {
switch len(args) {
case 0:
- return rebuild()
+ return restore()
default:
- return fmt.Errorf("rebuild takes no arguments")
+ return fmt.Errorf("restore takes no arguments")
}
},
- AddFlags: addRebuildFlags,
+ AddFlags: addRestoreFlags,
}
-func rebuild() error {
+func restore() error {
m, err := vendor.ReadManifest(manifestFile())
if err != nil {
return fmt.Errorf("could not load manifest: %v", err)
@@ -91,27 +91,24 @@
}
func downloadDependency(dep vendor.Dependency) error {
+ log.Printf("fetching %s", dep.Importpath)
+ repo, _, err := vendor.DeduceRemoteRepo(dep.Importpath, rbInsecure)
+ if err != nil {
+ return fmt.Errorf("dependency could not be processed: %s", err)
+ }
+ wc, err := repo.Checkout("", "", dep.Revision)
+ if err != nil {
+ return fmt.Errorf("dependency could not be fetched: %s", err)
+ }
dst := filepath.Join(vendorDir(), dep.Importpath)
+ src := filepath.Join(wc.Dir(), dep.Path)
+
if _, err := os.Stat(dst); err == nil {
if err := fileutils.RemoveAll(dst); err != nil {
- // TODO need to apply vendor.cleanpath here too
return fmt.Errorf("dependency could not be deleted: %v", err)
}
}
- log.Printf("fetching %s", dep.Importpath)
-
- repo, _, err := vendor.DeduceRemoteRepo(dep.Importpath, rbInsecure)
- if err != nil {
- return err
- }
-
- wc, err := repo.Checkout("", "", dep.Revision)
- if err != nil {
- return err
- }
-
- src := filepath.Join(wc.Dir(), dep.Path)
if err := fileutils.Copypath(dst, src); err != nil {
return err
}