Skip to content

Fixed incorrect relative submodule URLs #14

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

Merged
merged 1 commit into from
Jun 27, 2016

Conversation

goriy
Copy link
Contributor

@goriy goriy commented Jun 20, 2016

According to git submodule documentation base path for relative submodule URL
is parent repository's root - not submodule "mount point".

So it's necessary to know "path" of parent repository to create correct submodule
URL.

Unfortunately, RefUrl function semantics are changed (kind of API change), so it can break something else that uses it.
At least it is required to change /templates/repo/view_list.tmpl in gogs project.

For more details see issue gogs/gogs#1926

Thus, maybe it's even better to make new function (temporary or permanently) similar to RefUrl (I don't know how bad it is to break compatibility in this particular case).

According to git submodule documentation base path for relative submodule URL
is parent repository's root - not submodule "mount point".

So it's necessary to know "path" of parent repository to create correct submodule
URL.
@unknwon
Copy link
Member

unknwon commented Jun 26, 2016

Thanks your PR!

Any input/output examples?

@goriy
Copy link
Contributor Author

goriy commented Jun 27, 2016

As an example: https://try.gogs.io/illustr/repo1/src/master/shared

Submodule repo2 has the relative URL: ../repo2

Let's assume that file https://github.com/gogits/gogs/blob/master/templates/repo/view_list.tmpl is patched according to gogs/gogs#1926 (i. e. RefUrl on lines 33,34 is called in such way: $commit.RefUrl AppUrl $.BranchLink)

While composing submodule URL, function RefUrl is called with arguments:

Variable sf.refUrl inside function contains "../repo2".

So output will be constructed like this: "https://try.gogs.io" + "/illustr/repo1" + "/" + "../repo2"

Thus, returned value is "https://try.gogs.io/illustr/repo1/../repo2". Corresponding absolute url is "https://try.gogs.io/illustr/repo2" as expected.

I've never used Go language before, so I'm not sure that it's the best solution.

@unknwon unknwon merged commit c61be78 into gogs:master Jun 27, 2016
unknwon added a commit that referenced this pull request Jun 27, 2016
- Refactor some name
@goriy goriy deleted the relative-submodules branch June 27, 2016 23:21
sapk pushed a commit to sapk-fork/git-module that referenced this pull request Mar 8, 2017
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