Skip to content

Commit ece16f5

Browse files
authored
Merge pull request #30 from two-inc/support-any-prefix
chore: Support any 3 letter prefix
2 parents 85445b3 + d90452b commit ece16f5

File tree

5 files changed

+936
-57
lines changed

5 files changed

+936
-57
lines changed

.github/workflows/deploy.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,32 @@ name: Run test
33
on:
44
workflow_dispatch:
55
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
611

712
jobs:
813
pytest:
914
runs-on: ubuntu-latest
1015
permissions:
1116
contents: read
1217
id-token: write
18+
pull-requests: write
1319
steps:
1420
- uses: actions/checkout@v4
21+
- name: Setup uv
22+
uses: astral-sh/setup-uv@v6
23+
with:
24+
python-version: '3.10'
25+
- name: Install dependencies
26+
run: uv sync --all-groups
1527
- name: Run pytest
16-
shell: bash
17-
run: |
18-
python3 -m venv venv
19-
source venv/bin/activate
20-
pip install '.[dev]'
21-
coverage run -m pytest
22-
coverage report -m --fail-under=95
28+
run: uv run pytest --cov=git_hooks --cov-report=xml:coverage.xml --durations=10
29+
- name: Get Cover
30+
uses: orgoro/coverage@v3.2
31+
if: ${{ github.event_name == 'pull_request' }}
32+
with:
33+
coverageFile: coverage.xml
34+
token: ${{ secrets.GITHUB_TOKEN }}

git_hooks/common.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,18 @@
3232

3333
commit_type_regex: str = f"(?:{'|'.join(commit_types.keys())})"
3434
teams: list[str] = [
35-
"ABN",
36-
"ATL",
37-
"CET",
38-
"DEL",
39-
"FE",
40-
"INF",
41-
"KNA",
42-
"L2",
43-
"NOR",
4435
"T",
36+
"L2",
4537
]
4638
linear_ref: str = (
4739
"(?:"
4840
f"{'|'.join(t for t in teams)}"
4941
"|"
42+
r"[A-Z]{3}"
43+
"|"
5044
f"{'|'.join(t.lower() for t in teams)}"
45+
"|"
46+
r"[a-z]{3}"
5147
")-[0-9]{1,5}"
5248
)
5349
valid_commit_regex: str = (

git_hooks/test_common.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ def test_commit_type_regex(commit_type: str):
2222
"issue",
2323
[
2424
"T-1234",
25-
"KNA-1234",
26-
"CET-1234",
27-
"NOR-1234",
2825
"L2-1234",
29-
"DEL-14",
26+
"ABC-1234",
27+
"xyz-1234",
28+
"T-1",
29+
"L2-99999",
3030
],
3131
)
3232
def test_linear_ref(issue: str):
@@ -37,12 +37,11 @@ def test_linear_ref(issue: str):
3737
"commit",
3838
[
3939
"T-1234/feat: ",
40-
"T-1234/fix: ",
41-
"KNA-1234/hotfix: ",
42-
"CET-1234/docs: ",
43-
"NOR-1234/style: ",
44-
"L2-1234/test: ",
45-
"DEL-14/refactor: "
40+
"L2-1234/fix: ",
41+
"ABC-1234/hotfix: ",
42+
"xyz-1234/docs: ",
43+
"T-1/style: ",
44+
"L2-99999/test: ",
4645
],
4746
)
4847
def test_valid_commit_regex(commit: str):
@@ -53,11 +52,11 @@ def test_valid_commit_regex(commit: str):
5352
"branch",
5453
[
5554
"hotfix/T-1234-fix-something",
56-
"hotfix/brtknr/KNA-1234-add-something",
57-
"feat/CET-1234-fix-something",
58-
"bharat/L2-1234-add-something",
59-
"brtkwr/cet-281-fix-company-search-gb-bucket-permission",
60-
"shelmig/del-13-update-credentials",
55+
"feat/L2-1234-add-something",
56+
"fix/ABC-1234-fix-something",
57+
"bharat/xyz-1234-add-something",
58+
"brtkwr/abc-281-fix-company-search-gb-bucket-permission",
59+
"shelmig/xyz-13-update-credentials",
6160
],
6261
)
6362
def test_branch_regex(branch: str):
@@ -87,12 +86,11 @@ def test_commit_msg_title_regex(commit_msg: str):
8786
"commit_msg",
8887
[
8988
"T-1234/feat: add something",
90-
"KNA-1234/fix: fix something",
91-
"CET-1234/hotfix: fix something",
92-
"NOR-1234/docs: add something",
93-
"L2-1234/style add something",
94-
"T-1234/test: add something",
95-
"DEL-1234/test: add something",
89+
"L2-1234/fix: fix something",
90+
"ABC-1234/hotfix: fix something",
91+
"xyz-1234/docs: add something",
92+
"T-1/style add something",
93+
"L2-99999/test: add something",
9694
],
9795
)
9896
def test_commit_msg_issue_regex(commit_msg: str):
@@ -105,11 +103,11 @@ def test_commit_msg_issue_regex(commit_msg: str):
105103
"issue",
106104
[
107105
"T-1234",
108-
"KNA-1234",
109-
"CET-1234",
110-
"NOR-1234",
111106
"L2-1234",
112-
"DEL-1234",
107+
"ABC-1234",
108+
"xyz-1234",
109+
"T-1",
110+
"L2-99999",
113111
],
114112
)
115113
def test_issue_regex(issue: str):

pyproject.toml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
[project]
22
name = "git-hooks"
33
version = "24.11.29"
4-
dependencies = [
5-
"gql[requests]==3.4.1",
6-
]
4+
dependencies = ["gql[requests]==3.4.1"]
5+
requires-python = ">=3.10"
6+
7+
[tool.uv]
8+
package = true
9+
710

8-
[project.optional-dependencies]
9-
dev = [
11+
[dependency-groups]
12+
test = [
1013
"bumpver==2022.1119",
1114
"pytest==6.2.5",
12-
"coverage==7.5.3",
15+
"pytest-cov>=6.1.1",
1316
"pre-commit==3.7.1",
1417
]
1518

@@ -26,13 +29,19 @@ tag = true
2629
push = true
2730

2831
[tool.bumpver.file_patterns]
29-
"pyproject.toml" = [
30-
'^version = "{version}"',
31-
'^current_version = "{version}"',
32-
]
33-
"README.md" = [
34-
'rev: {version}',
35-
]
36-
"git_hooks/commit_msg.py" = [
37-
'two-inc/git-hooks/blob/{version}/README.md'
38-
]
32+
"pyproject.toml" = ['^version = "{version}"', '^current_version = "{version}"']
33+
"README.md" = ['rev: {version}']
34+
"git_hooks/commit_msg.py" = ['two-inc/git-hooks/blob/{version}/README.md']
35+
36+
[tool.coverage.run]
37+
branch = true
38+
39+
[tool.coverage.report]
40+
show_missing = true
41+
skip_covered = false
42+
skip_empty = false
43+
# Always show the report by default
44+
fail_under = 0
45+
46+
[tool.pytest.ini_options]
47+
addopts = "--cov=git_hooks --cov-report=term"

0 commit comments

Comments
 (0)