Skip to content

Git: Short SHA performance #560

Open
@giggsey

Description

@giggsey

Use Case

There is also an optimisation if the cloned repo is at the correct revision: https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/main/lib/puppet/provider/vcsrepo/git.rb#L529-L532 introduced in #380

But this only works with full SHAs.

When the SHA isn't an exact match, a git fetch is run, which can potentially be slow for large repos

Describe the Solution You Would Like

git rev-parse HEAD is used to get the current commit for use in comparison, which returns the full sha.

Could that command change to git rev-parse --short={@resource.value(:revision).length} HEAD for the comparison?

This would then match, and not bother with the rest of the get_revision function.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions