Skip to content

fix relative URL resolution for SCP-style SSH remotes - #109

Open
eugene-nuvacore wants to merge 1 commit into
c0fec0de:mainfrom
eugene-nuvacore:urljoin-scp-relative
Open

fix relative URL resolution for SCP-style SSH remotes#109
eugene-nuvacore wants to merge 1 commit into
c0fec0de:mainfrom
eugene-nuvacore:urljoin-scp-relative

Conversation

@eugene-nuvacore

Copy link
Copy Markdown

urljoin() handles scheme:// URLs and truly-relative paths, but not
SCP-style SSH remotes (git@host:path). Python's urllib doesn't parse
those as URLs (they have no scheme), so they fell through to plain string
concatenation.

With a manifest whose main repo is cloned over an SCP-style remote, a
dependency URL like ../dep.git resolves against the base
git@host:group/main.git to:

git@host:group/main.git/../dep.git   # broken

instead of:

git@host:group/dep.git

git then fails the clone (the server reports the namespace/path doesn't
exist). SCP-style remotes are git's default for git@-cloned repos, so this
hits anyone using a manifest with relative dependency URLs over SSH without an
explicit ssh:// scheme.

The fix is to detect SCP-like syntax using git's own rule — a colon before any slash and no
scheme:// — then normalize the .. within the path while preserving the
host: prefix, so the result stays valid SCP syntax. This also covers the
user-less host:path form, which urllib otherwise mis-parses as having a
scheme (host).

urljoin() only handled scheme:// URLs and truly-relative paths. SCP-style
remotes (git@host:path), which urllib does not parse as URLs, fell through to
plain string concatenation, so a dependency URL of ../dep.git against a base of
git@host:group/main.git produced git@host:group/main.git/../dep.git instead of
git@host:group/dep.git — leaving git to fail the clone.

Detect SCP syntax by git's own rule (a colon before any slash, no scheme://),
normalize the ".." within the path, and keep the "host:" prefix so the result
stays valid SCP syntax. Also covers the user-less host:path form, which urllib
otherwise mis-parses as having a scheme.
@eugene-nuvacore

Copy link
Copy Markdown
Author

@c0fec0de please take a look, thanks :)

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.

1 participant