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

editorconfig-checker inspects .git by default and fails #268

Open
bizrad opened this issue May 15, 2023 · 4 comments
Open

editorconfig-checker inspects .git by default and fails #268

bizrad opened this issue May 15, 2023 · 4 comments
Labels
bug a bug which occured help wanted

Comments

@bizrad
Copy link

bizrad commented May 15, 2023

The tool is now inspecting .git directories and failing. It seems like the self checks you have in CI might need to be updated here as well as this fails for this repo with the current config.

Steps to reproduce

git clone https://github.com/editorconfig-checker/editorconfig-checker.git
cd editorconfig-checker
git checkout tags/2.4.0
docker run --rm --volume=$PWD:/check mstruebing/editorconfig-checker:2.4.0
# WORKS
git checkout tags/2.7.0
docker run --rm --volume=$PWD:/check mstruebing/editorconfig-checker:2.7.0
# FAILS
.git/config:
	2: Wrong amount of left-padding spaces(want multiple of 4)
	3: Wrong amount of left-padding spaces(want multiple of 4)
	4: Wrong amount of left-padding spaces(want multiple of 4)
        ....continued
@sanmai-NL
Copy link

Relevant #273, since Git config properties can be set from the command line and these config files are being generated by Git to a varying extent.

@mstruebing mstruebing added bug a bug which occured help wanted labels Jun 20, 2023
@polarathene
Copy link
Contributor

Provided you volume mount to /check dir as instructed, this has been resolved with 2.7.1.

@dmohns
Copy link

dmohns commented Nov 23, 2023

Hey,

I see this issue being resolved in the 2.7.1 of the Docker. But what to do if we run editorconfig-checker outside of Docker? I.e. in my CI (Github Actions) I simply pipx install "editorconfig-checker".

On the runner

ec .
.git/index:
        Not all lines have the correct end of line character

fails. But running

docker run --rm --volume=$PWD:/check mstruebing/editorconfig-checker

succeeds.

@polarathene
Copy link
Contributor

polarathene commented Nov 25, 2023

I see this issue being resolved in the 2.7.1 of the Docker.

Resolved as in.. it had been already working in the Docker image until git was updated with a new safety feature that broke future releases of the EC Docker image.

Thus the published image for EC 2.7.1 release includes a fix for that git issue - by adding an exception for the /check mount path (documented in the README):

# Prevent the git error that triggered EC fallback behaviour:
# https://github.com/editorconfig-checker/editorconfig-checker/pull/265
# Only works when running EC from this location, which the project should be volume mounted to:
git config --global --add safe.directory /check

I simply pipx install "editorconfig-checker"

Right, so chances are you may be experiencing this issue which occurs if you do not have git installed in your environment.

EC then has some fallback logic, but is unaware of .git/ being special (not part of the default excludes) so you'd need to add an explicit ignore yourself with a .ecrc config (or use the --exclude arg with a regex: ec --exclude '\.git/'):

{
  "IgnoreDefaults": false,
  "Exclude": [
    "\\.git/"
  ]
}

NOTE: The . needs to be escaped since it's a regex pattern and that would otherwise match any char. The / is also provided to be more explicit with matching a valid directory path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug which occured help wanted
Projects
None yet
Development

No branches or pull requests

5 participants