Prevent formatting symlink file - #1144
Conversation
|
I will automatically update this comment whenever this PR is modified
|
| - id: check-added-large-files | ||
| # Check for common mistakes |
There was a problem hiding this comment.
Thanks @ana-sher! It looks like you may have forgotten to skip the yamlfmt hook when you committed your change, but I think that's because you used VSCode to commit this change, rather than making the commit from the command line, where you would be able to specify SKIP.
Can you revert the changes in this file, other than the single line for excluding docs/LICENSE.txt?
There was a problem hiding this comment.
Thank you @chuckwondo, yes, that's exactly what happened 💯 Reverted and fixed by running from the command line.
|
@ana-sher, thanks again for your first contribution! It looks like your branch is out of date with the |
|
Much better :-) I think I found a solution to the yamlfmt issue, if you want to give it a try. It works for me, but that's because I'm running macOS, so if you want to try the following on your Windows machine, that would be great. If it works, I'd like you to add it to this PR so that it is a complete fix for #1143. Please do the following: First, create a file named """Helper script that automatically skips the yamlfmt pre-commit hook on Windows.
This is not intended to be called directly. It is configured to be called by
pre-commit via the configuration in .pre-commit-config.yml for the yamlfmt hook.
Due to https://github.com/google/yamlfmt/issues/263, comments in yaml files are
not handled properly under Windows, so any Windows user that causes yamlfmt to
format yaml files will cause CI build failure because we build under Linux, and
the resulting format will differ, causing file changes during the pre-commit
step, causing build failure.
Therefore, this script avoids calling yamlfmt (via pre-commit) when running on
Windows.
"""
import platform
import subprocess
import sys
if platform.system() != "Windows":
sys.exit(subprocess.call(["yamlfmt", *sys.argv[1:]]))Then, modify the - repo: https://github.com/google/yamlfmt
rev: v0.20.0
hooks:
- id: yamlfmt
entry: python scripts/yamlfmt.py
types_or: [yaml]
exclude: ".*/vcr_cassettes/.*\\.yaml"Notice that I've added Once you've added the new script and modified the pre-commit config, try running |
…-sher/earthaccess into 1143-pre-commit-hook-win-bug
|
It is a good way to solve it until google/yamlfmt#263 will be fixed! Worked as intended on my Windows machine, thank you @chuckwondo , added script to the PR. |
Fantastic! I'm glad that works. I think the only thing left to do is add an entry to CHANGLOG.md indicating your contribution! Under the "Unreleased" heading (near the top of CHANGELOG.md), there is a "Fixed" subheading. Please add the following item for your fix: cc: @danielfromearth |
|
Done ✅ Thanks a lot for the mentoring on my first contribution, @chuckwondo! |
chuckwondo
left a comment
There was a problem hiding this comment.
Awesome @ana-sher! Happy to welcome you as a new contributor!
@danielfromearth, since you were on the call too when we started debugging this, do you have any additional comments?
|
I think this looks great. The entry script is a clever way handle the issue! If/when |
I've subscribed to the yamlfmt issue, so I'll get notified of any future activity on the thread. If you want to do the same, then at least a few of us will see if/when it gets resolved. If/when the yamlfmt issue if fixed, we can then open an issue to remove this newly added script along with the |
|
Sounds good to me. I just now subscribed to that issue thread too 👀 |
Prevent fixing symlink file
resolves #1143 LICENSE.txt fixing issue with end-of-file-fixer hook on Windows
📚 Documentation preview 📚: https://earthaccess--1144.org.readthedocs.build/en/1144/