Skip to content

Commit

Permalink
Fix incorrect tag name used for automatic version tagging of packages…
Browse files Browse the repository at this point in the history
… in Git repositories.

Git doesn't allow ':' to be used in tag names. As done in a previous implementation, we're using '!' instead of ':' to denote epochs in our version tags.
  • Loading branch information
hwittenborn committed Apr 14, 2022
1 parent 150bfac commit 13a1882
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
5 changes: 4 additions & 1 deletion aurweb/git/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,10 @@ def main(): # noqa: C901
save_metadata(srcinfo, user)

# Create a tag for the current package's version if it doesn't currently exist.
tag_name = f"refs/tags/ver/{version}"
#
# Git tags don't support the ':' character, so we replace it with '!'.
tag_version = version.replace(":", "!")
tag_name = f"refs/tags/ver/{tag_version}"

if not repo.references.get(tag_name):
repo.references.create(tag_name, sha1_new)
Expand Down
29 changes: 29 additions & 0 deletions test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,32 @@ def test_push_invalid_pkgbase():
match="invalid pkgbase: not_the_correct_pkgbase, expected testpkg",
):
repo.push()


def test_push_with_epoch():
"""
Ensure that the update script creates a tag with the ':' in the epoch
replaced with a '!'.
"""
repo = create_git_repo("testpkg")
repo.chdir_repo()

write_file("PKGBUILD", [])
write_file(
".SRCINFO",
[
"pkgbase = testpkg",
"pkgname = testpkg",
"pkgver = 1",
"pkgrel = 1",
"epoch = 1",
"pkgdesc = testpkgdesc",
"arch = any",
],
)

repo.add(["PKGBUILD", ".SRCINFO"])
repo.commit()
repo.push()

assert repo.run_command(["git", "tag"]).stdout == "ver/1!1-1\n"

0 comments on commit 13a1882

Please sign in to comment.