Skip to content

Conversation

@rtyley
Copy link
Owner

@rtyley rtyley commented Sep 17, 2025

The unpackRepo() method is very useful for setting up example repo fixtures for testing - it unzips zipped git archives on the resource classpath, and returns us the JGit repository. However, loading resources from the classpath (while convenient, meaning we don't need to worry about the absolute location on the filesystem of the zip file) can also be temperamental, with the resource not being found if it's not within the same classloader as the class of com.madgag.git.test.

It seems the most reliable way to be able to find our test resources is to specify which class we want to search the classpath of when we search for the resource. From there, we can get an unambiguous path for the resource that can be used by unpackRepo().

…ource

The `unpackRepo()` method is very useful for setting up example repo fixtures for
testing - it unzips zipped git archives on the resource classpath, and returns us
the JGit repository. However, loading resources from the classpath (while convenient,
meaning we don't need to worry about the absolute location on the filesystem of the
zip file) can also be temperamental, with the resource not being found if it's not
within the same classloader as the class of `com.madgag.git.test`.

It seems the most reliable way to be able to find our test resources is to specify
_which_ class we want to search the classpath of when we search for the resource. From
there, we can get an unambiguous path for the resource that can be used by
`unpackRepo()`.
@rtyley rtyley marked this pull request as ready for review September 17, 2025 13:10
@rtyley rtyley merged commit b7ea5ec into main Sep 17, 2025
1 check passed
@rtyley rtyley deleted the tweak-for-resource-classpath-problems branch September 17, 2025 13:10
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