@@ -47,6 +47,7 @@ def get_version_entry(
47
47
version ,
48
48
* ,
49
49
since = None ,
50
+ since_last_stable = None ,
50
51
until = None ,
51
52
auth = None ,
52
53
resolve_backports = False ,
@@ -65,6 +66,8 @@ def get_version_entry(
65
66
The new version
66
67
since: str
67
68
Use PRs with activity since this date or git reference
69
+ since_last_stable:
70
+ Use PRs with activity since the last stable git tag
68
71
until: str, optional
69
72
Use PRs until this date or git reference
70
73
auth : str, optional
@@ -77,14 +80,7 @@ def get_version_entry(
77
80
str
78
81
A formatted changelog entry with markers
79
82
"""
80
-
81
- if not since :
82
- source = ref or branch
83
- tags = util .run (
84
- f"git --no-pager tag --sort=-creatordate --merged { source } " , quiet = True
85
- )
86
- if tags :
87
- since = tags .splitlines ()[0 ]
83
+ since = since or _get_since (ref or branch , since_last_stable )
88
84
89
85
util .log (f"Getting changes to { repo } since { since } on branch { branch } ..." )
90
86
@@ -142,7 +138,9 @@ def get_version_entry(
142
138
return output
143
139
144
140
145
- def build_entry (ref , branch , repo , auth , changelog_path , since , resolve_backports ):
141
+ def build_entry (
142
+ ref , branch , repo , auth , changelog_path , since , since_last_stable , resolve_backports
143
+ ):
146
144
"""Build a python version entry"""
147
145
branch = branch or util .get_branch ()
148
146
repo = repo or util .get_repo ()
@@ -166,6 +164,7 @@ def build_entry(ref, branch, repo, auth, changelog_path, since, resolve_backport
166
164
repo ,
167
165
version ,
168
166
since = since ,
167
+ since_last_stable = since_last_stable ,
169
168
auth = auth ,
170
169
resolve_backports = resolve_backports ,
171
170
)
@@ -211,7 +210,15 @@ def format(changelog):
211
210
212
211
213
212
def check_entry (
214
- ref , branch , repo , auth , changelog_path , since , resolve_backports , output
213
+ ref ,
214
+ branch ,
215
+ repo ,
216
+ auth ,
217
+ changelog_path ,
218
+ since ,
219
+ since_last_stable ,
220
+ resolve_backports ,
221
+ output ,
215
222
):
216
223
"""Check changelog entry"""
217
224
branch = branch or util .get_branch ()
@@ -241,6 +248,7 @@ def check_entry(
241
248
repo ,
242
249
version ,
243
250
since = since ,
251
+ since_last_stable = since_last_stable ,
244
252
auth = auth ,
245
253
resolve_backports = resolve_backports ,
246
254
)
@@ -282,3 +290,23 @@ def extract_current(changelog_path):
282
290
if start != - 1 and end != - 1 :
283
291
body = changelog [start + len (START_MARKER ) : end ]
284
292
return body
293
+
294
+
295
+ def _get_since (source , since_last_stable = False ):
296
+ """Get the appropriate since reference or None"""
297
+ tags = util .run (
298
+ f"git --no-pager tag --sort=-creatordate --merged { source } " , quiet = True
299
+ )
300
+ if not tags :
301
+ return
302
+
303
+ tags = tags .splitlines ()
304
+
305
+ if since_last_stable :
306
+ stable_tag = re .compile (r"\d\.\d\.\d$" )
307
+ tags = [t for t in tags if re .search (stable_tag , t )]
308
+ if not tags :
309
+ return
310
+ return tags [0 ]
311
+
312
+ return tags [0 ]
0 commit comments