Skip to content

Commit 4b1a79b

Browse files
committed
let dec-tool publish treat an unchanged site as up to date
Publishing a build identical to the deployed version failed with GitEmptyCommit, which also aborted public:preview before it could serve the branch. Report that nothing changed and exit cleanly.
1 parent 1ae0d91 commit 4b1a79b

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

‎tools/publish.py‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import click
3131
from mike import commands, utils
32+
from mike.git_utils import GitEmptyCommit
3233

3334
CANONICAL_RE = re.compile(r'<link rel="canonical" href="([^"]+)"')
3435

@@ -95,15 +96,26 @@ def publish(version: str, branch: str, aliases: tuple[str, ...]) -> None:
9596
if pruned:
9697
print(f"Pruned {len(pruned)} copied-along dotfile(s)", file=sys.stderr)
9798

98-
# Empty body: mike commits site_dir when the context manager exits.
99-
with commands.deploy(
100-
cfg,
101-
version,
102-
aliases=list(aliases),
103-
update_aliases=True,
104-
branch=branch,
105-
):
106-
pass
107-
10899
listed = ", ".join(aliases) or "no aliases"
100+
101+
# Empty body: mike commits site_dir when the context manager exits. An
102+
# unchanged site is not an error - mike has already dropped the empty
103+
# commit, and public:preview must still serve the branch as it stands.
104+
try:
105+
with commands.deploy(
106+
cfg,
107+
version,
108+
aliases=list(aliases),
109+
update_aliases=True,
110+
branch=branch,
111+
):
112+
pass
113+
except GitEmptyCommit:
114+
print(
115+
f"{branch} already carries this build as {version} ({listed}) - "
116+
f"nothing to commit",
117+
file=sys.stderr,
118+
)
119+
return
120+
109121
print(f"Committed {site} as {version} ({listed}) on {branch}", file=sys.stderr)

0 commit comments

Comments
 (0)