Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git: Short SHA performance #560

Open
giggsey opened this issue Jul 27, 2022 · 4 comments
Open

Git: Short SHA performance #560

giggsey opened this issue Jul 27, 2022 · 4 comments
Assignees

Comments

@giggsey
Copy link

giggsey commented Jul 27, 2022

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.

@chelnak
Copy link

chelnak commented Aug 1, 2022

Hey @giggsey thanks for this. It's a solid suggestion.

I'll do some testing with the updated command in the description and see what comes up.

In the meantime - if you have already implemented this, a PR would be welcome. We could work with you to get it merged.

@chelnak chelnak self-assigned this Aug 1, 2022
chelnak added a commit that referenced this issue Aug 1, 2022
As pointed out in #560, the check for SHA equality only
currently works for long shas which are 40 characters.

If a short SHA with :revision rev-parse HEAD returns a long SHA
therefore rendering the equality check false.

e.g

"cb1eb6" != "cb1eb6bb33eb6889818f5b02aa593b4ff2f8ca33"

This commit updates the args so that rev-parse will always return a SHA
that is the same length as the value provided with the :revision
parameter.

This will cause the check to be true and exit get_revision early as it would
do when both values are 40 characters.
@github-actions
Copy link

Hello! 👋

This issue has been open for a while and has had no recent activity. We've labelled it with attention-needed so that we can get a clear view of which issues need our attention.

If you are waiting on a response from us we will try and address your comments on a future Community Day.

Alternatively, if it is no longer relevant to you please close the issue with a comment.

@giggsey
Copy link
Author

giggsey commented Nov 8, 2022

Completed?

@LukasAud
Copy link

LukasAud commented Nov 9, 2022

Sorry, this was marked as inactive and closed by our outdated automated system some time ago. We no longer close inactive issues based on inactivity without confirmation. Re-opening this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants