summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorGuillaume Girol <symphorien@users.noreply.github.com>2021-07-22 16:18:10 +0000
committerGitHub <noreply@github.com>2021-07-22 12:18:10 -0400
commitf98bc23805c5956314f0c0359794225a2557088f (patch)
tree31b48f7d84632f3743639687de08c874b27c7e02 /pkgs/build-support
parentf81f71591399b64ffe0c7002042078bd0a7b2192 (diff)
downloadnixpkgs-f98bc23805c5956314f0c0359794225a2557088f.tar
nixpkgs-f98bc23805c5956314f0c0359794225a2557088f.tar.gz
nixpkgs-f98bc23805c5956314f0c0359794225a2557088f.tar.bz2
nixpkgs-f98bc23805c5956314f0c0359794225a2557088f.tar.lz
nixpkgs-f98bc23805c5956314f0c0359794225a2557088f.tar.xz
nixpkgs-f98bc23805c5956314f0c0359794225a2557088f.tar.zst
nixpkgs-f98bc23805c5956314f0c0359794225a2557088f.zip
nix-gitignore: fix evaluation when .gitignore contains \# or \! (#130643)
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/nix-gitignore/default.nix5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkgs/build-support/nix-gitignore/default.nix b/pkgs/build-support/nix-gitignore/default.nix
index 5d7b945bf1b..497dcb0660b 100644
--- a/pkgs/build-support/nix-gitignore/default.nix
+++ b/pkgs/build-support/nix-gitignore/default.nix
@@ -41,6 +41,9 @@ in rec {
         let split = match "^(!?)(.*)" l;
         in [(elemAt split 1) (head split == "!")];
 
+      # regex -> regex
+      handleHashesBangs = replaceStrings ["\\#" "\\!"] ["#" "!"];
+
       # ignore -> regex
       substWildcards =
         let
@@ -86,7 +89,7 @@ in rec {
       mapPat = f: l: [(f (head l)) (last l)];
     in
       map (l: # `l' for "line"
-        mapPat (l: handleSlashSuffix (handleSlashPrefix (mapAroundCharclass substWildcards l)))
+        mapPat (l: handleSlashSuffix (handleSlashPrefix (handleHashesBangs (mapAroundCharclass substWildcards l))))
         (computeNegation l))
       (filter (l: !isList l && !isComment l)
       (split "\n" gitignore));