From e4d8ef47447cf96ba53743c013d00f98d339f1f0 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Sat, 15 Feb 2014 16:56:10 +0400 Subject: [PATCH] Showing download sources argument in mirror show and mirror list. --- cmd_mirror.go | 5 +++++ debian/remote.go | 10 +++++++++- debian/remote_test.go | 10 ++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cmd_mirror.go b/cmd_mirror.go index 77c556cb..1696fba4 100644 --- a/cmd_mirror.go +++ b/cmd_mirror.go @@ -138,6 +138,11 @@ func aptlyMirrorShow(cmd *commander.Command, args []string) error { fmt.Printf("Distribution: %s\n", repo.Distribution) fmt.Printf("Components: %s\n", strings.Join(repo.Components, ", ")) fmt.Printf("Architectures: %s\n", strings.Join(repo.Architectures, ", ")) + downloadSources := "no" + if repo.DownloadSources { + downloadSources = "yes" + } + fmt.Printf("Download Sources: %s\n", downloadSources) if repo.LastDownloadDate.IsZero() { fmt.Printf("Last update: never\n") } else { diff --git a/debian/remote.go b/debian/remote.go index 21d3a566..774e5055 100644 --- a/debian/remote.go +++ b/debian/remote.go @@ -86,7 +86,15 @@ func (repo *RemoteRepo) prepare() error { // String interface func (repo *RemoteRepo) String() string { - return fmt.Sprintf("[%s]: %s %s", repo.Name, repo.ArchiveRoot, repo.Distribution) + srcFlag := "" + if repo.DownloadSources { + srcFlag = " [src]" + } + distribution := repo.Distribution + if distribution == "" { + distribution = "./" + } + return fmt.Sprintf("[%s]: %s %s%s", repo.Name, repo.ArchiveRoot, distribution, srcFlag) } // IsFlat determines if repository is flat diff --git a/debian/remote_test.go b/debian/remote_test.go index 8b590991..99686199 100644 --- a/debian/remote_test.go +++ b/debian/remote_test.go @@ -103,6 +103,16 @@ func (s *RemoteRepoSuite) TestFlatCreation(c *C) { c.Check(err, ErrorMatches, "components aren't supported for flat repos") } +func (s *RemoteRepoSuite) TestString(c *C) { + c.Check(s.repo.String(), Equals, "[yandex]: http://mirror.yandex.ru/debian/ squeeze") + c.Check(s.flat.String(), Equals, "[exp42]: http://repos.express42.com/virool/precise/ ./") + + s.repo.DownloadSources = true + s.flat.DownloadSources = true + c.Check(s.repo.String(), Equals, "[yandex]: http://mirror.yandex.ru/debian/ squeeze [src]") + c.Check(s.flat.String(), Equals, "[exp42]: http://repos.express42.com/virool/precise/ ./ [src]") +} + func (s *RemoteRepoSuite) TestNumPackages(c *C) { c.Check(s.repo.NumPackages(), Equals, 0) s.repo.packageRefs = s.reflist