Files
renovate/lib/modules/datasource/git-refs
Jason Learst 74233b1696 feat(git-refs): use dereferenced commit hash for annotated tags (#41560)
* feat(git-refs): use dereferenced commit hash for annotated tags

When git ls-remote lists annotated tags, it returns two entries:
1. The tag object hash: refs/tags/v1.0.0 -> abc123
2. The dereferenced commit hash: refs/tags/v1.0.0^{} -> def456

Previously, Renovate used the tag object hash (abc123).  However, `git submodule status` returns the actual commit hash (def456).  This mismatch caused false-positive dependency updates that resulted in empty commits, since the tag object and commit hash differ even when pointing to the same version.

This feature:
- Parses both entries from git ls-remote into allRefs
- Builds a lookup map of tag names to their dereferenced commit hashes
- For annotated tags, replaces the tag object hash with the commit hash
- Lightweight tags are unaffected (they already return the commit hash)

This ensures Renovate's detected digest matches what git submodule operations actually use, preventing unnecessary update PRs.

* Apply suggestions from code review

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>

* fix typo in dereferencedTags variable name

---------

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>
2026-03-12 20:10:11 +00:00
..
2022-03-04 09:04:02 +01:00

You can use this datasource plus regex managers to update git-based dependencies that are not natively supported by Renovate.

The git-refs datasource returns a reference from a Git repository.

The packageName must be a fully qualified domain name.

To fetch the latest digest of a reference instead of the named reference: put the named reference in currentValue and match on the currentDigest.

Usage example

Say you want to maintain the HEAD digest of the master branch of a repository. You would configure a custom manager in your Renovate config file for files named versions.ini:

{
  "customManagers": [
    {
      "customType": "regex",
      "managerFilePatterns": ["/^versions.ini$/"],
      "matchStrings": ["GOOGLE_API_VERSION=(?<currentDigest>.*?)\\n"],
      "currentValueTemplate": "master",
      "depNameTemplate": "googleapis",
      "packageNameTemplate": "https://github.com/googleapis/googleapis",
      "datasourceTemplate": "git-refs"
    }
  ]
}