Skip to content

Commit

Permalink
Merge pull request #9 from vict0rsch/emoji-sets
Browse files Browse the repository at this point in the history
  • Loading branch information
vict0rsch authored Nov 14, 2023
2 parents 6056e99 + a78152b commit 25a7cce
Show file tree
Hide file tree
Showing 5 changed files with 289 additions and 16 deletions.
226 changes: 223 additions & 3 deletions gitmopy/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
"name": "Remember commit history for auto-complete and emoji sorting",
"default": True,
},
{
"value": "emoji_set",
"name": "Emoji set to use for commits",
"default": "gitmoji",
"options": ["gitmoji", "ai-devmojis"],
},
]
"""
Choices for the setup prompt.
Expand All @@ -87,6 +93,13 @@
Empty by default or if user diabled it.
"""

EMOJIS = []
"""
The loaded emojis. Will be set to :py:const:`gitmopy.GITMOJIS` or
:py:const:`gitmopy.AI_DEVMOJIS` depending on the user's choice, and updated with the
user's custom emoji set.
"""

# https://github.com/carloscuesta/gitmoji/blob/master/packages/gitmojis/src/gitmojis.json
GITMOJIS = [
{
Expand Down Expand Up @@ -338,7 +351,7 @@
"description": "Work on code related to authorization, roles and permissions.",
},
{
"emoji": "🩹",
"emoji": "🖍️🩹",
"description": "Simple fix for a non-critical issue.",
},
{
Expand All @@ -358,7 +371,7 @@
"description": "Add or update business logic.",
},
{
"emoji": "🩺",
"emoji": "🩺⛑️",
"description": "Add or update healthcheck.",
},
{
Expand All @@ -378,11 +391,218 @@
"description": "Add or update code related to multithreading or concurrency.",
},
{
"emoji": "🦺",
"emoji": "🦺",
"description": "Add or update code related to validation.",
},
]
"""
List of emojis and their code and description according
to https://gitmoji.dev/
"""

AI_DEVMOJIS = [
{
"emoji": "🧠",
"description": "Add or update a model.",
},
{
"emoji": "🧬",
"description": "Add or update a dataset.",
},
{
"emoji": "🧮",
"description": "Add or update a metric.",
},
{
"emoji": "🧩",
"description": "Add or update a loss function.",
},
{
"emoji": "🧱",
"description": "Add or update a layer.",
},
{
"emoji": "🔢",
"description": "Add or update a numerical algorithm.",
},
{
"emoji": "📉",
"description": "Add or update a statistical algorithm.",
},
{
"emoji": "🔊",
"description": "Update logging.",
},
{
"emoji": "🎲",
"description": "Add or update code related to randomness.",
},
{
"emoji": "🧪",
"description": "Update experiments pipeline.",
},
{
"emoji": "📊",
"description": "Add or update data visualization.",
},
{
"emoji": "📋",
"description": "Add or update data processing pipeline.",
},
{
"emoji": "📄",
"description": "Add or update documentation.",
},
{
"emoji": "🧾",
"description": "Add or update paper.",
},
{
"emoji": "🔨",
"description": "Add or update development scripts.",
},
{
"emoji": "🔧",
"description": "Add or update utility functions.",
},
{
"description": "Improve function logic.",
"emoji": "🏄‍♂️",
},
{
"emoji": "🐛",
"description": "Fix a bug.",
},
{
"emoji": "🚑",
"description": "Critical hotfix.",
},
{
"emoji": "🚀",
"description": "Deploy stuff.",
},
{
"emoji": "📦",
"description": "Add or update compiled files or packages.",
},
{
"emoji": "🔧",
"description": "Add or update configuration files.",
},
{
"emoji": "👥",
"description": "Add or update contributor(s).",
},
{
"emoji": "🔍",
"description": "Add or update data exploration.",
},
{
"emoji": "🧵",
"description": "Add or update code related to multithreading or concurrency.",
},
{
"emoji": "🧑‍💻",
"description": "Improve developer experience.",
},
{
"emoji": "🩺⛑️",
"description": "Add or update healthcheck.",
},
{
"emoji": "🧪",
"description": "Work on a test.",
},
{
"emoji": "🖍️🩹",
"description": "Simple fix for a non-critical issue.",
},
{
"emoji": "🚩",
"description": "Add, update, or remove flags / command-line arguments.",
},
{
"emoji": "🥅",
"description": "Catch errors.",
},
{
"emoji": "🏷️",
"description": "Add or update types.",
},
{
"emoji": "🙈",
"description": "Add or update a .gitignore file.",
},
{
"emoji": "🚸",
"description": "Improve user experience / usability.",
},
{
"emoji": "🏗️",
"description": "Make architectural changes.",
},
{
"emoji": "💡",
"description": "Add or update comments in source code.",
},
{
"emoji": "🍻",
"description": "Write code drunkenly.",
},
{
"emoji": "👽️",
"description": "Update code due to external API changes.",
},
{
"emoji": "🚚",
"description": "Move or rename resources (e.g.: files, paths, routes).",
},
{
"emoji": "📄",
"description": "Add or update license.",
},
{
"emoji": "💥",
"description": "Introduce breaking changes.",
},
{
"emoji": "🍱",
"description": "Add or update assets, constants etc.",
},
{
"emoji": "✏️",
"description": "Fix typos.",
},
{
"emoji": "💩",
"description": "Write bad code that needs to be improved.",
},
{
"emoji": "⏪️",
"description": "Revert changes.",
},
{
"emoji": "♻️",
"description": "Refactor code.",
},
{
"emoji": "🎨",
"description": "Improve structure / format of the code.",
},
{
"emoji": "⚡️",
"description": "Improve performance.",
},
{
"emoji": "🔥",
"description": "Remove code or files.",
},
{
"emoji": "✨",
"description": "Introduce new features.",
},
]
"""
List of emojis and their code and description according to a new standard
tailored for AI/ML projects and development.
"""
19 changes: 11 additions & 8 deletions gitmopy/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def save_to_history(commit_dict: Dict[str, str]) -> None:
gpyc.HISTORY_PATH.write_text(json.dumps(gpyc.HISTORY))


