-
-
Notifications
You must be signed in to change notification settings - Fork 128
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect .git/info/exclude in addition to .gitignore #613
Comments
Thanks @weilbith! I didn't know about For now, you could consider using a dynamic |
Wow, that was a fast reply! 馃槺 Ah, cool. That actually sounds like a sound idea! In case someone stumbles across this issue and it is not (yet) implemented upstream, here is my version of adding it to my import { readFile } from "fs/promises";
import type { KnipConfig } from "knip";
// TODO: Remove once feature was implemented upstream.
async function readGitInfoExcludePatterns(): Promise<string[]> {
const buffer = await readFile(".git/info/exclude");
return buffer
.toString("utf-8")
.split(/\r\n|\r|\n/)
.filter((line) => !!line.trim())
.filter((line) => !line.startsWith("#"))
.map((line) => (line.endsWith("/") ? `${line}**` : line));
}
export default async function composeConfiguration(): Promise<KnipConfig> {
const gitInfoExcludePatterns = await readGitInfoExcludePatterns();
return {
ignore: [
...gitInfoExcludePatterns,
// ... more patterns
],
// ... more configuration
};
} |
Thanks for sharing your solution! Feel free to give this a shot. That part of the code is here: https://github.com/webpro/knip/blob/main/packages/knip/src/util/globby.ts#L59 |
Hui, that's a function 馃槃 |
Maybe you could consider something like moving everything inside the |
@weilbith Is this still something you fancy picking up? I have absolutely no hurries with this one, just checking up. |
@webpro I'm theoretically up for it. Just the typical excuse that I'm more than busy right now. Just became father and don't have the time anymore to do such things in my free time anymore. Sorry. 馃槙 |
馃殌 This issue has been resolved in v5.14.0. See Release 5.14.0 for release notes. Using Knip in a commercial project? Please consider sponsoring me. |
Thanks @weilbith! Wishing you good health for everyone 鉂わ笍 |
Thank you so much! My configuration just got more lean. 馃槉 |
Hey 馃憢馃従
Thank you very much for this nice tool! It is great to see how it develops.
A problem I stumble over is the ignoring of developer local files. So I usually have a few files I don't want to be checked-in to the VCS, but as it is a "personal" thing, I add them to
.git/info/exclude
(see documentation) rather than polluting the shared.gitignore
file. As knip already respects the.gitignore
file, it would be amazing if it could to the same for the.git/info/exclude
file too. As I don't wanna add these ignore patterns to.gitignore
I don't wanna add them to knip it'signore
configuration either.Right now I always have issues because knip complains in my git hooks and I can't rely on your amazing autofixing.
Happy to discuss this idea further. 馃檭
Thanks in advance!
The text was updated successfully, but these errors were encountered: