-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Block publishing on dirty directories #2714
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
} | ||
|
||
fn check_directory_cleanliness(config: &Config) -> CargoResult<()>{ | ||
let allow_dirty = try!(config.get_bool("publish.allow_untracked_changes")) |
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 may actually be best configured via a command line flag perhaps? I suspect that this flag would be passed in one-off situations rather than blanket configured for the whole system
Thanks @sbeckeriv! Looking good to me! |
dac311a
to
9f20a9f
Compare
Updated with the changes. I think there is an edge case with open_ext. I believe you can run
run cargo publish from sub project it will catch the level 1 git repo current. I don't know why someone would have this setup. Its just a thought. Trying to open the git repository is the best thing I can think to check for the version control system at this time. Also the flag will still allow you to publish. Thanks again. |
let pkg = try!(Package::for_path(&manifest_path, config)); | ||
|
||
if !allow_untracked{ |
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.
Stylistically a space typically comes before the {
here (also a few other places in this diff)
9f20a9f
to
dd3995a
Compare
that need to be addressed before publishing. to force the publish command \ | ||
include --allow-untracked\nproblem files:\n{}", num, files.join("\n")))) | ||
} | ||
} |
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 can probably just be:
if !files.is_empty() {
bail!("...");
}
Ok(())
☔ The latest upstream changes (presumably #2722) made this pull request unmergeable. Please resolve the merge conflicts. |
75b92bc
to
d6184b7
Compare
Dearest reviewer, This is part of rust-lang#841 which is about the publishing and tagging flow. This pull request just prevents publishing with uncommitted or untracked files. I have included a flag for turning this off. There are two new test. More details about the full flow at rust-lang#2443 . I plan on doing more work on the flow, however, I felt this was useful enough to do stand alone. When I tried the flow before I was doing to much at once. Thanks! Becker [Updated] Moved from config to flag Using open_ext to sub crates Include the file names in error message include flag in error Move to discover off of open_ext formatting cut back on unwraps rework file check logic with a bail
Cargo should be orthogonal to the version control system 😠 |
@tomaka I'd personally at least find it a little more helpful if you could be more constructive in your criticism as well, as blanket stating "cargo should be orthogonal" isn't too actionable. Do you have specific concerns that you'd like to see addressed? In general Cargo should indeed not worry about an underlying version control system, but that also doesn't mean that it should ignore it entirely. Cargo strives to recognize the underlying VCS to make workflows much more ergonomic in aspects like:
In each of these situations Cargo doesn't need to have a VCS or require something like git, it simply recognizes that git exists and attempts to infer as much from git as possible. This enables many more "zero configuration" use cases of Cargo where it all just works without having to do much. Cargo is explicitly designed to support more than one VCS as well, it just so happens that work has only been done so far to work with git, not others like mercurial. |
@alexcrichton I just brought up this point here without arguing since it has already been discussed in the workspace RFC. The problem when you assume that the user does someone in a specific way is that it breaks horribly and in an unpredictable way when people use for example git differently than how it was supposed to be used. Tools that try to be smarter than the programmer tend to be annoying as soon as you try to do something slightly different than what's expected. For example what if for some reason I write a script that applies a patch, then runs cargo publish, then reverts the change? Does that meant that the script will now have to create a commit, then publish, then revert the commit? What will the person who wrote the script think of this PR? The follow-up is that at least the exact behavior of each command should be documented. If |
@tomaka yes it's possible for what we infer to be wrong, and that's why there's always an escape hatch. For example an |
I am closing this until I learn more about git2. Someone can pick it up it up if they like. Sorry |
Dearest reviewer,
This is part of #841 which is about the publishing and tagging flow.
This pull request just prevents publishing with uncommitted or untracked
files. I have included a flag for turning this off. There are two new
test and I have also updated the docs.
More details about the full flow at
#2443 . I plan on doing more
work on the flow, however, I felt this was useful enough to do stand
alone. When I tried the flow before I was doing to much at once.
closes #1597
Thanks!
Becker