Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to add a new component to a published repo #1341

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions api/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/aptly-dev/aptly/deb"
"github.com/aptly-dev/aptly/pgp"
"github.com/aptly-dev/aptly/task"
"github.com/aptly-dev/aptly/utils"
"github.com/gin-gonic/gin"
)

Expand Down Expand Up @@ -299,13 +298,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
published.UpdateLocalRepo(component)
}
} else if published.SourceKind == "snapshot" {
publishedComponents := published.Components()
for _, snapshotInfo := range b.Snapshots {
if !utils.StrSliceHasItem(publishedComponents, snapshotInfo.Component) {
AbortWithJSONError(c, 404, fmt.Errorf("component %s is not in published repository", snapshotInfo.Component))
return
}

snapshotCollection := collectionFactory.SnapshotCollection()
snapshot, err2 := snapshotCollection.ByName(snapshotInfo.Name)
if err2 != nil {
Expand Down
5 changes: 0 additions & 5 deletions cmd/publish_switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strings"

"github.com/aptly-dev/aptly/deb"
"github.com/aptly-dev/aptly/utils"
"github.com/smira/commander"
"github.com/smira/flag"
)
Expand Down Expand Up @@ -65,10 +64,6 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
}

for i, component := range components {
if !utils.StrSliceHasItem(publishedComponents, component) {
return fmt.Errorf("unable to switch: component %s is not in published repository", component)
}

snapshot, err = collectionFactory.SnapshotCollection().ByName(names[i])
if err != nil {
return fmt.Errorf("unable to switch: %s", err)
Expand Down
5 changes: 4 additions & 1 deletion deb/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,10 @@ func (p *PublishedRepo) UpdateSnapshot(component string, snapshot *Snapshot) {
panic("not snapshot publish")
}

item := p.sourceItems[component]
item, exists := p.sourceItems[component]
if !exists {
item = repoSourceItem{}
}
item.snapshot = snapshot
p.sourceItems[component] = item

Expand Down
9 changes: 8 additions & 1 deletion system/t06_publish/PublishSwitch12Test_gold
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
ERROR: unable to switch: component c is not in published repository
Loading packages...
Generating metadata files and linking package files...
Finalizing metadata files...
Signing file 'Release' with gpg, please enter your passphrase when prompted:
Clearsigning file 'Release' with gpg, please enter your passphrase when prompted:
Cleaning up prefix "." components a, c...

Publish for snapshot ./maverick [i386] publishes {a: [snap2]: Created as empty}, {b: [snap2]: Created as empty}, {c: [snap3]: Created as empty} has been successfully switched to new snapshot.
13 changes: 10 additions & 3 deletions system/t06_publish/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,22 @@ def check(self):

class PublishSwitch12Test(BaseTest):
"""
publish switch: wrong component names
publish switch: add new component to publish
"""
fixtureCmds = [
"aptly snapshot create snap1 empty",
"aptly snapshot create snap2 empty",
"aptly snapshot create snap3 empty",
"aptly publish snapshot -architectures=i386 -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -component=a,b snap1 snap2",
]
runCmd = "aptly publish switch -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=a,c maverick snap2 snap1"
expectedCode = 1
runCmd = "aptly publish switch -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -component=a,c maverick snap2 snap3"
gold_processor = BaseTest.expand_environ

def check(self):
super(PublishSwitch12Test, self).check()

self.check_exists('public/dists/maverick/a/binary-i386/Packages')
self.check_exists('public/dists/maverick/c/binary-i386/Packages')


class PublishSwitch13Test(BaseTest):
Expand Down
Loading