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

fix how we collect tags on current commit #1063

Merged
merged 2 commits into from
Jun 16, 2023
Merged
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
31 changes: 12 additions & 19 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,8 @@ def publish(context: Context, dry_run: str = ""):
"js": prepare_js_release,
"py": prepare_py_release,
}

parsed_tags: list[TagInfo] = [
parse_tag(tag) for tag in dry_run.split(",") or get_current_tags(context)
]
current_tags = dry_run.split(",") if dry_run else get_current_tags(context)
parsed_tags = [parse_tag(tag) for tag in current_tags]

publishers: list[Callable[[bool], None]] = []
for tag_info in parsed_tags:
Expand Down Expand Up @@ -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 --exit-code", hide=True)
except Exception:
log.error("Cannot create a tag - there are uncommitted changes")
log.error("Cannot get current tags - there are uncommitted changes")
return set()

tags_per_commit: dict[str, list[str]] = {}
for commit, tag in map(
str.split,
context.run(
r"git for-each-ref --format '%(objectname) %(refname:short)' refs/tags",
hide=True,
).stdout.splitlines(),
):
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()))
# get tags for current commit
tags = {
line
for line in map(
str.strip,
context.run("git tag --points-at HEAD", hide=True).stdout.splitlines(),
)
if line
}

if not tags:
log.error("No tags found for current commit")
Expand Down