From 7311a8f02e4a157379c2759fe5bb80d46cadeaaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Thu, 2 Feb 2023 17:46:58 +0100 Subject: [PATCH] Add https directory link to URL file name message --- bot.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bot.ts b/bot.ts index e64125a..5d6ea8f 100644 --- a/bot.ts +++ b/bot.ts @@ -114,7 +114,8 @@ export const bot: ApplicationFunction = (app) => { let identifiedPlaylistsText = ''; const validEntries = playlistLookupResults.filter( - ({ found, filename }) => found && !filename.includes(siQueryStart) + ({ found, filename, url }) => + found && !filename.includes(siQueryStart) && filename !== url ); if (validEntries.length > 0) { @@ -159,16 +160,19 @@ export const bot: ApplicationFunction = (app) => { if (urlFilenameEntries.length > 0) { successText = ''; - const baseUrl = `${payload.pull_request.head.repo.html_url}/new/main/playlists/registry/FOO`; + const forkPageUrl = payload.pull_request.head.repo.html_url; + const httpsDirUrl = `${forkPageUrl}/tree/main/playlists/registry/https:`; + + const baseCreateUrl = `${forkPageUrl}/new/main/playlists/registry/FOO`; const linkList = urlFilenameEntries.map(({ url }) => { const playlistId = getPlaylistIdFromUrl(url); - const createFilePageUrl = `${baseUrl}?filename=${playlistId}&value=REMOVE%20THIS%20TEXT%20FIRST`; + const createFilePageUrl = `${baseCreateUrl}?filename=${playlistId}&value=REMOVE%20THIS%20TEXT%20FIRST`; return `\t- [Create \`${playlistId}\`](${createFilePageUrl})`; }); reviewEvent = 'REQUEST_CHANGES'; - urlEntriesToRenameText = `### ⚠️ Some entries are malformed playlist URLs\n\nHere's how you can correct them:\n\n1. Remove the \`https:\` folder\n\n2. Use the links below to create valid entries:\n${linkList}`; + urlEntriesToRenameText = `### ⚠️ Some entries are malformed playlist URLs\n\nHere's how you can correct them:\n\n1. Go to [the \`https:\` folder](${httpsDirUrl}), click on the three dots on the right-hand side, and choose _Delete directory_\n\n2. Use the links below to create valid entries:\n${linkList}`; } let notFoundText = '';