Skip to content

Commit 9cbfe94

Browse files
committed
add changelog to docs
1 parent 025a996 commit 9cbfe94

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

docs/source/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Changelog
2+
=========

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Libraries for defining and controlling interactive webpages with Python
2929

3030
contributing
3131
developer-guide
32+
changelog
3233

3334
.. toctree::
3435
:hidden:

noxfile.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from __future__ import annotations
2+
13
import os
24
import re
5+
import subprocess
36
from pathlib import Path
4-
from typing import List
7+
from typing import DefaultDict, List, Tuple
58

69
import nox
710
from nox.sessions import Session
@@ -146,6 +149,46 @@ def test_docs(session: Session) -> None:
146149
session.run("sphinx-build", "-b", "doctest", "docs/source", "docs/build")
147150

148151

152+
@nox.session
153+
def commits_since_last_tag(session: Session) -> None:
154+
sha_format_in_rst = "--sha-format=rst" in session.posargs
155+
156+
latest_tag = (
157+
subprocess.check_output(["git", "describe", "--tags", "--abbrev=0"])
158+
.decode()
159+
.strip()
160+
)
161+
commit_references = (
162+
subprocess.check_output(
163+
["git", "log", "--pretty=reference", f"{latest_tag}..HEAD"]
164+
)
165+
.decode()
166+
.strip()
167+
.split("\n")
168+
)
169+
170+
commits: List[Tuple[str, str, str]] = []
171+
for commit_ref in commit_references:
172+
commit_sha, remainder = commit_ref.split(" ", 1)
173+
commit_message, commit_date = remainder[1:-1].rsplit(", ", 1)
174+
commits.append((commit_sha, commit_message, commit_date))
175+
176+
commits_by_date: DefaultDict[str, List[str]] = DefaultDict(list)
177+
for sha, msg, date in commits:
178+
if sha_format_in_rst:
179+
sha_repr = f"`{sha} <https://github.com/idom-team/idom/commit/{sha}>`__"
180+
else:
181+
sha_repr = sha
182+
commits_by_date[date].append(f"{msg} {sha_repr}")
183+
184+
for date, commits in commits_by_date.items():
185+
print(f"Commits on {date}")
186+
print()
187+
for cmt in commits:
188+
print("-", cmt)
189+
print()
190+
191+
149192
def install_idom_dev(session: Session, extras: str = "stable") -> None:
150193
session.install("-e", f".[{extras}]")
151194
if "--no-restore" not in session.posargs:

0 commit comments

Comments
 (0)