162: chore(core): make git2 optional r=orhun a=MarcoIeni
<!--- Thank you for contributing to git-cliff! ⛰️ -->
## Description
<!--- Describe your changes in detail -->
Make git2 optional in git-cliff-core crate.
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
In release-plz I use git-cliff-core.
However, I don't need git-cliff to read the git history, so I don't need it to include git2.
I depend on both cargo and git-cliff, and often they have conflicting git2 versions.
For example, right now I can't update to the latest git-cliff, because git2 of git-cliff isn't compatible with cargo.
However with this change, by using:
`git-cliff-core = { path = "../git-cliff/git-cliff-core", default-features = false }`
in release-plz I'm able to update!
Some questions for you:
- are you ok with this additional complexity?
- do you want to find a better name for the feature?
Probably there are other dependencies that can be made optional, but for now git2 is the biggest pain-point for me.
If you are interested, I can find more dependencies.
## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->
release-plz is compiling.
Maybe we can add a CI check to test that git-cliff-core compiles even without default features enabled.
## Screenshots / Logs (if applicable)
## Types of Changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation (no code change)
- [x] Refactor (refactoring production code)
- [ ] Other <!--- (provide information) -->
## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [x] My code follows the code style of this project.
- [x] I have updated the documentation accordingly.
- [x] I have formatted the code with [rustfmt](https://github.com/rust-lang/rustfmt).
- [x] I checked the lints with [clippy](https://github.com/rust-lang/rust-clippy).
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
## alternative
Extract the code that doesn't depend on git2 in a third crate.
In particular, in my use case I already have the commits I want to write in the changelog, so it would be great if there was a crate that is only focused on generating the changelog, not in determining the commits to write into it.
It would be great if it could expose a subset of the configuration. For example, in release-plz not all git-cliff configuration option will have effect.
Co-authored-by: Marco Ieni <11428655+MarcoIeni@users.noreply.github.com>
* feat(config): changelog for the last n commits
Adds a additional configuration variable `limit_commits` to the
configuration struct.
`limit_commits` can be set to a positive integer number to limit the
commits contained in the generated changelog.
Also adjusts the default config file to contain `limit_commits` as a
commented out line.
Extends documentation in README.md to also cover the introduced
configuration value.
issue: https://github.com/orhun/git-cliff/issues/102
* test(fixture): add test fixture for limiting commits
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>