Skip to content

Commit

Permalink
Fix subdirectory tagging (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
sloede committed Sep 18, 2023
1 parent 8e26773 commit 9807a75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,

```
Expand Down
12 changes: 12 additions & 0 deletions tagbot/action/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@ 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:
arg = f"{commit.sha}:{self.__subdir}"
subdir_tree_hash = self._git.command("rev-parse", arg)
if subdir_tree_hash == tree:
return commit.sha
else:
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:
return commit.sha
else:
Expand Down

0 comments on commit 9807a75

Please sign in to comment.