def sort_emojis() -> List[Dict[str, str]]:
def sort_emojis_by_timestamp() -> List[Dict[str, str]]:
"""
Sort emojis by most recent usage in history.
Expand All @@ -84,7 +84,7 @@ def sort_emojis() -> List[Dict[str, str]]:
dater = {}
for commit in gpyc.HISTORY:
dater[commit["emoji"]] = commit["timestamp"]
gpyc.GITMOJIS.sort(key=lambda x: dater.get(x["emoji"], 0), reverse=True)
gpyc.EMOJIS.sort(key=lambda x: dater.get(x["emoji"], 0), reverse=True)


def gitmojis_setup() -> None:
Expand All @@ -97,19 +97,22 @@ def gitmojis_setup() -> None:
* sorts the emojis by most recent usage in history (if enabled)
"""
config = load_config()
emo_dict = {e["emoji"]: e for e in gpyc.GITMOJIS}
if config["emoji_set"].lower() == "gitmoji":
emo_dict = {e["emoji"]: e for e in gpyc.GITMOJIS}
else:
emo_dict = {e["emoji"]: e for e in gpyc.AI_DEVMOJIS}
user_emojis = load_user_gitmojis()
for u in user_emojis:
emo_dict[u["emoji"]] = u

gpyc.GITMOJIS = list(emo_dict.values())
gpyc.EMOJIS = list(emo_dict.values())

for k, e in enumerate(gpyc.GITMOJIS):
gpyc.GITMOJIS[k]["name"] = e["emoji"] + " " + e["description"]
gpyc.GITMOJIS[k]["value"] = e["emoji"]
for k, e in enumerate(gpyc.EMOJIS):
gpyc.EMOJIS[k]["name"] = e["emoji"] + " " + e["description"]
gpyc.EMOJIS[k]["value"] = e["emoji"]

if not config["enable_history"]:
return

load_history()
sort_emojis()
sort_emojis_by_timestamp()
21 changes: 20 additions & 1 deletion gitmopy/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def commit_prompt(config: Dict[str, bool]) -> Dict[str, str]:
emoji = (
inquirer.fuzzy(
message="Select gitmoji:",
choices=gpyc.GITMOJIS,
choices=gpyc.EMOJIS,
multiselect=False,
max_height="70%",
mandatory=True,
Expand Down Expand Up @@ -177,6 +177,7 @@ def config_prompt() -> None:
choices = [
Choice(c["value"], c["name"], config.get(c["value"], c["default"]))
for c in gpyc.DEFAULT_CHOICES
if isinstance(c["default"], bool)
]

selected = inquirer.checkbox(
Expand All @@ -192,8 +193,26 @@ def config_prompt() -> None:

selected = set(selected)

lists = [
c
for c in gpyc.DEFAULT_CHOICES
if isinstance(c["default"], str) and "options" in c
]
options = {}

for ldict in lists:
option = inquirer.select(
message=ldict["name"],
choices=ldict["options"],
default=ldict["default"],
qmark="❓",
amark="✓",
).execute()
options[ldict["value"]] = option

for c in choices:
config[c.value] = c.value in selected
config.update(options)

save_config(config)

Expand Down
Loading

0 comments on commit 25a7cce

Please sign in to comment.