From f9682082625691bfb7c420c702e8d9f51fd6bc3a Mon Sep 17 00:00:00 2001 From: Lionel Date: Tue, 11 Aug 2020 13:22:19 +0200 Subject: [PATCH] fix(alerts): use an accurate regexp for fiche-sp filter (#73) --- targets/alert-cli/src/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/targets/alert-cli/src/index.js b/targets/alert-cli/src/index.js index ba87a8182..9d8a932a0 100644 --- a/targets/alert-cli/src/index.js +++ b/targets/alert-cli/src/index.js @@ -66,10 +66,13 @@ function getFileFilter(repository) { // only a ccn matching our list return (path) => ccns.some((ccn) => new RegExp(ccn.id).test(path)); case "socialgouv/fiches-vdd": - return (path) => - ["index.json", ...listFichesVddId].some((id) => - new RegExp(id).test(path) + return (path) => { + const matched = ["index.json", ...listFichesVddId].some((id) => + new RegExp(`${id}.json$`).test(path) ); + console.error(path, matched); + return matched; + }; default: return () => false; } @@ -386,7 +389,7 @@ async function getDiffFromTags(tags, repositoryId) { const diffProcessor = getDiffProcessor(repositoryId); for (const tag of newTags) { - console.error(tag.ref); + console.error(repositoryId, tag.ref); const previousCommit = previousTag.commit; const { commit } = tag; const [prevTree, currTree] = await Promise.all([ @@ -418,7 +421,9 @@ async function main() { const sources = await getSources(); const results = []; - for (const source of sources) { + for (const source of sources.filter((source) => + /fiches-vdd/.test(source.repository) + )) { const repo = await openRepo(source); const tags = await getNewerTagsFromRepo(repo, source.tag); const [lastTag] = tags.slice(-1);