Don't compare tags to testing by default

This commit is contained in:
Mikhail f. Shiryaev 2022-05-24 20:15:04 +02:00
parent e120ce1abb
commit fbe16a1d33
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -173,6 +173,11 @@ def parse_args() -> argparse.Namespace:
"--gh-password",
help="a password that should be used when user is given",
)
parser.add_argument(
"--with-testing-tags",
action="store_true",
help="by default '*-testing' tags are ignored, this argument enables them too",
)
parser.add_argument(
"--from",
dest="from_ref",
@ -296,7 +301,7 @@ def write_changelog(fd: TextIO, descriptions: Dict[str, List[Description]]):
fd.write("\n")
def check_refs(from_ref: Optional[str], to_ref: str):
def check_refs(from_ref: Optional[str], to_ref: str, with_testing_tags: bool):
global FROM_REF, TO_REF
TO_REF = to_ref
@ -306,10 +311,13 @@ def check_refs(from_ref: Optional[str], to_ref: str):
# Check from_ref
if from_ref is None:
# Get all tags pointing to TO_REF
tags = runner.run(f"git tag --points-at '{TO_REF}^{{}}'")
tags = runner.run(f"git tag --points-at '{TO_REF}^{{}}'").split("\n")
logging.info("All tags pointing to %s:\n%s", TO_REF, tags)
exclude = " ".join([f"--exclude='{tag}'" for tag in tags.split("\n")])
FROM_REF = runner.run(f"git describe --abbrev=0 --tags {exclude} '{TO_REF}'")
if not with_testing_tags:
tags.append("*-testing")
exclude = " ".join([f"--exclude='{tag}'" for tag in tags])
cmd = f"git describe --abbrev=0 --tags {exclude} '{TO_REF}'"
FROM_REF = runner.run(cmd)
else:
runner.run(f"git rev-parse {FROM_REF}")
FROM_REF = from_ref
@ -336,7 +344,7 @@ def main():
logging.info("Fetching all tags")
runner.run("git fetch --tags", stderr=DEVNULL)
check_refs(args.from_ref, args.to_ref)
check_refs(args.from_ref, args.to_ref, args.with_testing_tags)
set_sha_in_changelog()
logging.info("Using %s..%s as changelog interval", FROM_REF, TO_REF)