-
-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(git): find upstream remote when using ssh #926
Conversation
Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️ |
Codecov ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good! I had a few comments regarding refactoring :)
2ea058f
to
87fc703
Compare
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 a URL, e.g. `https://github.com/orhun/git-cliff.git`. However, this would fail to parse when cloned using SSH, e.g. `git@github.com:orhun/git-cliff.git`. 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 posible reason for it failing would be that the `HEAD` is detached.
Thanks for the PR! |
Congrats on merging your first pull request! ⛰️ |
Description
When looking for the
owner
andrepo
of the remote for the currentHEAD
, 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 testrepo::test::git_upstream_remote
fails.The
upstream_remote
function was relying onurl::Url::parse
to extract theowner
andrepo
from theurl
. 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.git@github.com:orhun/git-cliff.git
.Now, if the
url::URL::parser
fails, we now try to parse an SSH remote in the formatgit@hostname:owner/repo.git
.The error from
upstream_remote
also notes that a possible reason for it failing would be that theHEAD
is detached.How Has This Been Tested?
orhun/git-cliff
repo askemitix/git-cliff
git@github.com:kemitix/git-cliff.git
cargo test
- all tests pass, includingrepo::test::git_upstream_remote
Screenshots / Logs (if applicable)
n/a
Types of Changes
Checklist: