Commit caeeb2c

ccamel <camel.christophe@gmail.com>
2023-11-06 19:21:15
Add only-emoji-commit badge
1 parent c5f3627
Changed files (4)
src/all-badges/emoji-only-commit/emoji-only-commit.png
Binary file
src/all-badges/emoji-only-commit/emoji-only-commit.ts
@@ -0,0 +1,20 @@
+import { Present, BadgePresenter } from '../../badges.js'
+
+export default new (class implements BadgePresenter {
+  url = new URL(import.meta.url)
+  badges = ['emoji-only-commit'] as const
+  present: Present = (data, grant) => {
+    const commits = data.repos.flatMap(repo =>
+      repo.commits.filter(commit => 
+        /^(\p{Emoji}|\s)+$/u.test(commit.message + commit.messageBody)
+      )
+    );
+
+    if (commits.length > 0) {
+      grant(
+        'emoji-only-commit',
+        'I used only emojis in my commit message.',
+      ).evidenceCommitsWithMessage(...commits)
+    }
+  }
+})()
src/all-badges/index.ts
@@ -21,4 +21,5 @@ export const allBadges = [
   await import('./the-ultimate-question/the-ultimate-question.js'),
   await import('./favorite-word/favorite-word.js'),
   await import('./polite-coder/polite-coder.js'),
+  await import('./emoji-only-commit/emoji-only-commit.js'),
 ] as const
BADGE_IDEAS.md
@@ -8,7 +8,6 @@ Feel free to grab any of these ideas and implement them:
 - **caffeine-fueled** - For a burst of commits at odd hours, implying lots of coffee.
 - **ninja-commit** - Silent commits with minimal descriptions.
 - **commit-haiku** - Commit descriptions that are in the format of a haiku.
-- **emoji-only** - For commit messages that use only emojis.
 - **oops-fix** - For commits that quickly follow a previous commit to fix something minor.
 - **one-liner** - For commits that change only one line.
 - **marathoner** - For long coding sessions with many commits.