-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix(publish): make include and exclude work #22720
Conversation
I'm working on updating deno-docs with this information. |
@@ -1095,7 +1095,15 @@ impl Config { | |||
continue; | |||
}; | |||
let settings = self.workspace_settings_for_specifier(workspace_uri); | |||
if settings.enable.unwrap_or_else(|| self.has_config_file()) { |
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.
@nayeemrmn this previous condition seemed slightly wrong and caused some trouble in the tests. Is the new condition ok?
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.
Ah good find, but if enable_paths
is specified then it should completely override enable
.
if settings.enable_paths.as_ref().map(|p| !p.is_empty()).unwrap_or_else(|| previous_condition) { ... }
let dir_path = if is_dir { &c } else { c.parent()? }; | ||
git_ignores.get_resolved_git_ignore(dir_path) | ||
}); | ||
if !is_pattern_matched( |
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 whole for loop + loop is super hard to grasp. Consider rewriting to use if
+ continue
, but not a blocker to land
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'm going to leave the code as-is for now because doing that is a riskier refactor.
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.
Is this whole module added just to support testing gitignore functionality? 😬 If so consider making it only available in cfg(test)
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.
Can't make it #[cfg(test)] because then it can't be used outside this crate. I think this will just be optimized away when compiling?
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.
Hm... Since the trait it implements is public maybe move it to the gitignore module?
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 it would be useful in the future for non-CLI crates and Deploy for testing purposes.
@@ -0,0 +1,424 @@ | |||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. | |||
|
|||
#![allow(clippy::disallowed_types)] |
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.
Are there many of them? Maybe leave a comment about this directive usage.
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'm going to add a comment on this. It's just to use Arc
, which is fine for this module.
The behaviour of |
@ghostdevv there are so many scenarios with what files should be matched or not. For example, someone might specify the Also, another point is that That said, and as you allude to, directories or files (non-globs) in the |
1. Stops `deno publish` using some custom include/exclude behaviour from other sub commands 2. Takes ancestor directories into account when resolving gitignore 3. Backards compatible change that adds ability to unexclude an exclude by using a negated glob at a more specific level for all sub commands (see denoland/deno_config#44).
I expect that using The situation I encountered is that the Is there a way to completely override cd pkg
npx jsr publish --dry-run # pkg/.gitignore
* # pkg/.npmignore
*.tgz {
"exclude": []
} |
Oh, that's strange. The negation should work, but it looks like it doesn't. Seems like it only works if I explicitly specify the files or directories at the top level. I'm looking into it. |
@magic-akari ok, so the reason it occurs in that scenario is because the Also, you'll probably want to use |
#22805) This is an unrealistic scenario, but it's still a good thing to fix and have a test for because it probably fixes some other underlying issues with how the gitignore was being resolved for the root directory. From #22720 (comment)
@dsherret that makes a lot of sense thanks! It's for sure a complicated problem and this is probably the nicest solution |
#22805) This is an unrealistic scenario, but it's still a good thing to fix and have a test for because it probably fixes some other underlying issues with how the gitignore was being resolved for the root directory. From #22720 (comment)
deno publish
using some custom include/exclude behaviour from other sub commandsInclude only
deno/
folderThis respects the ignored files in the gitignore:
Include all files except
dist/
folderThis respects the ignored files in the gitignore:
Include a file/directory that's excluded at the top level
Include a file/directory that's excluded in a gitignore
Include all files except the
dist/
folder, but do includedist/js/
Closes #22648
Closes #22656
Closes #22482
Closes jsr-io/jsr#194