Skip to content

Add test for detached HEAD discovery, run unit tests for gix-discover and add archives - #3038

Open
Christoph Rüßler (cruessler) wants to merge 1 commit into
GitoxideLabs:mainfrom
cruessler:run-gix-discover-tests
Open

Christoph Rüßler (cruessler) wants to merge 1 commit into
GitoxideLabs:mainfrom
cruessler:run-gix-discover-tests

Conversation

@cruessler

Copy link
Copy Markdown
Contributor

This PR is the result of a search by GPT 5.5/6.0 (I don’t remember which one) for places where calling Default::default() for gix_hash::Kind could result in subtle errors. The code was already working as expected, so this commit only adds the appropriate regression test.

More specifically, this PR adds a test for the assertion in the comment to is_git. In this line, we create a gix_hash::Kind via Default::default(). The test makes sure discovery works for both SHA-1 as well as SHA-256 detached HEADs.

This PR also adds generated SHA-256 archives for gix-discover. It also adds gix-discover to the unit-tests section of justfile.

Sebastian Thiel (@Byron) If there’s a specific reason gix-discover tests are not run under unit-tests, feel free to remove this part. Also, the added test is quite pedantic, but the fact that this is what the LLM finds when asked for potential issues related to assuming SHA-1 as the default make me more confident that gix most likely does not have larger issues left. Whatever the case, I’ll try and keep polishing this area as best as I can. 😉

This commit is the result of a search by GPT 5.4/6.0 (I don’t remember
which one) for places where calling `Default::default()` for
`gix_hash::Kind` could result in subtle errors. The code was already
working as expected, so this commit only adds the appropriate regression
test.

More specifically, this commit adds a test for the assertion in the
comment to [is_git]. In this line, we create a `gix_hash::Kind` via
`Default::default`. The test makes sure discovery works for both SHA-1
as well as SHA-256 detached HEADs.

[is_git]: https://github.com/cruessler/gitoxide/blob/8f1280faf8dcabcfd967ee004a466f8b473b9b4f/gix-discover/src/is.rs#L72

This commit also adds generated SHA-256 archives for `gix-discover`. It
also adds `gix-discover` to the `unit-tests` section of `justfile`.

Assisted-by: GPT 6.0
@cruessler
Christoph Rüßler (cruessler) marked this pull request as ready for review October 2, 2026 19:45
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.

1 participant