Last active
March 21, 2025 16:11
-
-
Save gdarchen/3fcf4fc499457e1ba19ee04be376fa62 to your computer and use it in GitHub Desktop.
Conventional Gitmoji review comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async function generateReplies(document) { | |
/** | |
* Those saved replies are a mix of the "conventional comments" and the | |
* "code review emoji guide". | |
* Refer to the following resources: | |
* - https://conventionalcomments.org | |
* - https://github.com/axolo-co/code-review-emoji-guide | |
*/ | |
const LABEL = { | |
suggestion: "suggestion", | |
typo: "typo", | |
refactor: "refactor", | |
question: "question", | |
note: "note", | |
thought: "thought", | |
praise: "praise", | |
idea: "idea", | |
}; | |
const EMOJI = { | |
[LABEL.suggestion]: "β", | |
[LABEL.typo]: "π€", | |
[LABEL.refactor]: "β»οΈ", | |
[LABEL.question]: "β", | |
[LABEL.note]: "π", | |
[LABEL.thought]: "π", | |
[LABEL.praise]: "π―", | |
[LABEL.idea]: "π‘" | |
}; | |
function post(key, token) { | |
return fetch("replies", { | |
headers: { "content-type": "application/x-www-form-urlencoded" }, | |
method: "POST", | |
mode: "cors", | |
credentials: "include", | |
body: new URLSearchParams({ | |
body: `${EMOJI[key]} **${key}:** `, | |
authenticity_token: token, | |
title: `${EMOJI[key]} ${key}`, | |
}).toString(), | |
}); | |
} | |
const form = document.querySelector(".new_saved_reply"); | |
const token = form?.querySelector("[name=authenticity_token]")?.value; | |
// Replies are order alphabetically, so order doesn't need to preserved. | |
await Promise.all(Object.keys(LABEL).map(key => post(key, token))); | |
console.log("Labels have been added! You can refresh the page."); | |
})(window.document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
π¬ Conventional Gitmoji review comments
This Gist enables to set saved replies for your GitHub account following the Conventional Gitmoji review comments approach.
It is an adaptation of the Conventional Comments and the Code Review Emoji Guide.
π§ How to install
βοΈ How to use saved replies
You can alternatively use CTRL + . shortcut.
Or Cmd + . on Mac π».
You can also use the shortcuts like CTRL + [#reply].