Skip to content

Added git_hash and git_tag to generated cache info.#357

Open
mnesarco wants to merge 1 commit intoFreeCAD:devfrom
mnesarco:dev-git-info
Open

Added git_hash and git_tag to generated cache info.#357
mnesarco wants to merge 1 commit intoFreeCAD:devfrom
mnesarco:dev-git-info

Conversation

@mnesarco
Copy link
Contributor

@mnesarco mnesarco commented Feb 18, 2026

Added git info to cache data, it provides better ways to determine if an addon has changed "officially" by its tag or just by commits.

  "AddonX": [
    {
      "last_update_time": "2026-01-18T15:06:33-05:00",
      "curated": true,
      "sparse_cache": false,
      "relative_cache_path": "", ...


      # Fields added:
      "git_hash": "20013ae868bdc7bc32623aa0244735915ff3ec78",
      "git_tag": "0.1.17"
    }
  ],

Note: For some strange reason, Github does not refresh latest changes from the branch: dev-git-info

Copilot AI review requested due to automatic review settings February 18, 2026 19:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the generated addon catalog cache metadata to include git provenance (git_hash and git_tag) so consumers can distinguish between “official” tagged releases vs. untagged commit states.

Changes:

  • Add git_hash / git_tag fields to AddonCatalogEntry and a helper API to populate them.
  • Compute git tag (exact match) and HEAD commit hash during cache generation and write them into the cache output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
AddonCatalogCacheCreator.py Computes git tag/hash for locally cloned addon repos and stores them into the catalog entries during cache generation.
AddonCatalog.py Extends AddonCatalogEntry with git_hash/git_tag and adds add_git_info_to_entry() to persist those values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 236 to 269
def get_git_info(
self, addon_id: str, index: int, catalog_entry: AddonCatalog.AddonCatalogEntry
) -> Tuple[str | None, str | None]:
commit_hash: str | None = None
tag: str | None = None
dirname = self.get_directory_name(addon_id, index, catalog_entry)
if os.path.exists(os.path.join(self.cwd, dirname, ".git")):
repo = os.path.join(self.cwd, dirname)
# Tag
try:
result = subprocess.run(
["git", "describe", "--tags", "--exact-match"],
capture_output=True,
text=True,
check=True,
cwd=repo,
)
tag = result.stdout.strip()
except Exception:
tag = None
# Hash
try:
result = subprocess.run(
["git", "rev-parse", "HEAD"],
capture_output=True,
text=True,
check=True,
cwd=repo,
)
commit_hash = result.stdout.strip()
except Exception:
commit_hash = None

return commit_hash, tag
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

New behavior is introduced here (calling git to compute git_hash/git_tag and storing it in the catalog), but the existing unit test suite for AddonCatalogCacheCreator doesn’t cover this path. Please add tests for get_git_info (e.g., patch subprocess.run to simulate a tagged vs untagged HEAD and to ensure failures produce None values without invoking real git).

Copilot uses AI. Check for mistakes.
Comment on lines +344 to +356
def add_git_info_to_entry(
self, addon_id: str, index: int, commit_hash: str | None, tag: str | None
) -> None:
"""Adds git commit hash and tag to an AddonCatalogEntry"""
entries = self._dictionary.get(addon_id)
if entries is None:
raise RuntimeError(f"Addon {addon_id} does not exist")
if index >= len(entries):
raise RuntimeError(f"Addon {addon_id} index out of range")
entry = entries[index]
entry.git_hash = commit_hash
entry.git_tag = tag

Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

add_git_info_to_entry is a new public method on AddonCatalog but there are existing tests for AddonCatalog/AddonCatalogEntry that don’t cover it. Please add unit tests to verify it sets git_hash/git_tag on the correct entry and raises the expected errors for unknown addon IDs / out-of-range indexes.

Copilot uses AI. Check for mistakes.
Comment on lines 29 to 31
from dataclasses import is_dataclass, fields
from typing import Any, List, Optional, Dict
from typing import Any, List, Optional, Dict, Tuple

Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

typing.List is imported twice in this module (once in the combined import that was updated here, and again later as from typing import List). Please drop the later duplicate import to avoid redundancy and keep imports consistent.

Copilot uses AI. Check for mistakes.
@mnesarco mnesarco marked this pull request as draft February 18, 2026 20:27
@mnesarco
Copy link
Contributor Author

I don't know what is going on with Github, but the latest changes are not reflected here. So look at the branch directly: dev...mnesarco:AddonManager:dev-git-info

@mnesarco mnesarco marked this pull request as ready for review February 18, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments