Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 26, 2025

git commit -am only stages tracked files, so newly created CHANGELOG.md files were not included in release commits.

Changes Made

  • src/command/release/git.rs: commit_changes() now accepts a list of changelog paths, checks the git index internally to determine which ones are untracked, and runs git add -- on them before git commit -am
  • src/command/release/manifest.rs: Collect all changelog paths before they are consumed and pass them to commit_changes()

Implementation Details

  • Use ctx.repo.open_index() to access the git index
  • Get worktree path with repo.workdir()
  • Convert absolute paths to worktree-relative paths with forward slashes using gix::path::to_unix_separators(gix::path::into_bstr())
  • Use index.entry_by_path() to check if a file is tracked in the index
  • Only run git add for paths that are not in the index

Testing

  • All existing tests pass
  • Clippy linter passes
Original prompt

See if CHANGELOG.md, once changed, can be added to Git if it is untracked. It can definitely update it when it's tracked already, as it creates a commit with changed changelog files.
The question is if it can add new files, and it seems that's not the case.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@Byron
Copy link
Member

Byron commented Nov 26, 2025

Related to #5

Copilot AI changed the title [WIP] Verify if untracked CHANGELOG.md can be added to Git Add untracked CHANGELOG.md files to git before commit Nov 26, 2025
Copilot AI requested a review from Byron November 26, 2025 05:49
Copilot finished work on behalf of Byron November 26, 2025 05:49
@Byron
Copy link
Member

Byron commented Nov 26, 2025

@copilot Instead of checking for existence of files at lock-acquisition time, check for the presence of the file in the git index instead. Note that the lookup requires a worktree-relative slash-separated path, and gix::path::* has a function for the conversion, but you have to figure out how to get the worktree-relative path.

Copy link
Contributor Author

Copilot AI commented Nov 26, 2025

@copilot Instead of checking for existence of files at lock-acquisition time, check for the presence of the file in the git index instead. Note that the lookup requires a worktree-relative slash-separ...

Changed to check the git index instead of file existence. In commit f49d22f:

  • Use ctx.base.repo.open_index() to access the index
  • Get worktree path with repo.workdir()
  • Convert absolute path to worktree-relative path with forward slashes using gix::path::to_unix_separators(gix::path::into_bstr(relative_path))
  • Check if path is tracked with index.entry_by_path(relative_path_unix.as_bstr())

Copilot finished work on behalf of Byron November 26, 2025 07:26
@Byron
Copy link
Member

Byron commented Nov 26, 2025

@copilot This git index check should be done at the time when it decides if git add needs to be called. This allows to completely avoid that new struct that was introduced.

Copy link
Contributor Author

Copilot AI commented Nov 26, 2025

@copilot This git index check should be done at the time when it decides if git add needs to be called. This allows to completely avoid that new struct that was introduced.

Moved the git index check to commit_changes() where git add is called. Removed the CommitLocksOutcome struct and restored commit_locks_and_generate_bail_message() to return Option<String>. In commit b977b5a.

Copilot finished work on behalf of Byron November 26, 2025 08:25
Previously it would fail if the changelogs were new,
now we auto-add it if it's not yet tracked.

Co-authored-by: Byron <[email protected]>
@Byron Byron force-pushed the copilot/check-changelog-untracked branch from b977b5a to 45d1be9 Compare November 27, 2025 05:30
@Byron Byron marked this pull request as ready for review November 27, 2025 05:30
- carog fmt
@Byron Byron force-pushed the copilot/check-changelog-untracked branch from 45d1be9 to 10c7a3e Compare November 27, 2025 05:50
@Byron Byron merged commit 67e1743 into main Nov 27, 2025
12 checks passed
@Byron Byron deleted the copilot/check-changelog-untracked branch November 27, 2025 06:39
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.

2 participants