Skip to content

Commit

Permalink
chore: add commitlint git hook
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed Aug 29, 2022
1 parent 1f2410b commit 5020f18
Show file tree
Hide file tree
Showing 5 changed files with 1,060 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit "\${1}"
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Notesnook is written & maintained by:
- Abdullah Atta <abdullahatta@streetwriters.co>
- Ammar Ahmed <ammarahmed6506@gmail.com>
17 changes: 17 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const { execSync } = require("child_process");
const { readFileSync } = require("fs");

const authorEmail = execSync(`git show -s --format='%ae' HEAD`)
.toString("utf-8")
.trim();

const authors = readFileSync("AUTHORS", "utf-8");
const isAuthor = authors.includes(`<${authorEmail}>`);

module.exports = {
rules: {
"signed-off-by": [isAuthor ? 0 : 2, "always", `Signed-off-by:`]
}
};
Loading

0 comments on commit 5020f18

Please sign in to comment.