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

Support a special `rev: PLACEHOLDER` which upon first installation will autoupdate #1023

Open
asottile opened this issue May 7, 2019 · 4 comments
Labels

Comments

@asottile
Copy link
Member

@asottile asottile commented May 7, 2019

problem

It's often clunky for hook authors to document a copy-pasteable snippet for use with pre-commit as they need to include a version number to use (this can be annoying when releasing that you need to remember to bump that version too!).

The current suggestion has been to use rev: '' though that leads to mysterious git errors -- for quite some time this was trending in our github traffic

proposal

Provide some sort of placeholder value, for backwards compatibility with existing documentation also allow the empty string as that placeholder value. This would allow a copy-pasteable snippet.

pre-commit would then need to ~essentially pre-commit autoupdate --repo $repo when encountered

thoughts?

@yoavcaspi
Copy link
Contributor

@yoavcaspi yoavcaspi commented Jun 12, 2019

I wish to work on this feature.
Is it possible to get the files relevant to the change? I'm still pretty new to pre-commit internals.

@asottile
Copy link
Member Author

@asottile asottile commented Jun 13, 2019

hmm yes, I'm not entirely sure where this should get implemented -- the autoupdate code lives in pre_commit/commands/autoupdate.py

The configuration loading ~mostly happens in pre_commit/repository.py -- though I think this rewriting should happen before that? Probably as part of pre_commit/commands/run.py?

autoupdate would also need to learn how to update from rev: '' / rev: PLACEHOLDER so that would also be in pre_commit/commands/autoupdate.py

@ollien
Copy link

@ollien ollien commented May 24, 2020

I've been poking around at implementing this and I have a couple questions about your intent with this issue.

  1. Should the config be updated when first run? My gut is to say no, as you likely wouldn't want this to be committed, as it would kind of defeat the point of the placeholder. If the answer is yes, how should this interact with --freeze?
  2. How should it interact with --bleeding-edge? Should this just assumed to be false?
@asottile
Copy link
Member Author

@asottile asottile commented May 24, 2020

yeah I think this would update the config on first run, without using --freeze or --bleeding-edge

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.