mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
Support for -no-remove while merging snapshots. #57
This commit is contained in:
@@ -29,10 +29,15 @@ func aptlySnapshotMerge(cmd *commander.Command, args []string) error {
|
||||
}
|
||||
|
||||
latest := context.flags.Lookup("latest").Value.Get().(bool)
|
||||
overrideMatching := !latest
|
||||
noRemove := context.flags.Lookup("no-remove").Value.Get().(bool)
|
||||
|
||||
if noRemove && latest {
|
||||
return fmt.Errorf("-no-remove and -latest can't be specified together")
|
||||
}
|
||||
|
||||
overrideMatching := !latest && !noRemove
|
||||
|
||||
result := sources[0].RefList()
|
||||
|
||||
for i := 1; i < len(sources); i++ {
|
||||
result = result.Merge(sources[i].RefList(), overrideMatching)
|
||||
}
|
||||
@@ -79,6 +84,7 @@ Example:
|
||||
}
|
||||
|
||||
cmd.Flag.Bool("latest", false, "use only the latest version of each package")
|
||||
cmd.Flag.Bool("no-remove", false, "don't remove duplicate arch/name packages")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -136,3 +136,51 @@ class MergeSnapshot8Test(BaseTest):
|
||||
]
|
||||
runCmd = "aptly snapshot diff snap4 snap5"
|
||||
expectedCode = 0
|
||||
|
||||
|
||||
class MergeSnapshot9Test(BaseTest):
|
||||
"""
|
||||
merge snapshots: -no-remove
|
||||
"""
|
||||
fixtureDB = True
|
||||
fixtureCmds = [
|
||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
||||
"aptly snapshot create snap2 from mirror wheezy-non-free",
|
||||
"aptly snapshot create snap3 from mirror wheezy-backports",
|
||||
]
|
||||
runCmd = "aptly snapshot merge -no-remove snap4 snap1 snap2 snap3"
|
||||
expectedCode = 0
|
||||
|
||||
def check(self):
|
||||
def remove_created_at(s):
|
||||
return re.sub(r"Created At: [0-9:A-Za-z -]+\n", "", s)
|
||||
|
||||
self.check_output()
|
||||
self.check_cmd_output("aptly snapshot show -with-packages snap4", "snapshot_show", match_prepare=remove_created_at)
|
||||
|
||||
|
||||
class MergeSnapshot10Test(BaseTest):
|
||||
"""
|
||||
merge snapshots: compare -no-remove and regular
|
||||
"""
|
||||
fixtureDB = True
|
||||
fixtureCmds = [
|
||||
"aptly snapshot create snap1 from mirror wheezy-main",
|
||||
"aptly snapshot create snap2 from mirror wheezy-non-free",
|
||||
"aptly snapshot create snap3 from mirror wheezy-backports",
|
||||
"aptly snapshot merge snap4 snap3 snap2 snap1",
|
||||
"aptly snapshot merge -no-remove snap5 snap3 snap2 snap1",
|
||||
]
|
||||
runCmd = "aptly snapshot diff snap4 snap5"
|
||||
expectedCode = 0
|
||||
|
||||
|
||||
class MergeSnapshot11Test(BaseTest):
|
||||
"""
|
||||
merge snapshots: -no-remove & -latest conflict
|
||||
"""
|
||||
fixtureCmds = [
|
||||
"aptly snapshot create snap1 empty"
|
||||
]
|
||||
runCmd = "aptly snapshot merge -no-remove -latest snap2 snap1"
|
||||
expectedCode = 1
|
||||
|
||||
Reference in New Issue
Block a user