Skip to content

Instantly share code, notes, and snippets.

@gdarchen
Last active March 21, 2025 16:11
Show Gist options
  • Save gdarchen/3fcf4fc499457e1ba19ee04be376fa62 to your computer and use it in GitHub Desktop.
Save gdarchen/3fcf4fc499457e1ba19ee04be376fa62 to your computer and use it in GitHub Desktop.
Conventional Gitmoji review comments
(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);
@gdarchen
Copy link
Author

πŸ’¬ 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

  1. Go to github.com/settings/replies
  2. Open your browser console
  3. Paste and run this JavaScript code in the console
  4. Refresh the page to see the saved replies

✏️ How to use saved replies

  1. Go to a Pull Request or Issue
  2. Select a line to open the comment box
  3. Open the saved replies tool.
    You can alternatively use CTRL + . shortcut.
    Or Cmd + . on Mac πŸ’».
  4. Select one of the saved replies.
    You can also use the shortcuts like CTRL + [#reply].
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment