🔥(ci) drop the requests dependency from the gitmoji rule

The rule downloaded the gitmoji list with requests, so lint-git had to install
that package before the linter could run. urllib.request is in the standard
library and answers the same call, leaving one fewer package fetched on the
runner before the job's own command starts.
This commit is contained in:
davd-gzl
2026-08-25 18:48:09 +00:00
committed by aleb_the_flash
parent 0e9660ead3
commit a0dbfa9357
+6 -7
View File
@@ -3,14 +3,14 @@ Gitlint extra rule to validate that the message title is of the form
"<gitmoji>(<scope>) <subject>" "<gitmoji>(<scope>) <subject>"
""" """
from __future__ import unicode_literals import json
import re import re
import urllib.request
import requests
from gitlint.rules import CommitMessageTitle, LineRule, RuleViolation from gitlint.rules import CommitMessageTitle, LineRule, RuleViolation
GITMOJIS_URL = "https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json"
class GitmojiTitle(LineRule): class GitmojiTitle(LineRule):
""" """
@@ -28,9 +28,8 @@ class GitmojiTitle(LineRule):
Download the list possible gitmojis from the project's github repository and check that Download the list possible gitmojis from the project's github repository and check that
title contains one of them. title contains one of them.
""" """
gitmojis = requests.get( with urllib.request.urlopen(GITMOJIS_URL, timeout=10) as response:
"https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json" gitmojis = json.load(response)["gitmojis"]
).json()["gitmojis"]
emojis = [item["emoji"] for item in gitmojis] emojis = [item["emoji"] for item in gitmojis]
pattern = r"^({:s})\(.*\)\s[a-z].*$".format("|".join(emojis)) pattern = r"^({:s})\(.*\)\s[a-z].*$".format("|".join(emojis))
if not re.search(pattern, title): if not re.search(pattern, title):