Git Stratum
Stratum: A single layer of something - Cambridge Dictionary.
A library that lets you anlayse your repository one strata at a time, leveraging a higher level API than git2-rs analysing your repository is simple!
Quick Start
First add stratum to your dependencies.
Then inside of your main function:
use open_repository;
let repo = open_repository.unwrap;
for commit in repo.traverse_commits.unwrap
Note that the API is liable to change up until version 1.0.0.
For more detail on the API, see the docs.
Testing
Unit Testing
In /src/lib.rs a test specific module called common is defined, in here a git2 reposiotry is lazilly made for testing purposes. This method for unit testing was chosen for several reasons:
- Mocking
git2objects would be very challenging as they do not expose any traits. - Lazilly constructing this repository ensures it is only made once per unit testing module.
- This allows for the direct testing of private functions with minimal overhead/difficulty.
Example
Integration Testing
The integration tests, will effectively function the same as the unit tests, however the data that the integration tests have access to (in test-repos.zip) is far more elaborate and rich, the primary goal of this design is to catch the edge cases that the unit tests miss.
To write new tests:
- Manually unzip the
test-repos.zipchoose a repository to use in testing.- If one is not appropriate, create a new one, be sure to upload a new zip file containing your new repository.
- To use your chosen repository, use a code block similar to the following:
use test_data_dir;
- The
test-reposhould only be unzipped once per test module, so if your testing fits within an existing test module, it will save some time to put the test in an existing module.
credit: The /test-repos.zip file was originally created by the maintainer of PyDriller, which is the core inspiration for this project. At the time of writing Pydriller is under the Apache2.0 license.