Skip to content

clean may not to be working as expected (or I don't know what I'm doing wrong) #156

Closed

Description

Before the first run of pre-commit on my repo, I created a .pre-commit-config.yaml file with pre-commit-hooks and the id Trim Trailing Whitespace (for testing purposes). It worked perfectly.
Now I've completely replaced the file with these contents:

-   repo: git://github.com/pre-commit/mirrors-jshint
    sha: b3a83909517504cc4bc923b9513b9e727987efdf
    hooks:
    -   id: jshint

And then ran it again after calling clean:

$ pre-commit clean
Cleaned /home/gabriel/.pre-commit.
$ pre-commit autoupdate
Updating git://github.com/pre-commit/mirrors-jshint...already up to date.
$ pre-commit run
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/gabriel/.pre-commit/patch1409172873.
[INFO] Installing environment for git://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Trim Trailing Whitespace................................................................................................................................Passed

What am I supposed to do? I've even reinstalled pre-commit without success 🐼

Activity

  1. asottile commented on Aug 27, 2014

    @asottile
    Member

    ah yeah I've seen this happen before. What's happening is it recognizes the .pre-commit-config.yaml file as unstaged and temporarily stashes it. To fix this git add .pre-commit-config.yaml or pre-commit run --no-stash

    The feature that you're running against is pre-commit will only run against staged contents of files.

    Let me know if this works for you and if there's somewhere we can update documentation!

    Also: pre-commit clean is mostly to clean out broken state (if it ever occurs) in ~/.pre-commit and shouldn't really be necessary in general :)

  2. gabrielpugliese-luizalabs commented on Aug 28, 2014

    @gabrielpugliese-luizalabs
    Author

    Yeah it worked like a charm! :) Ty
    Personally, I think putting in docs would be bad unless you put a FAQ section with good keywords so Google can index it very well. Otherwise, I would try to implement a way to not stash that file (do normal stash followed by checking out the yaml file - like git checkout stash@{0} -- .pre-commit-config.yaml)

  3. asottile commented on Aug 30, 2014

    @asottile
    Member

    @gabrielpugliese-luizalabs Created #157 to track this

  4. added a commit that references this issue on Mar 23, 2022
    96fb7fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions