Skip to content

Request support git "insteadOf" url aliases #1150

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

Closed
larsks opened this issue Jan 22, 2025 · 6 comments · Fixed by #1151
Closed

Request support git "insteadOf" url aliases #1150

larsks opened this issue Jan 22, 2025 · 6 comments · Fixed by #1151
Labels
bug Something isn't working properly confirmed Prevent from becoming stale

Comments

@larsks
Copy link
Contributor

larsks commented Jan 22, 2025

Bug Report

Description

With a configuration like this in my global git config:

[url "ssh://git@github.com/larsks/"]
	insteadof = me:

I can clone a repository like this:

git clone me:myproject

Which ends up looking like this:

$ git config --get remote.origin.url
me:myproject

Which ultimately causes psr to fail like this:

$ psr version
::ERROR:: Bad url: 'me:myproject'

Expected behavior

PSR would not have thrown an error because it would have been able to interpret my git configuration and extracted the remote URL just as git normally can.

If you use git remote get-url <remote> command, it will return a fully expanded url via the insteadOf setting.

$ git remote get-url origin
ssh://git@github.com/larsks/myproject

Actual behavior

PSR errored out with a failure message of a bad remote URL because it retrieved the remote url setting which in raw form is an invalid URL rather than using the git interpreter which supports the insteadOf alias attribute and would of returned a valid remote URL value.

Environment

semantic-release, version 9.16.1
@larsks larsks added bug Something isn't working properly triage waiting for initial maintainer review labels Jan 22, 2025
@codejedi365 codejedi365 changed the title psr should support git "insteadOf" url aliases Request support git "insteadOf" url aliases Jan 22, 2025
@codejedi365 codejedi365 added confirmed Prevent from becoming stale and removed triage waiting for initial maintainer review labels Jan 22, 2025
@codejedi365
Copy link
Contributor

I don't appreciate the rude tone as I do this on my own time for $0.

@larsks
Copy link
Contributor Author

larsks commented Jan 22, 2025

Look, I wasn't trying to be rude. I was just opening an issue. I'm sorry to bother you; I'll work on fixing it myself and submit a PR at some point.

@larsks larsks closed this as completed Jan 22, 2025
@larsks
Copy link
Contributor Author

larsks commented Jan 22, 2025

I've re-read the original post, and I'm not sure what you've identified as "rude". Was it this?

psr fell over because it couldn't parse a valid remote specification.

Maybe the description is a bit terse, but I think it accurately captures the behavior. I apologize if it came across as rude. For what it's worth, I also work on software for $0 in my spare time, so we have in common, at least.

If other folks want to tackle this, note that the underlying problem is that PSR relies on GitPython, which has been in "maintenance mode" for at least eight years. The most relevant issue was opened backed in 2017, and has remained untouched since then.

The correct path forward is probably to fix this in GitPython, but note that even if it gets fixed there, PSR will need to update its dependencies, which currently pins GitPython to ~= 3.0, whereas GitPython has moved on to 3.1.xx.

larsks added a commit to larsks/python-semantic-release that referenced this issue Jan 22, 2025
Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
@larsks
Copy link
Contributor Author

larsks commented Jan 22, 2025

It turns out there's a relatively simple way to work around this; I've submitted a pull request that addresses the problem.

@codejedi365
Copy link
Contributor

codejedi365 commented Jan 23, 2025

I've re-read the original post, and I'm not sure what you've identified as "rude". Was it this?

psr fell over because it couldn't parse a valid remote specification.

Maybe the description is a bit terse, but I think it accurately captures the behavior. I apologize if it came across as rude.

Thanks for the apology, I was probably having a bit of a long day and took it overly personal as I had never heard of the instead of aliasing option before. It's quite difficult to get all scenarios of use covered.

For what it's worth, I also work on software for $0 in my spare time, so we have in common, at least.

We do, which software is that?

If other folks want to tackle this, note that the underlying problem is that PSR relies on GitPython, which has been in "maintenance mode" for at least eight years. The most relevant issue was opened backed in 2017, and has remained untouched since then.

The correct path forward is probably to fix this in GitPython, but note that even if it gets fixed there, PSR will need to update its dependencies, which currently pins GitPython to ~= 3.0, whereas GitPython has moved on to 3.1.xx.

That is good research you have completed and it would be nice to have GitPython still maintained.

No need to bump the version, the approximation value only locks the major version of 3.

larsks added a commit to larsks/python-semantic-release that referenced this issue Jan 23, 2025
Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
larsks added a commit to larsks/python-semantic-release that referenced this issue Jan 23, 2025
Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
larsks added a commit to larsks/python-semantic-release that referenced this issue Jan 23, 2025
Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
larsks added a commit to larsks/python-semantic-release that referenced this issue Jan 23, 2025
Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
larsks added a commit to larsks/python-semantic-release that referenced this issue Jan 23, 2025
Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
@codejedi365 codejedi365 reopened this Jan 25, 2025
codejedi365 added a commit to larsks/python-semantic-release that referenced this issue Jan 25, 2025
codejedi365 pushed a commit to larsks/python-semantic-release that referenced this issue Jan 25, 2025
…dOf` configurations

Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
codejedi365 pushed a commit to larsks/python-semantic-release that referenced this issue Jan 25, 2025
…dOf` configurations

Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
codejedi365 pushed a commit to codejedi365/python-semantic-release that referenced this issue Jan 25, 2025
…dOf` configurations

Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Jan 25, 2025
codejedi365 pushed a commit to codejedi365/python-semantic-release that referenced this issue Jan 25, 2025
…dOf` configurations

Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
codejedi365 added a commit to larsks/python-semantic-release that referenced this issue Jan 25, 2025
codejedi365 pushed a commit to larsks/python-semantic-release that referenced this issue Jan 25, 2025
…dOf` configurations

Git permits creating URL aliases through the use of the insteadOf directive
[1]. For example, given a configuration like this:

    [url "ssh://git@github.com/larsks/"]
    insteadOf = me:

We can reference a remote project like this:

    git clone me:myproject

Which will act as if we had actually typed:

    git clone ssh://git@github.com/larsks/myproject

Previously, python-semantic-release would attempt to use the raw url from
the repository configuration (`me:myproject` in the above example), and
would fail to parse it because it's not actually a url. With this change,
psr instead calls out to `git remote get-url`, which fully expands the url
for us.

[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Closes: python-semantic-release#1150
@codejedi365
Copy link
Contributor

🎉 This issue has been resolved in Version 9.17.0 🎉

You can find more information about this release on the GitHub Releases page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working properly confirmed Prevent from becoming stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants