Skip to content

Commit

Permalink
Merge pull request #783 from camptocamp/fix-publish
Browse files Browse the repository at this point in the history
Stronger version detection
  • Loading branch information
sbrunner authored Oct 12, 2022
2 parents 09dcf0c + 5e0b2e9 commit 79917ea
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions c2cciutils/scripts/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def main() -> None:
ref,
c2cciutils.compile_re(config["version"].get("branch_to_version_re", []), "refs/heads/"),
)
ref_match = re.match(r"refs/pull/(.*)/merge", ref)

if args.version is not None:
version = args.version
Expand All @@ -115,18 +116,16 @@ def main() -> None:
else:
print("WARNING: you specified the argument --type but not one of --version, --branch or --tag")
version = c2cciutils.get_value(*tag_match)
elif branch_match[0] is None:
ref_match = re.match(r"refs/pull/(.*)/merge", ref)
if ref_match is not None:
version = c2cciutils.get_value(ref_match, {}, ref)
if version_type is None:
version_type = "feature_branch"
elif branch_match[0] is not None:
if version_type is None:
version_type = "version_branch"
else:
print("WARNING: you specified the argument --type but not one of --version, --branch or --tag")
version = c2cciutils.get_value(*branch_match)
elif ref_match is not None:
version = c2cciutils.get_value(ref_match, {}, ref)
if version_type is None:
version_type = "feature_branch"
elif ref.startswith("refs/heads/"):
if version_type is None:
version_type = "feature_branch"
Expand All @@ -149,7 +148,9 @@ def main() -> None:
sys.exit(0)

if version_type is None:
print("ERROR: you specified one of the arguments --version, --branch or --tag but not the --type")
print(
f"ERROR: you specified one of the arguments --version, --branch or --tag but not the --type, GitHub ref is: {ref}"
)
sys.exit(1)

if version_type is not None:
Expand Down

0 comments on commit 79917ea

Please sign in to comment.