mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-07 05:42:42 +00:00
Allow to customize Origin/Label during publishing. #29
This commit is contained in:
+23
-3
@@ -25,6 +25,8 @@ type PublishedRepo struct {
|
||||
Prefix string
|
||||
Distribution string
|
||||
Component string
|
||||
Origin string
|
||||
Label string
|
||||
// Architectures is a list of all architectures published
|
||||
Architectures []string
|
||||
// SourceKind is "local"/"repo"
|
||||
@@ -173,7 +175,17 @@ func (p *PublishedRepo) String() string {
|
||||
panic("no snapshot/localRepo")
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/%s (%s) [%s] publishes %s", p.Prefix, p.Distribution, p.Component, strings.Join(p.Architectures, ", "), source)
|
||||
var extra string
|
||||
|
||||
if p.Origin != "" {
|
||||
extra += fmt.Sprintf(", origin: %s", p.Origin)
|
||||
}
|
||||
|
||||
if p.Label != "" {
|
||||
extra += fmt.Sprintf(", label: %s", p.Label)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/%s (%s%s) [%s] publishes %s", p.Prefix, p.Distribution, p.Component, extra, strings.Join(p.Architectures, ", "), source)
|
||||
}
|
||||
|
||||
// Key returns unique key identifying PublishedRepo
|
||||
@@ -367,8 +379,16 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorage
|
||||
}
|
||||
|
||||
release := make(Stanza)
|
||||
release["Origin"] = p.Prefix + " " + p.Distribution
|
||||
release["Label"] = p.Prefix + " " + p.Distribution
|
||||
if p.Origin == "" {
|
||||
release["Origin"] = p.Prefix + " " + p.Distribution
|
||||
} else {
|
||||
release["Origin"] = p.Origin
|
||||
}
|
||||
if p.Label == "" {
|
||||
release["Label"] = p.Prefix + " " + p.Distribution
|
||||
} else {
|
||||
release["Label"] = p.Label
|
||||
}
|
||||
release["Codename"] = p.Distribution
|
||||
release["Date"] = time.Now().UTC().Format("Mon, 2 Jan 2006 15:04:05 MST")
|
||||
release["Components"] = p.Component
|
||||
|
||||
@@ -274,6 +274,12 @@ func (s *PublishedRepoSuite) TestString(c *C) {
|
||||
repo, _ = NewPublishedRepo("", "squeeze", "main", []string{"i386", "amd64"}, s.snapshot, s.factory)
|
||||
c.Check(repo.String(), Equals,
|
||||
"./squeeze (main) [i386, amd64] publishes [snap]: Snapshot from mirror [yandex]: http://mirror.yandex.ru/debian/ squeeze")
|
||||
repo.Origin = "myorigin"
|
||||
c.Check(repo.String(), Equals,
|
||||
"./squeeze (main, origin: myorigin) [i386, amd64] publishes [snap]: Snapshot from mirror [yandex]: http://mirror.yandex.ru/debian/ squeeze")
|
||||
repo.Label = "mylabel"
|
||||
c.Check(repo.String(), Equals,
|
||||
"./squeeze (main, origin: myorigin, label: mylabel) [i386, amd64] publishes [snap]: Snapshot from mirror [yandex]: http://mirror.yandex.ru/debian/ squeeze")
|
||||
}
|
||||
|
||||
func (s *PublishedRepoSuite) TestKey(c *C) {
|
||||
|
||||
Reference in New Issue
Block a user