Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
aaa9099
adopt-project.py: a plan that sends a source's `.gitmodules` to one l…
brettheap Oct 7, 2026
09d7889
adopt-project.py: a submodule a plan keeps in a leg must now be regis…
brettheap Oct 9, 2026
326fb25
adopt-project.py: `plan` asks the `.gitmodules` question on every ent…
brettheap Oct 9, 2026
794828c
Merge main (b18cca9, #168 via #170) into fix/adopt-split-submodule-plan
brettheap Oct 9, 2026
ca5fb3d
adopt-project.py: `check` reads a source's `.gitmodules` as git's own…
brettheap Oct 9, 2026
5bef216
Merge main (21f5c33, #167 via #182) into fix/adopt-split-submodule-plan
brettheap Oct 9, 2026
a037228
Merge main (f25d805, #169 via #187) into fix/adopt-split-submodule-plan
brettheap Oct 9, 2026
ce5e52d
adopt-project.py: `plan` keeps main's follow-ups and seeding record f…
brettheap Oct 9, 2026
6aaedc5
tests: the unreadable-`.gitmodules` finding names where git fails on …
brettheap Oct 9, 2026
6fcf645
tests: `resolve` writes the plan back LF and `raw_source` skips a sou…
brettheap Oct 9, 2026
96c8353
Merge main (22c9fdd, #175 via #185, #176 via #186, #192 via #193) int…
brettheap Oct 9, 2026
3eb55e5
adopt-project.py: a source submodule's relative url kept in a leg mus…
brettheap Oct 9, 2026
52cf9f9
Merge origin/fix/adopt-split-submodule-plan (96c8353) into fix/adopt-…
brettheap Oct 9, 2026
b0c959e
Merge origin/main (e4decfb, #166 via #194) into fix/adopt-relative-su…
brettheap Oct 11, 2026
c46dc57
Merge origin/main (54aa69a) into fix/adopt-relative-submodule-url: #1…
brettheap Oct 11, 2026
8a4663b
tests/test_adopt_relative_submodule_url.py: `execute`'s refusal is as…
brettheap Oct 11, 2026
8a0adb9
adopt-project.py: git's answer for a relative url, resolved against a…
brettheap Oct 11, 2026
c2b5302
repo_shape.py: `remote_key` takes a port off a url's host and reads `…
brettheap Oct 11, 2026
60e9558
Merge origin/main (4835fb4) into fix/adopt-relative-submodule-url: #2…
brettheap Oct 11, 2026
9bc4147
Merge branch 'main' into fix/adopt-relative-submodule-url
brettheap Oct 11, 2026
0b996fd
Merge branch 'main' into fix/adopt-relative-submodule-url
brettheap Oct 11, 2026
1abe078
Merge branch 'main' into fix/adopt-relative-submodule-url
brettheap Oct 11, 2026
8ce5614
Merge branch 'main' into fix/adopt-relative-submodule-url
brettheap Oct 11, 2026
18e161e
Merge origin/main ede15ce into fix/adopt-relative-submodule-url: #215…
brettheap Oct 12, 2026
c0b1ebb
tests: #190's relative-url finding is expected with the submodule and…
brettheap Oct 12, 2026
5d3caf3
Merge origin/main b421e6b into fix/adopt-relative-submodule-url: #196…
brettheap Oct 12, 2026
2e93649
Merge origin/main 71b58a1 into fix/adopt-relative-submodule-url: #262…
brettheap Oct 12, 2026
cc5b6ae
Merge branch 'main' into fix/adopt-relative-submodule-url
brettheap Oct 12, 2026
d72544c
Merge branch 'main' into fix/adopt-relative-submodule-url
brettheap Oct 12, 2026
b33562d
Merge origin/main f795cf7 into fix/adopt-relative-submodule-url: #255…
brettheap Oct 12, 2026
a0272b2
Merge origin/main ab623dd into fix/adopt-relative-submodule-url: #332…
brettheap Oct 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
386 changes: 345 additions & 41 deletions adopt-project.py

Large diffs are not rendered by default.

28 changes: 26 additions & 2 deletions scripts/repo_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,17 @@ def repo_basename(repository: str) -> str:
#: draws for a value on a command line, for the same reason.
REMOTE_DRIVE_RE = re.compile(r"^[A-Za-z]:$")

#: A `:<port>` after the HOST of a `<scheme>://` url: where its transport
#: connects, never which repository it reaches. Only such a url has one; in
#: git's scp spelling `host:22/Repo.git` the `22` is the path's, and stays.
#: Digits are required, so a drive's bare colon is never read as one.
REMOTE_PORT_RE = re.compile(r":\d+$")

#: A host that is another door into the repositories of the host it maps
#: to: GitHub's SSH-over-the-HTTPS-port endpoint, which GitHub's own
#: documentation spells `ssh://git@ssh.github.com:443/Org/Repo.git`.
REMOTE_HOST_ALIASES = {"ssh.github.com": "github.com"}


def _remote_body(url: str) -> str:
"""A remote with its scheme, its credential and its trailing `/` gone.
Expand Down Expand Up @@ -2085,11 +2096,24 @@ def remote_key(url: str) -> str:
was written in. It is asked of the remote AS IT WAS WRITTEN, because the
scp colon this function is about to turn into a `/` is the one thing that
tells a Windows drive from a host.

A PORT COMES OFF TOO, AND `ssh.github.com` IS `github.com` (#190).
`ssh://git@github.com:22/Org/Repo.git` and GitHub's documented
`ssh://git@ssh.github.com:443/Org/Repo.git` are
`git@github.com:Org/Repo.git` reached through another door; with the
port's colon taken for the scp one they keyed as `github.com/22/org/repo`,
which no other spelling of that repository does, and a caller comparing
keys -- `adopt-project.py`'s relative-url check -- called them two.
"""
text = _remote_body(url)
fold_case = _remote_names_a_host(url)
if ":" in text.split("/", 1)[0]: # the scp spelling's one separator
text = text.replace(":", "/", 1)
first, slash, rest = text.partition("/")
if REMOTE_SCHEME_RE.match(url.strip()): # only a url's host has a port
first = REMOTE_PORT_RE.sub("", first)
# The scp spelling's one separator, `host:path`, becomes a `/`.
host, slash, rest = (first.replace(":", "/", 1) + slash
+ rest).partition("/")
text = REMOTE_HOST_ALIASES.get(host.lower(), host) + slash + rest
if text.lower().endswith(".git"):
text = text[:-4]
return (text.lower() if fold_case else text).strip("/")
Expand Down
7 changes: 6 additions & 1 deletion tests/test_adopt_gitmodules_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@

UNREADABLE = "plan-gitmodules-unreadable"
REMOTES = "remotes"
REGISTRATION = '[submodule "b"]\n\tpath = vendor/b\n\turl = ../b\n'
#: An ABSOLUTE url, which git copies as it stands. A relative one kept in a
#: leg is resolved from the leg too (#190), and in a source with no remote
#: `../b` is the directory beside it, which no GitHub leg reaches: a finding
#: of its own beside every value here, which is not what these tests ask.
REGISTRATION = ('[submodule "b"]\n\tpath = vendor/b\n'
'\turl = https://example.invalid/b\n')
#: A source whose plan asks about `.gitmodules`, and about `vendor/` where
#: the tip holds the submodule: `specs/` and `src/` classify themselves and
#: `README.md` stays in the root.
Expand Down
Loading
Loading