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

check-symlinks hook not working #1718

Closed
CodeBleu opened this issue Nov 27, 2020 · 1 comment
Closed

check-symlinks hook not working #1718

CodeBleu opened this issue Nov 27, 2020 · 1 comment
Labels

Comments

@CodeBleu
Copy link

OS : Gentoo
Python Version : Python 3.8.6
pre-commit Version : pre-commit 2.9.1

$ cat .pre-commit-config.yaml

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.3.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml
    -   id: check-added-large-files
    -   id: check-json
    -   id: check-merge-conflict
    -   id: check-symlinks
    -   id: detect-aws-credentials

$ ls -alh

total 24K
drwxr-xr-x 3 blah users 4.0K Nov 25 18:50 .
drwxr-xr-x 4 blah users 4.0K May 24  2020 ..
drwxr-xr-x 7 blah users 4.0K Nov 25 18:51 .git
-rw-r--r-- 1 blah users  436 Nov 25 18:01 .pre-commit-config.yaml
lrwxrwxrwx 1 blah users    8 Nov 25 18:26 blahblah -> asdfasdf
-rw-r--r-- 1 blah users   14 Nov 25 17:35 greeting
-rw-r--r-- 1 blah users  107 Nov 25 18:06 testingblah

$ file blahblah
blahblah: broken symbolic link to asdfasdf

$ identify-cli blahblah
["symlink"]

$ pre-commit run check-symlinks --all-files
Check for broken symlinks............................(no files to check)Skipped

>>> import os.path
>>> os.path.exists("blahblah")
False
>>> os.path.exists("test")
True
>>>


>>> import os.path
>>> os.path.lexists("blahblah")
True
>>>

File is untracked

$ git status

On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   testingblah

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    test

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .pre-commit-config.yaml
        blahblah

$ pre-commit run check-symlinks --all-files
Check for broken symlinks............................(no files to check)Skipped

File is being tracked
$ git status

On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   blahblah
        modified:   testingblah

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    test

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .pre-commit-config.yaml

Issue still exists even when tracked.

$ pre-commit run check-symlinks --all-files
Check for broken symlinks............................(no files to check)Skipped

@asottile
Copy link
Member

<3 thanks for reporting this so I can link it! I figured this out and fixed it in 2.9.2 -- it regressed in 2.9.0 as part of types_or being implemented

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

No branches or pull requests

2 participants