Skip to content
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
29 changes: 17 additions & 12 deletions src/cfengine_cli/masterfiles/generate_git_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,29 @@ def clone_or_update_repo(repo):
def get_commit_shas_from_tags(repo_path):
# Returns a mapping of git tag to commit SHA for all version tags in the repo
output = (
subprocess.check_output(["git", "show-ref", "--tags"], cwd=repo_path)
subprocess.check_output(["git", "show-ref", "--tags", "-d"], cwd=repo_path)
.decode()
.strip()
)
tag_map = {}

for line in output.splitlines():
ref = line.split()[1]
tag = ref.split("refs/tags/")[1]
if re.fullmatch(TAG_REGEX, tag):
sha = (
subprocess.check_output(
["git", "log", "-n", "1", "--format=%H", tag], cwd=repo_path
)
.decode()
.strip()
)
tag_map[tag] = sha
parts = line.split()
if len(parts) != 2:
continue
sha, ref = parts

if ref.startswith("refs/tags/"):
tag = ref.split("refs/tags/")[1]
if tag.endswith("^{}"):
tag_name = tag[:-3]
if re.fullmatch(TAG_REGEX, tag_name):
tag_map[tag_name] = sha
else:
if re.fullmatch(TAG_REGEX, tag):
# Only set if not already set by ^{}
if tag not in tag_map:
tag_map[tag] = sha
Comment on lines +63 to +67
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarakthon is this necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I generate the files without the else-block, a lot of the tags are not included, for example in the nova repository these tags are lost:

  "3.12.0-3756": "569a47940a899323762bb344590a6a8bd45e9bca",
  ...
  "2.2.3": "7425acab5d3746bd19f684d3da7ab48af3cb42fd",
  ...
  "2.1.4": "6c164868706b031bb7cf922388db754088a72d79",
  "2.1.3": "3bfb08ae8c335cebfce75c50b7269626b2519a27",
  "2.1.2": "c3f7f0a69082d9c3c539cdb203c36fa2f223d124",
  "2.1.1": "c15d6957e8ec4719699b5b65c9c1897712756eff",
  "2.1.0": "7648a05e1983b8beb2f71dea01f0f18965eeb681",
  "2.0.4": "f5c9b2893fd49027e6e03423650c834099c2a35f",
  "2.0.3": "05824b1769879d6f506e30e8a2847d4886477c70",
  "2.0.2": "3741ac8a615bbfdee572db065d616ac618eff860",
  "2.0.1": "eaebfe66e3bfb348fe22f6898bb4382387b717c8",
  "2.0.0": "bf89f831fb94a0af815014f61eb1bddead337a57",
  "1.1.2": "a503ebb250162b015e115e92d258517b0f75538e",
  "1.1.1": "f6150803b45cd0fe519a918f34e34753bcafdba2",
  "1.1.0": "b8d8ccaa05c0c66f1970a7de8a8a8e98c9ec6b80"
}

I tried looking into these tags and when I print them, none of them end with ^{}:

1.1.0
1.1.1
1.1.2
2.0.0
2.0.1
2.0.2
2.0.3
2.0.4
2.1.0
2.1.0b1
2.1.0p1
2.1.1
2.1.2
2.1.3
2.1.4
2.2.0
2.2.0^{}
2.2.1
2.2.1^{}
2.2.2
2.2.2^{}
2.2.3
2.2.4
2.2.4^{}

I also checked the tags manually on GitHub and this message appears:
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Does this mean I should not include them? Or should I include them in some other way?


return tag_map

Expand Down
Loading