-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add support for automatically gitignoring generated files #157
base: main
Are you sure you want to change the base?
Conversation
b867aee
to
9e8506c
Compare
Running `nix run .\#regenerate-files` now generates files locally according to the `files` option in `project.ncl`. This is still rather crude in a number of ways, but it is already working (and used to generate this project's own `.gitignore`). Fixes #144
Add a light `gitignore` abstraction allowing to define a set of gitignore patterns from Nickel, and plug that in to the file generation interface so that a generated file can also be git ignored by simply setting `files.foo.gitignore = true`
9e8506c
to
2b7ebe9
Compare
@@ -0,0 +1,52 @@ | |||
# let nix = import "./nix-interop/nix.ncl" in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# let nix = import "./nix-interop/nix.ncl" in |
: Bool | ||
| doc "Whether to gitignore the file" | ||
| default | ||
= false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that each generated file will be added to .gitignore
in one way or another. I think we should have a default option here that doesn't add it to .gitignore
at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No they aren't, the ones with gitignore = true
are filtered out here.
But that indeed makes some slightly confusing semantics as it means that files.foo.gitignore
has a different semantics than git.ignore."/foo"
.
|> std.array.map (fun { value = { target, .. }, .. } => { field = target, value = true }) | ||
|> std.record.from_array | ||
in | ||
let gitignore_content | { _ : Bool } -> String = fun ignores => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these functions should be in the final record so that users can add more .gitignore
files to their repos.
fun pattern is_ignored => | ||
"%{if is_ignored then "" else "!"}%{pattern}" | ||
) | ||
|> std.record.values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should somehow provide a way to order these lines, because order is important in .gitignore
# let nix = import "./nix-interop/nix.ncl" in | ||
let filegen = import "./files.ncl" in | ||
let Gitignorable = { | ||
gitignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be nested like git.ignore
in case we want to add, for example, .gitattributes
support.
Add a light
gitignore
abstraction allowing to define a set of gitignore patterns from Nickel, and plug that in to the file generation interface so that a generated file can also be git ignored by simply settingfiles.foo.gitignore = true