GRM-20: refactor(scripts): centralize constants, API clients, and HTTP status codes
- Add shared config.py with API URLs, regexes, timeouts, pagination - Add GiteaClient and VikunjaClient in api_clients.py with pooled sessions - Add APIError exception for unified HTTP error handling - Refactor all scripts to use shared modules and http.HTTPStatus - Rewrite unit tests to mock clients and use HTTPStatus constants - Add tests for api_clients and config modules - Achieve 100% test coverage
This commit is contained in:
@@ -12,12 +12,10 @@ import subprocess
|
||||
|
||||
import click
|
||||
|
||||
from gitea_runner_manager.config import CONVENTIONAL_RE
|
||||
from gitea_runner_manager.i18n import _
|
||||
|
||||
CONVENTIONAL_RE = re.compile(
|
||||
r"^(feat|fix|chore|docs|style|refactor|perf|test|ci|build|revert|BREAKING CHANGE)(\(.+\))?: .+"
|
||||
)
|
||||
TASK_ID_RE = re.compile(r"^GRM-\d+:")
|
||||
MASTER_TASK_ID_RE = re.compile(r"^GRM-\d+:")
|
||||
|
||||
|
||||
def first_line(text: str) -> str:
|
||||
@@ -47,7 +45,7 @@ def main(commit_msg_file: str) -> None:
|
||||
subject = first_line(msg)
|
||||
|
||||
if branch == "master":
|
||||
if not TASK_ID_RE.match(subject):
|
||||
if not MASTER_TASK_ID_RE.match(subject):
|
||||
raise click.ClickException(
|
||||
_(
|
||||
"Oops! Master branch commits must start with a task ID.\n"
|
||||
@@ -56,7 +54,7 @@ def main(commit_msg_file: str) -> None:
|
||||
subject=subject,
|
||||
)
|
||||
)
|
||||
remainder = TASK_ID_RE.sub("", subject).strip()
|
||||
remainder = MASTER_TASK_ID_RE.sub("", subject).strip()
|
||||
if not CONVENTIONAL_RE.match(remainder):
|
||||
raise click.ClickException(
|
||||
_(
|
||||
@@ -68,7 +66,7 @@ def main(commit_msg_file: str) -> None:
|
||||
)
|
||||
return
|
||||
|
||||
if TASK_ID_RE.match(subject):
|
||||
if MASTER_TASK_ID_RE.match(subject):
|
||||
raise click.ClickException(
|
||||
_(
|
||||
"Oops! Do not include task ID (GRM-N) in feature branch commits.\n"
|
||||
|
||||
Reference in New Issue
Block a user