Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github_repo: strip v prefix if revision is any version number #2832

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions rules/subrepo_rules.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,19 @@ def github_repo(name:str, repo:str, revision:str, build_file:str=None, labels:li
org, _, repo = repo.partition('/')
assert repo, "Must pass a valid Github repo argument, e.g. thought-machine/please"

# If it looks like semver, we need to remove the v from it because github formats their zips differently for semver
# tags
if is_semver(revision):
# If revision looks like a version number, we need to strip any "v" prefix from it because
# GitHub also strips it from the top-level directory name for zips generated for tags that
# look like version numbers
def is_dotted_version_number(v):
v = v.removeprefix("v")
num = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
for p in v.split("."):
for n in num:
p = p.replace(n, "")
if p != "":
return False
return True
if is_semver(revision) or is_dotted_version_number(revision):
prefix = revision.removeprefix('v')
else:
prefix = revision
Expand Down