Skip to content
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

cargo new --template ignores/replaces/overwrites .gitignore #3859

Closed
ssokolow opened this issue Mar 23, 2017 · 6 comments
Closed

cargo new --template ignores/replaces/overwrites .gitignore #3859

ssokolow opened this issue Mar 23, 2017 · 6 comments

Comments

@ssokolow
Copy link

ssokolow commented Mar 23, 2017

While investigating another flaw in --template, I discovered the following undesired behaviour when generating a test project from my boilerplate for CLI utilities:

diff -u -ur ../rust-cli-boilerplate/.gitignore ./.gitignore
--- ../rust-cli-boilerplate/.gitignore  2017-03-09 13:33:13.345285768 -0500
+++ ./.gitignore        2017-03-23 11:41:35.619386304 -0400
@@ -1,2 +1,3 @@
-/callgrind.out.justfile
-/target
+target/
+**/*.rs.bk
+Cargo.lock

While I admit I forgot to exclude *.rs.bk, the rest is unhelpful.

What's worse is that I don't see how this actually helps anything, given that, for a project template, there isn't really much of a purpose to .gitignore outside of being passed on to the generated projects. (It's not as if the template's Cargo.toml is valid TOML before the placeholder for the author list gets substituted.)

You'll also notice that it's adding Cargo.lock to the .gitignore when this is specifically intended as --bin project template, not a --lib one, so that's not helpful either.

I think a proper solution would be to only generate a .gitignore if none is present in the template

As-is, I'm forced to go back to what I used before... a wrapper script.

@ssokolow ssokolow changed the title cargo new --template overwrites .gitignore cargo new --template ignores/replaces/overwrites .gitignore Mar 23, 2017
@ssokolow ssokolow changed the title cargo new --template ignores/replaces/overwrites .gitignore cargo new --template ignores/replaces/overwrites .gitignore Mar 23, 2017
@alexcrichton
Copy link
Member

cc @ehiggs @gchp

@ehiggs
Copy link
Contributor

ehiggs commented Mar 24, 2017

If I understand correctly, your template has a .gitignore but it wasn't used by cargo new and some other .gitignore was generated. And the expected behaviour is that it should use the .gitignore from your template verbatim. Makes sense to me.

@ssokolow
Copy link
Author

Yes, that's correct.

The template contains a .gitignore which ignores the target folder and the temporary file used by my justfile for passing profiles from callgrind to kcachegrind.

cargo new instead populates new projects with a .gitignore which ignores target, *.rs.bk, and Cargo.lock. (The latter being a problem because not all templates are going to be --lib templates.)

@alexcrichton
Copy link
Member

Yeah makes sense to me as well to use the .gitignore from templates over the built-in one, thanks for the report @ssokolow!

bors added a commit that referenced this issue Mar 31, 2017
…richton

Revert template until after rfc

As discussed in #3860, templates was merged without going through the RFC process. @ssokolow has raised some useful comments which need to be settled before the template system can be put back in.

#3859 was another relevant issue.
@ehiggs
Copy link
Contributor

ehiggs commented Apr 11, 2017

Templates have been removed pending an RFC. There is a pre-RFC thread here. I think this can be closed for now.

@alexcrichton
Copy link
Member

Thanks @ehiggs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants