list package moves

This commit is contained in:
2025-11-06 00:35:05 -05:00
parent 0befd7b090
commit 1fa468a3b7
2 changed files with 27 additions and 25 deletions

View File

@@ -21,7 +21,7 @@ interface Actions {
interface Result { interface Result {
build: boolean; build: boolean;
move: boolean; move: PackageInfo[];
delete: PackageInfo[]; delete: PackageInfo[];
actions: Actions; actions: Actions;
} }
@@ -57,7 +57,7 @@ async function parse(previous: PathLike, current: PathLike): Promise<Result> {
const actions = curr?.actions; const actions = curr?.actions;
const result: Result = { const result: Result = {
build: false, build: false,
move: false, move: [],
delete: [], delete: [],
actions, actions,
}; };
@@ -66,10 +66,9 @@ async function parse(previous: PathLike, current: PathLike): Promise<Result> {
const repo: RepoContents = prev.repos[actions.removeRepo]; const repo: RepoContents = prev.repos[actions.removeRepo];
result.delete.push(...parseRepoContents(repo, actions.removeRepo)); result.delete.push(...parseRepoContents(repo, actions.removeRepo));
} }
else if (prev && (result.move = isMove(actions))) { else if (prev && isMove(actions)) {
const moving = parseRepoContents(curr.repos[actions.addRepo], actions.removeRepo); const moving = result.move = parseRepoContents(curr.repos[actions.addRepo], actions.removeRepo);
result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), moving)); result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), moving));
result.delete.push(...moving);
} }
else if ((result.build = isAdd(actions)) && prev) { else if ((result.build = isAdd(actions)) && prev) {
result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), parseRepoContents(curr.repos[actions.addRepo], actions.addRepo))); result.delete.push(...getDropped(parseRepoContents(prev.repos[actions.addRepo], actions.addRepo), parseRepoContents(curr.repos[actions.addRepo], actions.addRepo)));
@@ -115,5 +114,5 @@ async function tryRead(file: PathLike): Promise<PkgBase | null> {
} }
} }
export { parse }; export { parse, tryRead };
export type { Actions, Result, RepoContents, PkgBase, PackageInfo }; export type { Actions, Result, RepoContents, PkgBase, PackageInfo };

View File

@@ -6,7 +6,7 @@ describe('pkgbase parser', () => {
it('can detect an add operation', async () => { it('can detect an add operation', async () => {
const expected: Result = { const expected: Result = {
build: true, build: true,
move: false, move: [],
delete: [], delete: [],
actions: { actions: {
addRepo: 'system-goblins', addRepo: 'system-goblins',
@@ -25,7 +25,7 @@ describe('pkgbase parser', () => {
it('can detect an add operation on a new repo', async () => { it('can detect an add operation on a new repo', async () => {
const expected: Result = { const expected: Result = {
build: true, build: true,
move: false, move: [],
delete: [], delete: [],
actions: { actions: {
addRepo: 'world', addRepo: 'world',
@@ -44,7 +44,7 @@ describe('pkgbase parser', () => {
it('can remove dangling packages in an add operation', async () => { it('can remove dangling packages in an add operation', async () => {
const expected: Result = { const expected: Result = {
build: true, build: true,
move: false, move: [],
delete: [ delete: [
{ {
architecture: "x86_64", architecture: "x86_64",
@@ -70,13 +70,15 @@ describe('pkgbase parser', () => {
it('can detect a move operation', async () => { it('can detect a move operation', async () => {
const expected: Result = { const expected: Result = {
build: false, build: false,
move: true, move: [
delete: [{ {
architecture: "x86_64", architecture: "x86_64",
package: "opencascade", package: "opencascade",
repository: "world-gremlins", repository: "world-gremlins",
version: "1:7.9.2-1", version: "1:7.9.2-1",
}], }
],
delete: [],
actions: { actions: {
addRepo: 'world', addRepo: 'world',
removeRepo: 'world-gremlins', removeRepo: 'world-gremlins',
@@ -94,14 +96,7 @@ describe('pkgbase parser', () => {
it('can remove dangling packages in a move operation', async () => { it('can remove dangling packages in a move operation', async () => {
const expected: Result = { const expected: Result = {
build: false, build: false,
move: true, move: [
delete: [
{
architecture: "x86_64",
package: "pidgin",
repository: "world",
version: "2.14.14-3",
},
{ {
architecture: "x86_64", architecture: "x86_64",
package: "libpurple", package: "libpurple",
@@ -115,6 +110,14 @@ describe('pkgbase parser', () => {
version: "2.14.14-4", version: "2.14.14-4",
} }
], ],
delete: [
{
architecture: "x86_64",
package: "pidgin",
repository: "world",
version: "2.14.14-3",
}
],
actions: { actions: {
addRepo: 'world', addRepo: 'world',
removeRepo: 'world-gremlins', removeRepo: 'world-gremlins',
@@ -132,7 +135,7 @@ describe('pkgbase parser', () => {
it('can detect a delete operation', async () => { it('can detect a delete operation', async () => {
const expected: Result = { const expected: Result = {
build: false, build: false,
move: false, move: [],
delete: [ delete: [
{ {
architecture: "any", architecture: "any",