-
Notifications
You must be signed in to change notification settings - Fork 712
Allow directories in cabal data-files (#713) #1344
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
Conversation
This commit adds the capability to specify a whole directory which contains data-files in a project's .cabal file. If a data-files entry ends with a slash, like "static/", then it will pull in all files under the directory named "static/". Notes: * This has only been tested by calling matchDirFileGlob in GHCi. * I'm not sure about the name (data FileGlob = DirTrailingSlash -- perhaps it should have Glob on the end like the others?) but I've been unable to come up with anything better.
refs #713 |
@@ -725,6 +730,9 @@ matchDirFileGlob dir filepath = case parseFileGlob filepath of | |||
[] -> die $ "filepath wildcard '" ++ filepath | |||
++ "' does not match any files." | |||
matches -> return matches | |||
Just (DirTrailingSlash dir') -> | |||
let contents = getDirectoryContentsRecursive (dir </> dir') |
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 that the original idea with this feature was to add only a limited form of globbing and explicitly disallow including directories recursively because it makes it easy to include unwanted files.
Alternatively, we could use
|
Ah yes, I think I prefer the zsh syntax; it seems to fit with the other types of globs better, since they refer to files, or groups of files, and not directories. I'll wait until the spec is better defined ;) |
Another one to consider: |
What's the status of this? Are you waiting for a code review? |
I was waiting for the spec to become a bit clearer. Currently I'm not sure how this is feature is supposed to behave, or even if it's wanted at all. |
I vote for using the We could start by allowing @dcoutts, what do you think? |
Lets not get bogged down on syntax too much. Can we just pick the most commonly used one and stick with that? I'm not terribly worried that people will glob too much. |
What do you mean by most commonly used? The first thing that comes to mind when I hear 'globbing' is bash. With that in mind, I'd propose that:
I think the the inconvenience of restricted globbing outweighs the benefit of reducing the risk of accidental file inclusions. It seems very unlikely that people would include sensitive data in public cabal project directories -- and so it also seems reasonable to claim that any accidentally included files would only be a minor inconvenience to users downloading a source distribution. Here's a real use case: Currently I'm writing something which has to change its behaviour based on a file extension (https://github.com/hdgarrood/herringbone). Therefore, the tests have all kinds of data files with weird extensions, and the current behaviour makes including these in source distributions more difficult than it needs to be. |
I'm fine with bash globbing. |
I didn't know bash had that feature. New in 4.0 with a thing to enable it. Yes, we need to do something about the massive .cabal files people are creating because of the inability to concisely specify files to include. I'm happy with any reasonable & consistent syntax (so long as it is itself consistent with our existing syntax). Assuming bash style glob syntax fits that criteria then I'm happy with that. Since it's new syntax we also have to check what older versions of Cabal do when they encounter it. We may have to only allow the new syntax with a cabal-version check. |
Ok, so the proposal for bash style globbing is separate to this, so shall I do some work on it and open another PR? |
Bash style globbing would also subsume #1343 I think |
Closing in favour of #2522. |
This commit adds the capability to specify a whole directory which
contains data-files in a project's .cabal file.
If a data-files entry ends with a slash, like "static/", then it will
pull in all files under the directory named "static/".
Notes:
perhaps it should have Glob on the end like the others?) but I've been
unable to come up with anything better.