Skip to content

fix(init): append newline to .gitignore if missing - #7122

Open
ravindra-RKB wants to merge 2 commits into
prefix-dev:mainfrom
ravindra-RKB:fix-init-gitignore-newline
Open

ravindra-RKB wants to merge 2 commits into
prefix-dev:mainfrom
ravindra-RKB:fix-init-gitignore-newline

Conversation

@ravindra-RKB

Copy link
Copy Markdown

Description

Fixes an issue where pixi init appends .gitignore entries to the last line without a newline, which can break the user's existing last ignore rule (Fixes #7120).
Added a check to ensure that a newline is prepended if the existing .gitignore doesn't end with one.

Checks

  • I have checked that this pull request has not already been reported.
  • I have added tests to verify that the bug is fixed.
  • I have formatted my code using cargo fmt and pixi run lint.

Reproducible example

cd "$(mktemp -d anyname.XXXXX)"
printf 'data/' > .gitignore
pixi init
cat .gitignore

Before:

data/# pixi environments
.pixi/*
!.pixi/config.toml

After:

data/

# pixi environments
.pixi/*
!.pixi/config.toml

This PR doesn't contain AI-generated content.

@ravindra-RKB
ravindra-RKB force-pushed the fix-init-gitignore-newline branch from 2750753 to 08c6375 Compare September 30, 2026 11:15

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

pixi init appends environment rules to existing .gitignore without a leading newline, breaking the previous last line

1 participant