Skip to content

Fix relatively-pathed submodule link rendering

Administrator requested to merge cloud/fix-relative-submodule-links into main

Created by: flying-robot

Git submodules support an optional path parameter which can be used to point to repos that are relatively pathed[0], as shown below:

$ git submodule add ../test-repo-2
$ cat .gitmodules
[submodule "test-repo-2"]
       path = test-repo-2
       url = ../test-repo-2

That was causing link rendering to break since it wasn't able to resolve the code host URL with the repo, resulting in submodule links in the UI that went nowhere.

The mapping function will make a best-effort attempt to address this by checking whether or not the incoming cloneURL is relative, and if so tries to assemble a more complete URL given the identified host (if any). If the incoming cloneURL is not relative, or the host could not be set, it proceeds as normal.

TODOs

  • write supporting tests
  • write CHANGELOG entry

[0] https://git-scm.com/docs/git-submodule

fixes https://github.com/sourcegraph/sourcegraph/issues/15286

Merge request reports

Loading