Skip to content

Commit

Permalink
Merge pull request #3 from jonathanlinat/chore/upgrade_to_node_20
Browse files Browse the repository at this point in the history
Build the thing... and upgrade to version `0.8.2`
  • Loading branch information
kduske authored Feb 5, 2024
2 parents d21e8b4 + dd08e23 commit c51c0c9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clean commit step
uses: TrenchBroom/clean-commit-action@v0.8.1
uses: TrenchBroom/clean-commit-action@v0.8.2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
35 changes: 20 additions & 15 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30800,14 +30800,15 @@ var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
const { getInput, setFailed, debug, error } = __nccwpck_require__(4856);
const { GitHub, context } = __nccwpck_require__(3791);
const { getOctokit, context } = __nccwpck_require__(3791);

const { BAD_KEYWORDS } = __nccwpck_require__(4537);

function filterCommit(commit) {
commit = commit.toLowerCase();
const result = [];
for(keyword of BAD_KEYWORDS) {

for (const keyword of BAD_KEYWORDS) {
if (commit.indexOf(keyword) != -1) {
result.push(keyword);
}
Expand All @@ -30817,35 +30818,39 @@ function filterCommit(commit) {
}

async function verifyCommits(repoToken) {
const client = new GitHub(repoToken);
const { data: commits } = await client.pulls.listCommits({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.issue.number})
debug(`There are ${commits.length} commits in this pr`);
const client = getOctokit(repoToken);
const { data: commits } = await client.rest.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});

debug(`There are ${commits.length} commits in this pull request`);

let badCommits = 0;
let isCommitBad = false;

for (const commit of commits) {
const { message } = commit.commit;

const badKeywords = filterCommit(message);
if (badKeywords.length) {
error(`commit message \"${message}\" contains ${badKeywords.join()}`);
isCommitBad = true;
}

if(isCommitBad) {
if (badKeywords.length) {
error(`commit message "${message}" contains ${badKeywords.join()}`);
badCommits++;
isCommitBad = false;
}
}

if (badCommits) {
throw Error(`${badCommits} bad commit(s) encountered. Please fix the above errors`);
throw new Error(`${badCommits} bad commit(s) encountered. Please fix the above errors`);
}
}

async function main() {
try {
const repoToken = getInput('repo-token', { required: true });
await verifyCommits(repoToken);

debug('Received repo token');

await verifyCommits(repoToken);
} catch (e) {
setFailed(`Action failed with error: ${e.message}`);
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clean-commit-action",
"version": "0.8.0",
"version": "0.8.2",
"main": "index.js",
"repository": "git@github.com:TrenchBroom/clean-commit-action.git",
"author": "Aakansha Doshi <aakansha1216@gmail.com>",
Expand Down

0 comments on commit c51c0c9

Please sign in to comment.