Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2846)

Unified Diff: cipd/client/cmd/cipd/friendly.go

Issue 2661313003: [cipd] Enable subdirs functionality. (Closed)
Patch Set: Make golint happy Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cipd/client/cipd/common/common.go ('k') | cipd/client/cmd/cipd/main.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cipd/client/cmd/cipd/friendly.go
diff --git a/cipd/client/cmd/cipd/friendly.go b/cipd/client/cmd/cipd/friendly.go
index 8c87d587c74a7732387a20d2467e4df381bdc686..e6b084ee21b2e1e3a56963b33e8c94a4d4a9230f 100644
--- a/cipd/client/cmd/cipd/friendly.go
+++ b/cipd/client/cmd/cipd/friendly.go
@@ -232,48 +232,24 @@ func (site *installationSite) modifyConfig(cb func(cfg *installationSiteConfig)
// installedPackages discovers versions of packages installed in the site.
//
// If pkgs is empty array, it returns list of all installed packages.
-func (site *installationSite) installedPackages(ctx context.Context, pkgs []string) ([]pinInfo, error) {
+func (site *installationSite) installedPackages(ctx context.Context) (map[string][]pinInfo, error) {
d := local.NewDeployer(site.siteRoot)
- // List all?
- if len(pkgs) == 0 {
- allPins, err := d.FindDeployed(ctx)
- if err != nil {
- return nil, err
- }
- if err := allPins.AssertOnlyDefaultSubdir(); err != nil {
- return nil, err
- }
- pins := allPins[""]
- output := make([]pinInfo, len(pins))
+ allPins, err := d.FindDeployed(ctx)
+ if err != nil {
+ return nil, err
+ }
+ output := make(map[string][]pinInfo, len(allPins))
+ for subdir, pins := range allPins {
+ output[subdir] = make([]pinInfo, len(pins))
for i, pin := range pins {
cpy := pin
- output[i] = pinInfo{
+ output[subdir][i] = pinInfo{
Pkg: pin.PackageName,
Pin: &cpy,
Tracking: site.cfg.TrackedVersions[pin.PackageName],
}
}
- return output, nil
- }
-
- // List specific packages only.
- output := make([]pinInfo, len(pkgs))
- for i, pkgName := range pkgs {
- pin, err := d.CheckDeployed(ctx, "", pkgName)
- if err == nil {
- output[i] = pinInfo{
- Pkg: pkgName,
- Pin: &pin,
- Tracking: site.cfg.TrackedVersions[pkgName],
- }
- } else {
- output[i] = pinInfo{
- Pkg: pkgName,
- Tracking: site.cfg.TrackedVersions[pkgName],
- Err: err.Error(),
- }
- }
}
return output, nil
}
@@ -496,7 +472,7 @@ func (c *installRun) Run(a subcommands.Application, args []string, env subcomman
func cmdInstalled() *subcommands.Command {
return &subcommands.Command{
Advanced: true,
- UsageLine: "installed [<package> <package> ...] [options]",
+ UsageLine: "installed [options]",
ShortDesc: "lists packages installed in the site root",
LongDesc: "Lists packages installed in the site root.",
CommandRun: func() subcommands.CommandRun {
@@ -514,7 +490,7 @@ type installedRun struct {
}
func (c *installedRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {
- if !c.checkArgs(args, 0, -1) {
+ if !c.checkArgs(args, 0, 0) {
return 1
}
site, err := getInstallationSite(c.rootDir)
@@ -522,5 +498,5 @@ func (c *installedRun) Run(a subcommands.Application, args []string, env subcomm
return c.done(nil, err)
}
ctx := cli.GetContext(a, c, env)
- return c.doneWithPins(site.installedPackages(ctx, args))
+ return c.doneWithPinMap(site.installedPackages(ctx))
}
« no previous file with comments | « cipd/client/cipd/common/common.go ('k') | cipd/client/cmd/cipd/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698