From 40b3a3a9c8955992e63430a896fe3fad1ef39a9b Mon Sep 17 00:00:00 2001 From: Eduard Marbach Date: Wed, 12 Jun 2024 03:08:18 +0200 Subject: [PATCH 1/3] fix: use correct variable for recyclarr checkout revision --- src/recyclarr-importer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/recyclarr-importer.ts b/src/recyclarr-importer.ts index fedbbea..2c71373 100644 --- a/src/recyclarr-importer.ts +++ b/src/recyclarr-importer.ts @@ -25,7 +25,7 @@ export const cloneRecyclarrTemplateRepo = async () => { await simpleGit().clone(applicationConfig.recyclarrConfigUrl ?? DEFAULT_RECYCLARR_GIT_URL, rootPath); } - await gitClient.checkout(applicationConfig.trashRevision ?? "master"); + await gitClient.checkout(applicationConfig.recyclarrRevision ?? "master"); logger.info(`Updating Recyclarr repo`); }; From 18ec80a862531ae66be0cb6be11e09b313c6d9d2 Mon Sep 17 00:00:00 2001 From: Eduard Marbach Date: Wed, 12 Jun 2024 03:11:06 +0200 Subject: [PATCH 2/3] fix: cloning + updating of repos --- src/recyclarr-importer.ts | 13 +++++++++++-- src/trash-guide.ts | 13 +++++++++++-- src/util.ts | 1 - 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/recyclarr-importer.ts b/src/recyclarr-importer.ts index 2c71373..943e9ff 100644 --- a/src/recyclarr-importer.ts +++ b/src/recyclarr-importer.ts @@ -11,6 +11,7 @@ const DEFAULT_RECYCLARR_GIT_URL = "https://github.com/recyclarr/config-templates export const cloneRecyclarrTemplateRepo = async () => { const rootPath = recyclarrRepoPaths.root; + logger.info(`Checking Recyclarr repo (${rootPath})`); if (!fs.existsSync(rootPath)) { fs.mkdirSync(rootPath, { recursive: true }); @@ -25,9 +26,17 @@ export const cloneRecyclarrTemplateRepo = async () => { await simpleGit().clone(applicationConfig.recyclarrConfigUrl ?? DEFAULT_RECYCLARR_GIT_URL, rootPath); } - await gitClient.checkout(applicationConfig.recyclarrRevision ?? "master"); + await gitClient.checkout(applicationConfig.recyclarrRevision ?? "master", ["-f"]); + const result = await gitClient.status(); - logger.info(`Updating Recyclarr repo`); + if (!result.detached) { + const res = await gitClient.pull(); + if (res.files.length > 0) { + logger.info(`Updated Recyclarr repo.`); + } + } + + logger.info(`Recyclarr repo on '${result.current}'`); }; export const getLocalTemplatePath = () => { diff --git a/src/trash-guide.ts b/src/trash-guide.ts index 7878c53..445be75 100644 --- a/src/trash-guide.ts +++ b/src/trash-guide.ts @@ -20,6 +20,7 @@ const DEFAULT_TRASH_GIT_URL = "https://github.com/TRaSH-Guides/Guides"; export const cloneTrashRepo = async () => { const rootPath = trashRepoPaths.root; + logger.info(`Checking TrashGuide repo (${rootPath})`); if (!fs.existsSync(rootPath)) { fs.mkdirSync(rootPath, { recursive: true }); @@ -34,9 +35,17 @@ export const cloneTrashRepo = async () => { await simpleGit().clone(applicationConfig.trashGuideUrl ?? DEFAULT_TRASH_GIT_URL, rootPath); } - await gitClient.checkout(applicationConfig.trashRevision ?? "master"); + await gitClient.checkout(applicationConfig.trashRevision ?? "master", ["-f"]); + const result = await gitClient.status(); - logger.info(`Updating TrashGuide repo`); + if (!result.detached) { + const res = await gitClient.pull(); + if (res.files.length > 0) { + logger.info(`Updated TrashGuide repo.`); + } + } + + logger.info(`TrashGuide repo on '${result.current}'`); }; export const loadSonarrTrashCFs = async (arrType: ArrType): Promise => { diff --git a/src/util.ts b/src/util.ts index 5b71bab..508f065 100644 --- a/src/util.ts +++ b/src/util.ts @@ -23,7 +23,6 @@ const recyclarrRadarrQPs = `${recyclarrRadarrRoot}/includes/quality-profiles`; const trashRepoPath = "docs/json"; const trashRepoRoot = `${repoPath}/trash-guides`; const trashRepoSonarrRoot = `${trashRepoRoot}/${trashRepoPath}/sonarr`; - const trashRepoRadarrRoot = `${trashRepoRoot}/${trashRepoPath}/radarr`; export const trashRepoPaths = { From b045a2a8c39344722a1337a720041f7f4452d8a1 Mon Sep 17 00:00:00 2001 From: Eduard Marbach Date: Wed, 12 Jun 2024 03:16:34 +0200 Subject: [PATCH 3/3] chore: update logging --- src/custom-formats.ts | 5 +++-- src/util.ts | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/custom-formats.ts b/src/custom-formats.ts index 3af2b13..17792cf 100644 --- a/src/custom-formats.ts +++ b/src/custom-formats.ts @@ -51,13 +51,14 @@ export const manageCf = async (cfProcessing: CFProcessing, serverCfs: Map `${key}.${subChange}`)); if (!isEqual) { - changes.push(`Mismatch found for key ${key}`); + changes.push(`Mismatch found for key '${key}'`); } } else { if (value1 !== value2) { - changes.push(`Mismatch found for key ${key}: server value ${value1}, value to set ${value2}`); + changes.push(`Mismatch found for key '${key}': server value '${value1}', value to set '${value2}'`); } } } else {