-
Notifications
You must be signed in to change notification settings - Fork 2.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
Create .gitignore even if inside existing repository cargo new
#6376
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
cargo new
create .gitignore if inside non-cargo vcs repository.cargo new
1f5e21f
to
5bd4fb0
Compare
Thanks for the PR! I'm not really sure I'm quite following what's going on here though. If we didn't detect a git repository why would we then inject a gitignore anyway? Additionally how come the workdir is either one level up from a directory we just created or is the directory itself? I may be a bit lost on the rationale for this... |
Currently fn mk() is being used by both |
This does seem to be a little too special-cased looking at the parent directory. I'm wondering how this can be done in relatively safe way. I'd imagine It may not be worth the complexity, since the workaround (manually updating the ignore file) is quite easy to do. |
Making the root part of |
I'd defer to @ehuss, sounds like a plausible route but perhaps more complicated than updating gitignore |
Oops! Sorry had lost track of this. Will be completing it in a few. Thanks |
a6960c2
to
bfbc8c7
Compare
cargo new
cargo new
Updated! Also, I think we should just update/add the |
There seems to be a regression here. With this PR, every time I run
which seems like unwanted noise. It also doesn't seem to do anything else, which I'm not sure what the intent is here. It might be helpful to write down exactly and very precisely what the desired behavior is. There are many edge cases here, and it seems like it will be easy to cause breakage. |
☔ The latest upstream changes (presumably #6802) made this pull request unmergeable. Please resolve the merge conflicts. |
d434e96
to
9beef34
Compare
Sorry I had missed this. Was introduced after 99a23c0 . I've refactored fn format_existing() to only add paths that are missing instead of commenting out. Also added a description to the PR detailing the changes @ehuss |
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.
Sorry for the delay in the review.
One minor thing, each time I run cargo new
, it adds a blank line to gitignore. Can that be fixed?
src/cargo/util/vcs.rs
Outdated
.stdout; | ||
|
||
// We remove the last new-line character from stdout | ||
stdout = stdout[ .. stdout.len() - 1].to_vec(); |
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 might be a little safer to write as PathBuf::from(root.trim())
instead.
Also, I'm not entire sure I understand the intent or outcome of this change. If you do I guess I still don't understand what the use case is. |
Thanks. Fixed (including the blank line to .gitignore). The intent is; |
I think we explicitly decided in #6245 to not use There would also be the concern that if you are creating new projects inside a workspace, you really don't want anything modified. I think there's a fundamental problem here that |
Fair enough. I guess we should close this for now. |
Creates a VCS .ignore file if it doesn't exist or adds paths to be ignored when the project is created/initialized in an already existing VCS repository.
Fixes #6357