1
1
from __future__ import annotations
2
2
3
3
import re
4
+ from collections .abc import Iterable
4
5
from functools import cached_property
5
6
from typing import Callable , Protocol
6
7
10
11
11
12
12
13
def find_increment_by_callable (
13
- commit_messages : list [str ], get_increment : Callable [[str ], Increment | None ]
14
+ commit_messages : Iterable [str ], get_increment : Callable [[str ], Increment | None ]
14
15
) -> Increment | None :
15
16
"""Find the highest version increment from a list of messages.
16
17
@@ -29,7 +30,7 @@ def find_increment_by_callable(
29
30
30
31
Example:
31
32
>>> commit_messages = ["feat: new feature", "fix: bug fix"]
32
- >>> rule = DefaultBumpRule ()
33
+ >>> rule = ConventionalCommitBumpRule ()
33
34
>>> find_increment_by_callable(commit_messages, lambda x: rule.get_increment(x, False))
34
35
'MINOR'
35
36
"""
@@ -44,7 +45,7 @@ def get_increment(
44
45
) -> Increment | None : ...
45
46
46
47
47
- class DefaultBumpRule (BumpRule ):
48
+ class ConventionalCommitBumpRule (BumpRule ):
48
49
_PATCH_CHANGE_TYPES = set (["fix" , "perf" , "refactor" ])
49
50
50
51
def get_increment (
@@ -85,10 +86,4 @@ def _head_pattern(self) -> re.Pattern:
85
86
return re .compile (f"^{ re_change_type } { re_scope } { re_bang } :" )
86
87
87
88
88
- class CustomBumpRule (BumpRule ):
89
- """TODO: Implement"""
90
-
91
- def get_increment (
92
- self , commit_message : str , major_version_zero : bool
93
- ) -> Increment | None :
94
- return None
89
+ # TODO: Implement CustomBumpRule
0 commit comments