Skip to content

cargo init - check .gitignore before appending /target #12306

Closed as not planned
Closed as not planned
@Mirch

Description

@Mirch

Problem

When running cargo init in an existing git repository, cargo adds a /target line to .gitignore, regardless of whether that line is already present.

Proposed Solution

After checking if the .gitignore file exists, scan the lines to search for a /target, target/ or */taget line.

Notes

cargo -vV output:

cargo 1.68.0 (115f34552 2023-02-26)
release: 1.68.0
commit-hash: 115f34552518a2f9b96d740192addbac1271e7e6
commit-date: 2023-02-26
host: aarch64-apple-darwin
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.79.1 (sys:0.4.59+curl-7.86.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 12.5.1 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions