Skip to content

Add git hashes to commits metadata#2708

Merged
lutien merged 4 commits intomozilla:masterfrom
lutien:add-git-hashes-to-commits-metadata
Mar 13, 2026
Merged

Add git hashes to commits metadata#2708
lutien merged 4 commits intomozilla:masterfrom
lutien:add-git-hashes-to-commits-metadata

Conversation

@lutien
Copy link
Member

@lutien lutien commented Feb 27, 2026

Extracted the part about adding the git hashes to commits metadata from #2658.

  • I got the information that there is a CSV file with mapping between git and hg hashes up until the git migration data of last year. For the rest, we have to use the API. My idea would be to use this file as a starting point and then continue writing to it with new hashes.

@lutien lutien requested a review from jgraham February 27, 2026 16:53
@lutien lutien force-pushed the add-git-hashes-to-commits-metadata branch from 006b358 to 07c4824 Compare February 27, 2026 16:58
sync/lando.py Outdated
return _git_to_hg, _hg_to_git


def _save_new_hashes(git_hash: str, hg_hash: str) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to to add the mapping to the per-commit metadata in the repository (i.e. the git notes for each commit), and read that? We could consider a one-time import of the CSV file to backfill existing data (but that could be overkill; I think it's pretty likely we ~never read these older commits, unless I'm forgetting something).

sync/commit.py Outdated
return self.sha1

@property
def git_rev(self) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

I think the naming here is getting confusing because for mozilla-central we have three different possible revisions, two of which are git. Maybe we should call it canonical_rev_git. Here the implementation would look like:

@property
def canonical_rev_git(self) -> str:
    if self.cinnabar:
        raise ValueError(f"Commit {self.sha1} doesn't have a canonical git SHA1")
    return self.sha1

But then in GeckoCommit you'd override it to:

@property
def canonical_rev_git(self) -> str:
    if self.cinnabar:
        if "gecko-commit-git" not in self.notes:
            self.notes["gecko-commit-git"] = hg2git(self.sha1)
        sha1 = self.notes["gecko-commit-git"]
        assert sha1 is not None
        return sha1
    return self.sha1

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, updated

@lutien lutien force-pushed the add-git-hashes-to-commits-metadata branch from 2fb771b to 3e476c1 Compare March 2, 2026 13:39
@lutien lutien requested a review from jgraham March 9, 2026 08:34
@lutien lutien closed this Mar 9, 2026
@lutien lutien reopened this Mar 9, 2026
@lutien lutien merged commit d18149f into mozilla:master Mar 13, 2026
7 of 8 checks passed
@lutien lutien deleted the add-git-hashes-to-commits-metadata branch March 13, 2026 12:19
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.

2 participants