git-cliff
git-cliff copied to clipboard
feat: find upstream remote when using ssh
Description
When looking for the owner and repo of the remote for the current HEAD, we will now try to parse the SSH format of a remote if it fails to match an HTTPS format of a remote.
Motivation and Context
When the git-cliff repo is cloned for development using the SSH protocol, the test repo::test::git_upstream_remote fails.
The upstream_remote function was relying on url::Url::parse to extract the owner and repo from the url. But that only works when the repo is cloned using HTTPS, e.g. https://github.com/orhun/git-cliff.git. However, this would fail to parse when cloned using SSH, e.g. [email protected]:orhun/git-cliff.git.
Now, if the url::URL::parser fails, we now try to parse an SSH remote in the format git@hostname:owner/repo.git.
The error from upstream_remote also notes that a possible reason for it failing would be that the HEAD is detached.
How Has This Been Tested?
- Fork the
orhun/git-cliffrepo askemitix/git-cliff - Clone using SSH, with a remote of
[email protected]:kemitix/git-cliff.git - Run
cargo test- all tests pass, includingrepo::test::git_upstream_remote
Screenshots / Logs (if applicable)
n/a
Types of Changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation (no code change)
- [ ] Refactor (refactoring production code)
- [ ] Other
Checklist:
Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️
Codecov Report
Attention: Patch coverage is 74.07407% with 7 lines in your changes missing coverage. Please review.
Project coverage is 42.42%. Comparing base (
82b10ac) to head (ea50194). Report is 1 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| git-cliff-core/src/repo.rs | 74.08% | 7 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #926 +/- ##
==========================================
+ Coverage 41.72% 42.42% +0.71%
==========================================
Files 21 21
Lines 1678 1695 +17
==========================================
+ Hits 700 719 +19
+ Misses 978 976 -2
| Flag | Coverage Δ | |
|---|---|---|
| unit-tests | 42.42% <74.08%> (+0.71%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Thanks for the PR!
Congrats on merging your first pull request! ⛰️