Skip to content

Commit ccd4eb7

Browse files
author
Steven Silvester
authored
Merge pull request #163 from jtpio/fix-since
Fix Handling of Since Last Stable
2 parents 98cd184 + c0ff219 commit ccd4eb7

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

jupyter_releaser/actions/draft_changelog.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
if not os.environ.get("RH_SINCE"):
1515
curr_dir = os.getcwd()
1616
os.chdir(CHECKOUT_NAME)
17-
since = get_latest_tag(os.environ["RH_BRANCH"]) or ""
17+
since_last_stable = os.environ.get("RH_SINCE_LAST_STABLE")
18+
since = get_latest_tag(os.environ["RH_BRANCH"], since_last_stable)
1819
if since:
1920
log(f"Capturing {since} in RH_SINCE variable")
2021
os.environ["RH_SINCE"] = since

jupyter_releaser/actions/draft_release.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
if not os.environ.get("RH_SINCE"):
3939
curr_dir = os.getcwd()
4040
os.chdir(CHECKOUT_NAME)
41-
since = get_latest_tag(os.environ["RH_BRANCH"]) or ""
41+
since_last_stable = os.environ.get("RH_SINCE_LAST_STABLE")
42+
since = get_latest_tag(os.environ["RH_BRANCH"], since_last_stable)
4243
if since:
4344
log(f"Capturing {since} in RH_SINCE variable")
4445
os.environ["RH_SINCE"] = since

jupyter_releaser/changelog.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def get_version_entry(
8080
str
8181
A formatted changelog entry with markers
8282
"""
83-
since = since or _get_since(ref or branch, since_last_stable)
83+
since = since or util.get_latest_tag(ref or branch, since_last_stable)
8484

8585
util.log(f"Getting changes to {repo} since {since} on branch {branch}...")
8686

@@ -290,23 +290,3 @@ def extract_current(changelog_path):
290290
if start != -1 and end != -1:
291291
body = changelog[start + len(START_MARKER) : end]
292292
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]

jupyter_releaser/util.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,22 @@ def actions_output(name, value):
254254
print(f"::set-output name={name}::{value}")
255255

256256

257-
def get_latest_tag(branch):
257+
def get_latest_tag(source, since_last_stable=False):
258258
"""Get the default 'since' value for a branch"""
259-
tags = run(f"git --no-pager tag --sort=-creatordate --merged {branch}", quiet=True)
260-
if tags:
261-
return tags.splitlines()[0]
259+
tags = run(f"git --no-pager tag --sort=-creatordate --merged {source}", quiet=True)
260+
if not tags:
261+
return ""
262+
263+
tags = tags.splitlines()
264+
265+
if since_last_stable:
266+
stable_tag = re.compile(r"\d\.\d\.\d$")
267+
tags = [t for t in tags if re.search(stable_tag, t)]
268+
if not tags:
269+
return ""
270+
return tags[0]
271+
272+
return tags[0]
262273

263274

264275
def retry(cmd, **kwargs):

0 commit comments

Comments
 (0)