Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
76 lines (63 sloc) 1.98 KB
package main
import (
var (
// gb vendor delete flags
// delete all dependencies
deleteAll bool
func addDeleteFlags(fs *flag.FlagSet) {
fs.BoolVar(&deleteAll, "all", false, "delete all dependencies")
var cmdDelete = &cmd.Command{
Name: "delete",
UsageLine: "delete [-all] importpath",
Short: "deletes a local dependency",
Long: `delete removes a dependency from $PROJECT/vendor/src and the vendor manifest
remove all dependencies
Run: func(ctx *gb.Context, args []string) error {
if len(args) != 1 && !deleteAll {
return errors.New("delete: import path or --all flag is missing")
} else if len(args) >= 1 && deleteAll {
return errors.New("delete: you cannot specify path and --all flag at once")
m, err := vendor.ReadManifest(manifestFile(ctx))
if err != nil {
return errors.Errorf("could not load manifest: %v", err)
var dependencies []vendor.Dependency
if deleteAll {
dependencies = make([]vendor.Dependency, len(m.Dependencies))
copy(dependencies, m.Dependencies)
} else {
p := args[0]
dependency, err := m.GetDependencyForImportpath(p)
if err != nil {
return errors.Wrap(err, "could not get dependency")
dependencies = append(dependencies, dependency)
for _, d := range dependencies {
path := d.Importpath
if err := m.RemoveDependency(d); err != nil {
return errors.Wrap(err, "dependency could not be deleted")
if err := fileutils.RemoveAll(filepath.Join(ctx.Projectdir(), "vendor", "src", filepath.FromSlash(path))); err != nil {
// TODO(dfc) need to apply vendor.cleanpath here to remove intermediate directories.
return errors.Wrap(err, "dependency could not be deleted")
return vendor.WriteManifest(manifestFile(ctx), m)
AddFlags: addDeleteFlags,