Reintroduce double title fix

This commit is contained in:
Maciej Pędzich 2024-01-17 22:41:21 +01:00
parent 44c7630ba5
commit 17034ee323

View File

@ -8,9 +8,7 @@ type ReviewEvent = 'REQUEST_CHANGES' | 'COMMENT' | 'APPROVE';
const appFn = (app: Probot) => { const appFn = (app: Probot) => {
app.on( app.on(
['pull_request.opened', 'pull_request.synchronize'], ['pull_request.opened', 'pull_request.synchronize'],
async ({ payload, octokit }) => { async ({ payload, octokit, log }) => {
console.log('Pull Request Handler triggered');
const registryDirectoryPath = 'playlists/registry/'; const registryDirectoryPath = 'playlists/registry/';
const siQueryStart = '?si='; const siQueryStart = '?si=';
@ -93,13 +91,12 @@ const appFn = (app: Probot) => {
if (found) { if (found) {
const html = await spotifyResponse.text(); const html = await spotifyResponse.text();
const { title, description } = await getMetaData({ html }); const { description } = await getMetaData({ html });
const playlistMeta = (description || '') const playlistMeta = (description || '')
.split(' · ') .split(' · ')
.filter((text) => text !== 'Playlist'); .filter((text) => text !== 'Playlist');
console.log(details); details = playlistMeta.join(' · ');
details = [title, ...playlistMeta].join(' · ');
} }
return { return {
@ -209,8 +206,10 @@ const appFn = (app: Probot) => {
const [existingReview] = reviews; const [existingReview] = reviews;
await upsertReview(existingReview?.id, reviewEvent, reviewBody); await upsertReview(existingReview?.id, reviewEvent, reviewBody);
} catch (error) { } catch (e) {
console.error(error); const error = e as Error;
log.error({ stack: error?.stack }, error.message);
await upsertReview( await upsertReview(
undefined, undefined,
'COMMENT', 'COMMENT',