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

nix-gitignore: filter-out .git #94960

Merged
merged 1 commit into from Dec 10, 2020
Merged

Conversation

symphorien
Copy link
Member

fixes #94959

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@@ -98,7 +98,7 @@ in rec {
let
onPath = f: a: if typeOf a == "path" then f a else a;
str_patterns = map (onPath readFile) (lib.toList file_str_patterns);
in concatStringsSep "\n" str_patterns;
in ".git\n" + (concatStringsSep "\n" str_patterns);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it indeed makes some sense to add .git to the default filters for gitignoreSource.

This doesn't seem to be the right place to put this default value to me, though:

The 2 documented entry points for nix-gitignore are gitignoreSource and gitignoreSourcePure. They both call gitignoreFilterSourcePure, but gitignoreSource adds .gitignore to the parameters (via withGitignoreFile), while gitignoreSourcePure does not.

To be consistent I think it the additional default .git ignore should only be added to gitignoreSource, and gitignoreSourcePure should remain 'pure'. So I think .git should be added to withGitignoreFile (perhaps renamed to withDefaults or something?) instead of gitignoreCompileIgnore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My rationale was: "gitignoreSource works like git and gitignoreSourcePure like git in a repo where there is no .gitignore". What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit strange when there actually is a .gitignore present in that directory, though, right?

To me the interpretation 'gitignoreSource has defaults to work like git and gitignoreSourcePure gives you complete control' makes more sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok makes sense, I changed the PR to only affect the non pure variant.

@symphorien
Copy link
Member Author

cc @siers as original author ?

@siers
Copy link
Member

siers commented Nov 8, 2020

Go for it. :)

pkgs/build-support/nix-gitignore/default.nix Show resolved Hide resolved

withRecursiveGitignoreFile = patterns: root:
lib.toList patterns ++ [(compileRecursiveGitignore root)];
lib.toList patterns ++ [ ".git" ] ++ [(compileRecursiveGitignore root)];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it makes sense like this 👍

@siers
Copy link
Member

siers commented Nov 12, 2020 via email

@siers
Copy link
Member

siers commented Nov 12, 2020 via email

@symphorien
Copy link
Member Author

How did you test it?

See the reproduction steps of the linked issue

I assume you know, but the nix-gitignore in siers/nix-gitignore has the
.git pattern added and it seems to be working judging by no issues filed
about this.

No, I did not know siers/nix-gitignore existed before opening this PR. Anyway I'd like to keep using the one in nixpkgs.

@symphorien
Copy link
Member Author

@GrahamcOfBorg eval

@symphorien symphorien merged commit 4eb94d0 into NixOS:master Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nix-gitignore does not ignore .git
3 participants