Skip to content

fix: Use remote of branch rather than first remote in list (Fixes #242)#246

Merged
linrongbin16 merged 2 commits intolinrongbin16:masterfrom
tvsfx:master
Sep 19, 2024
Merged

fix: Use remote of branch rather than first remote in list (Fixes #242)#246
linrongbin16 merged 2 commits intolinrongbin16:masterfrom
tvsfx:master

Conversation

@tvsfx
Copy link
Contributor

@tvsfx tvsfx commented Sep 18, 2024

Since filing #242, I have noticed that the only issue standing in the way of my feature request there, is the selection of the first remote in case multiple remotes are available. If we do not do this, as this PR proposes, the behavior will be the (in my opinion more intuitive) behavior described in #242, namely the selection of the remote of the upstream of the current branch as the remote.

Previously, in case multiple remotes were available, and the first remote did not correspond to the current branch's remote, gitlinker failed even though the 2nd, 3rd etc. remote might still match, so the proposed behavior should cause strictly fewer failing cases, and hence be backwards compatible.

@linrongbin16
Copy link
Owner

linrongbin16 commented Sep 19, 2024

Note:

This line

if #remotes >= 1 then

is been changed last time in PR #235 , which is trying to fix issue #234 , relate comment: #234 (comment).

I actually forget why I'm doing it this way, let me consider this issue and the previous issue together, see if we have a solution to satisfy them both.

@linrongbin16
Copy link
Owner

linrongbin16 commented Sep 19, 2024

After take a look, I think this PR makes more sense, which is also the original code logic before #235 .

The logic is: gitlinker is only sure when there's only 1 git remote configured.

If there are multiple git remotes, i.e. git remotes > 1, then gitlinker should not automatically pick the first. Because this plugin will not know which remote the user wants, so the decision goes to the user.

@linrongbin16
Copy link
Owner

linrongbin16 commented Sep 19, 2024

I will accept this PR, after I upgrade the commons library in #245 .

@linrongbin16 linrongbin16 self-requested a review September 19, 2024 01:11
@linrongbin16 linrongbin16 changed the title Use remote of branch rather than first remote in list (Fixes #242) fix: Use remote of branch rather than first remote in list (Fixes #242) Sep 19, 2024
@linrongbin16 linrongbin16 merged commit b10e793 into linrongbin16:master Sep 19, 2024
@linrongbin16
Copy link
Owner

hi @tvsfx , thanks to your effort, PR is merged. Please have a try!

@tvsfx
Copy link
Contributor Author

tvsfx commented Sep 19, 2024

Thanks for looking at this so quickly!

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