From 12235cd4f4646fee8d5f32f41dd853edfdf5e215 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Wed, 13 Sep 2023 16:31:52 +0200 Subject: [PATCH 1/2] Fix subdirectory tagging --- README.md | 6 ++++++ tagbot/action/repo.py | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 3faed105..ed115bc7 100644 --- a/README.md +++ b/README.md @@ -387,6 +387,12 @@ with: Version tags will then be prefixed with the subpackage's name: `{PACKAGE}-v{VERSION}`, e.g., `SubpackageName-v0.2.3`. (For top-level packages, the default tag is simply `v{VERSION}`.) +**Note**: Using TagBot with a non-empty `subdir` will only work for Julia package versions +registered using the official +[Registrator](https://github.com/JuliaRegistries/Registrator.jl) (see also +[#281](https://github.com/JuliaRegistries/TagBot/issues/281) and +[#282](https://github.com/JuliaRegistries/TagBot/pull/282)). + To tag releases from a monorepo containing multiple subpackages and an optional top-level package, set up a separate step for each package you want to tag. For example, to tag all three packages in the following repository, ``` diff --git a/tagbot/action/repo.py b/tagbot/action/repo.py index f9ce14bb..fbdb2ef0 100644 --- a/tagbot/action/repo.py +++ b/tagbot/action/repo.py @@ -256,6 +256,16 @@ def _commit_sha_from_registry_pr(self, version: str, tree: str) -> Optional[str] logger.info("Registry PR body did not match") return None commit = self._repo.get_commit(m[1]) + # Handle special case of tagging packages in a repo subdirectory, in which + # case the Julia package tree hash does not match the git commit tree hash + if self.__subdir: + subdir_tree_hash = self._git.command("rev-parse", f"{commit.sha}:{self.__subdir}") + if subdir_tree_hash == tree: + return commit.sha + else: + logger.warning("Subdir tree SHA of commit from registry PR does not match") + return None + # Handle regular case (subdir is not set) if commit.commit.tree.sha == tree: return commit.sha else: From 8eac8a31e984a59e95ee99ef56c465fed6eab2c2 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Wed, 13 Sep 2023 16:38:11 +0200 Subject: [PATCH 2/2] Fix line length --- tagbot/action/repo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tagbot/action/repo.py b/tagbot/action/repo.py index fbdb2ef0..ae9bb311 100644 --- a/tagbot/action/repo.py +++ b/tagbot/action/repo.py @@ -259,11 +259,13 @@ def _commit_sha_from_registry_pr(self, version: str, tree: str) -> Optional[str] # Handle special case of tagging packages in a repo subdirectory, in which # case the Julia package tree hash does not match the git commit tree hash if self.__subdir: - subdir_tree_hash = self._git.command("rev-parse", f"{commit.sha}:{self.__subdir}") + arg = f"{commit.sha}:{self.__subdir}" + subdir_tree_hash = self._git.command("rev-parse", arg) if subdir_tree_hash == tree: return commit.sha else: - logger.warning("Subdir tree SHA of commit from registry PR does not match") + msg = "Subdir tree SHA of commit from registry PR does not match" + logger.warning(msg) return None # Handle regular case (subdir is not set) if commit.commit.tree.sha == tree: