fix how we collect tags on current commit (#1063)
* fix how we collect tags on current commit * fix dry-run handling
This commit is contained in:
parent
6df7ecdebb
commit
9bf3db7f66
1 changed files with 12 additions and 19 deletions
31
tasks.py
31
tasks.py
|
@ -209,10 +209,8 @@ def publish(context: Context, dry_run: str = ""):
|
||||||
"js": prepare_js_release,
|
"js": prepare_js_release,
|
||||||
"py": prepare_py_release,
|
"py": prepare_py_release,
|
||||||
}
|
}
|
||||||
|
current_tags = dry_run.split(",") if dry_run else get_current_tags(context)
|
||||||
parsed_tags: list[TagInfo] = [
|
parsed_tags = [parse_tag(tag) for tag in current_tags]
|
||||||
parse_tag(tag) for tag in dry_run.split(",") or get_current_tags(context)
|
|
||||||
]
|
|
||||||
|
|
||||||
publishers: list[Callable[[bool], None]] = []
|
publishers: list[Callable[[bool], None]] = []
|
||||||
for tag_info in parsed_tags:
|
for tag_info in parsed_tags:
|
||||||
|
@ -315,23 +313,18 @@ def get_current_tags(context: Context) -> set[str]:
|
||||||
context.run("git diff --cached --exit-code", hide=True)
|
context.run("git diff --cached --exit-code", hide=True)
|
||||||
context.run("git diff --exit-code", hide=True)
|
context.run("git diff --exit-code", hide=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.error("Cannot create a tag - there are uncommitted changes")
|
log.error("Cannot get current tags - there are uncommitted changes")
|
||||||
return set()
|
return set()
|
||||||
|
|
||||||
tags_per_commit: dict[str, list[str]] = {}
|
# get tags for current commit
|
||||||
for commit, tag in map(
|
tags = {
|
||||||
str.split,
|
line
|
||||||
context.run(
|
for line in map(
|
||||||
r"git for-each-ref --format '%(objectname) %(refname:short)' refs/tags",
|
str.strip,
|
||||||
hide=True,
|
context.run("git tag --points-at HEAD", hide=True).stdout.splitlines(),
|
||||||
).stdout.splitlines(),
|
)
|
||||||
):
|
if line
|
||||||
tags_per_commit.setdefault(commit, []).append(tag)
|
}
|
||||||
|
|
||||||
current_commit = context.run(
|
|
||||||
"git rev-parse HEAD", silent=True, external=True
|
|
||||||
).stdout.strip()
|
|
||||||
tags = set(tags_per_commit.get(current_commit, set()))
|
|
||||||
|
|
||||||
if not tags:
|
if not tags:
|
||||||
log.error("No tags found for current commit")
|
log.error("No tags found for current commit")
|
||||||
|
|
Loading…
Reference in a new issue