Skip to content

Commit

Permalink
fix: merge commits being really long and annoying
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Mar 30, 2024
1 parent 072233b commit c902bbc
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/webserver/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
ButtonStyle,
Client,
EmbedBuilder,
FetchMessageOptions,

Check failure on line 9 in src/webserver/github.ts

View workflow job for this annotation

GitHub Actions / lint

'FetchMessageOptions' is defined but never used
MessageResolvable,

Check failure on line 10 in src/webserver/github.ts

View workflow job for this annotation

GitHub Actions / lint

'MessageResolvable' is defined but never used
} from 'discord.js';
import { Commit } from '../types/github';

Expand Down Expand Up @@ -181,10 +183,10 @@ const actionCompleted = async (client: Client, req: Request) => {
forgeButton
);

oldMessage.edit({ embeds: [embed], components: [actionRow] });
await oldMessage.edit({ embeds: [embed], components: [actionRow] });
githubMap.delete(workflow_run.id);
} else {
oldMessage.edit({ embeds: [embed] });
await oldMessage.edit({ embeds: [embed] });
githubMap.delete(workflow_run.id);
}
};
Expand All @@ -201,17 +203,17 @@ const generateMavenUrl = (
};

const generateCommitsString = (head_sha: string) => {
if (!commitMap.get(head_sha)) {
return 'No commits found';
}
if (!commitMap.get(head_sha)) return 'No commits found';

const commitsArray = commitMap.get(head_sha);
if (!commitsArray) return;
const commitString = commitsArray.commits
.map((commit) => {
const committer = commit.committer;
const userProfile = `https://github.com/${committer.username}`;
const messageWithoutHashtag = commit.message.replace(/#/g, ''); // Remove all '#' symbols
return `[➤](${commit.url}) ${messageWithoutHashtag} - [${committer.username}](${userProfile})`;
const commitTitle = commit.message.split("\n")[0]
const messageWithEscapedHashtag = commitTitle.replace(/#/g, '\#'); // Remove all '#' symbols

Check failure on line 215 in src/webserver/github.ts

View workflow job for this annotation

GitHub Actions / lint

Unnecessary escape character: \#
return `[➤](${commit.url}) ${messageWithEscapedHashtag} - [${committer.username}](${userProfile})`;
})
.join('\n');

Expand All @@ -232,11 +234,7 @@ const getTimeTaken = (time: number) => {
const secondsString =
seconds > 0 ? `${seconds} second${seconds !== 1 ? 's' : ''}` : '';

const timeTaken = `${minutesString}${
minutesString && secondsString ? ' and ' : ''
}${secondsString}`;

return timeTaken;
return `${minutesString}${minutesString && secondsString ? ' and ' : ''}${secondsString}`;
};

const getVersion = async (apiurl: URL, run_number: string) => {
Expand Down Expand Up @@ -299,9 +297,5 @@ const verify_signature = (req: Request) => {
};

const isBuildRun = (req: Request) => {
if (req.body.workflow_run.path == '.github/workflows/build.yml') {
return true;
} else {
return false;
}
return req.body.workflow_run.path == '.github/workflows/build.yml';
};

0 comments on commit c902bbc

Please sign in to comment.