mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
Resolve PR #976 review comments
Signed-off-by: Joshua Colson <joshua.colson@gmail.com>
This commit is contained in:
committed by
Lorenzo Bolla
parent
899ed92ebc
commit
0bc66032d2
@@ -43,9 +43,7 @@ func aptlyMirrorListTxt(cmd *commander.Command, args []string) error {
|
||||
|
||||
context.CloseDatabase()
|
||||
|
||||
if len(repos) > 0 {
|
||||
sort.Strings(repos)
|
||||
}
|
||||
sort.Strings(repos)
|
||||
|
||||
if raw {
|
||||
for _, repo := range repos {
|
||||
|
||||
@@ -97,8 +97,6 @@ func aptlyMirrorShowJson(cmd *commander.Command, args []string) error {
|
||||
|
||||
name := args[0]
|
||||
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
|
||||
repo, err := context.CollectionFactory().RemoteRepoCollection().ByName(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to show: %s", err)
|
||||
@@ -110,6 +108,7 @@ func aptlyMirrorShowJson(cmd *commander.Command, args []string) error {
|
||||
}
|
||||
|
||||
// include packages if requested
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
if withPackages {
|
||||
if repo.RefList() != nil {
|
||||
var list *deb.PackageList
|
||||
|
||||
@@ -48,13 +48,13 @@ func aptlyRepoListTxt(cmd *commander.Command, args []string) error {
|
||||
|
||||
context.CloseDatabase()
|
||||
|
||||
sort.Strings(repos)
|
||||
|
||||
if raw {
|
||||
sort.Strings(repos)
|
||||
for _, repo := range repos {
|
||||
fmt.Printf("%s\n", repo)
|
||||
}
|
||||
} else {
|
||||
sort.Strings(repos)
|
||||
if len(repos) > 0 {
|
||||
fmt.Printf("List of local repos:\n")
|
||||
for _, repo := range repos {
|
||||
|
||||
@@ -11,16 +11,24 @@ import (
|
||||
)
|
||||
|
||||
func aptlyRepoShow(cmd *commander.Command, args []string) error {
|
||||
var err error
|
||||
if len(args) != 1 {
|
||||
cmd.Usage()
|
||||
return commander.ErrCommandError
|
||||
}
|
||||
|
||||
name := args[0]
|
||||
|
||||
jsonFlag := cmd.Flag.Lookup("json").Value.Get().(bool)
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
|
||||
if jsonFlag {
|
||||
return aptlyRepoShowJson(cmd, args)
|
||||
}
|
||||
|
||||
return aptlyRepoShowTxt(cmd, args)
|
||||
}
|
||||
|
||||
func aptlyRepoShowTxt(cmd *commander.Command, args []string) error {
|
||||
var err error
|
||||
|
||||
name := args[0]
|
||||
|
||||
repo, err := context.CollectionFactory().LocalRepoCollection().ByName(name)
|
||||
if err != nil {
|
||||
@@ -32,42 +40,60 @@ func aptlyRepoShow(cmd *commander.Command, args []string) error {
|
||||
return fmt.Errorf("unable to show: %s", err)
|
||||
}
|
||||
|
||||
if jsonFlag {
|
||||
// include packages if requested
|
||||
packageList := []string{}
|
||||
if withPackages {
|
||||
if repo.RefList() != nil {
|
||||
var list *deb.PackageList
|
||||
list, err = deb.NewPackageListFromRefList(repo.RefList(), context.CollectionFactory().PackageCollection(), context.Progress())
|
||||
if err == nil {
|
||||
packageList = list.FullNames()
|
||||
}
|
||||
fmt.Printf("Name: %s\n", repo.Name)
|
||||
fmt.Printf("Comment: %s\n", repo.Comment)
|
||||
fmt.Printf("Default Distribution: %s\n", repo.DefaultDistribution)
|
||||
fmt.Printf("Default Component: %s\n", repo.DefaultComponent)
|
||||
if repo.Uploaders != nil {
|
||||
fmt.Printf("Uploaders: %s\n", repo.Uploaders)
|
||||
}
|
||||
fmt.Printf("Number of packages: %d\n", repo.NumPackages())
|
||||
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
if withPackages {
|
||||
ListPackagesRefList(repo.RefList())
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func aptlyRepoShowJson(cmd *commander.Command, args []string) error {
|
||||
var err error
|
||||
|
||||
name := args[0]
|
||||
|
||||
repo, err := context.CollectionFactory().LocalRepoCollection().ByName(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to show: %s", err)
|
||||
}
|
||||
|
||||
err = context.CollectionFactory().LocalRepoCollection().LoadComplete(repo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to show: %s", err)
|
||||
}
|
||||
|
||||
// include packages if requested
|
||||
packageList := []string{}
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
if withPackages {
|
||||
if repo.RefList() != nil {
|
||||
var list *deb.PackageList
|
||||
list, err = deb.NewPackageListFromRefList(repo.RefList(), context.CollectionFactory().PackageCollection(), context.Progress())
|
||||
if err == nil {
|
||||
packageList = list.FullNames()
|
||||
}
|
||||
|
||||
sort.Strings(packageList)
|
||||
}
|
||||
|
||||
// merge the repo object with the package list
|
||||
var output []byte
|
||||
if output, err = json.MarshalIndent(struct {
|
||||
*deb.LocalRepo
|
||||
Packages []string
|
||||
}{repo, packageList}, "", " "); err == nil {
|
||||
fmt.Println(string(output))
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("Name: %s\n", repo.Name)
|
||||
fmt.Printf("Comment: %s\n", repo.Comment)
|
||||
fmt.Printf("Default Distribution: %s\n", repo.DefaultDistribution)
|
||||
fmt.Printf("Default Component: %s\n", repo.DefaultComponent)
|
||||
if repo.Uploaders != nil {
|
||||
fmt.Printf("Uploaders: %s\n", repo.Uploaders)
|
||||
}
|
||||
fmt.Printf("Number of packages: %d\n", repo.NumPackages())
|
||||
sort.Strings(packageList)
|
||||
}
|
||||
|
||||
if withPackages {
|
||||
ListPackagesRefList(repo.RefList())
|
||||
}
|
||||
// merge the repo object with the package list
|
||||
var output []byte
|
||||
if output, err = json.MarshalIndent(struct {
|
||||
*deb.LocalRepo
|
||||
Packages []string
|
||||
}{repo, packageList}, "", " "); err == nil {
|
||||
fmt.Println(string(output))
|
||||
}
|
||||
|
||||
return err
|
||||
|
||||
@@ -29,8 +29,6 @@ func aptlySnapshotShowTxt(cmd *commander.Command, args []string) error {
|
||||
var err error
|
||||
name := args[0]
|
||||
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
|
||||
snapshot, err := context.CollectionFactory().SnapshotCollection().ByName(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to show: %s", err)
|
||||
@@ -78,6 +76,7 @@ func aptlySnapshotShowTxt(cmd *commander.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
if withPackages {
|
||||
ListPackagesRefList(snapshot.RefList())
|
||||
}
|
||||
@@ -90,8 +89,6 @@ func aptlySnapshotShowJson(cmd *commander.Command, args []string) error {
|
||||
|
||||
name := args[0]
|
||||
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
|
||||
snapshot, err := context.CollectionFactory().SnapshotCollection().ByName(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to show: %s", err)
|
||||
@@ -131,6 +128,7 @@ func aptlySnapshotShowJson(cmd *commander.Command, args []string) error {
|
||||
}
|
||||
|
||||
// include packages if requested
|
||||
withPackages := context.Flags().Lookup("with-packages").Value.Get().(bool)
|
||||
if withPackages {
|
||||
if snapshot.RefList() != nil {
|
||||
var list *deb.PackageList
|
||||
|
||||
Reference in New Issue
Block a user