mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-30 04:20:53 +00:00
Check component names (that they do exist) before publish switching. #192
This commit is contained in:
@@ -3,6 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/smira/aptly/deb"
|
||||||
|
"github.com/smira/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -61,6 +62,10 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, component := range components {
|
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 = context.CollectionFactory().SnapshotCollection().ByName(names[i])
|
snapshot, err = context.CollectionFactory().SnapshotCollection().ByName(names[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to switch: %s", err)
|
return fmt.Errorf("unable to switch: %s", err)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ERROR: unable to switch: component c is not in published repository
|
||||||
@@ -388,3 +388,15 @@ class PublishSwitch11Test(BaseTest):
|
|||||||
|
|
||||||
self.check_file_contents("public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz", "file")
|
self.check_file_contents("public/pool/main/p/pyspi/pyspi_0.6.1.orig.tar.gz", "file")
|
||||||
|
|
||||||
|
|
||||||
|
class PublishSwitch12Test(BaseTest):
|
||||||
|
"""
|
||||||
|
publish switch: wrong component names
|
||||||
|
"""
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly snapshot create snap1 empty",
|
||||||
|
"aptly snapshot create snap2 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
|
||||||
|
|||||||
Reference in New Issue
Block a user