Skip to content
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

Submodule with 'ssh:// method' and alternate port breaks hyperlink in webui #4941

Closed
2 of 7 tasks
zefie opened this issue Dec 16, 2017 · 15 comments · Fixed by #7383
Closed
2 of 7 tasks

Submodule with 'ssh:// method' and alternate port breaks hyperlink in webui #4941

zefie opened this issue Dec 16, 2017 · 15 comments · Fixed by #7383
Assignees
Labels
💊 bug Something isn't working

Comments

@zefie
Copy link

zefie commented Dec 16, 2017

Description

Adding a submodule that uses an alternate port ('ssh:// method') causes the hyperlink to the submodule's git to be broken.

I guess this wouldn't normally be used (realized I was doing mine wrong) but at the same time, it could be useful in some private environments.

@unknwon
Copy link
Member

unknwon commented Oct 25, 2018

Hi, can you point out in https://try.gogs.io/zefie/gogs_custom_ssh_port_submodule_test, which part is wrong and what is expected?

@unknwon unknwon added the status: needs feedback Tell me more about it label Oct 25, 2018
@zefie
Copy link
Author

zefie commented Oct 25, 2018

Check the link to the module and .gitmodules.
My git is down so the link wouldn't work anyway, but the issue is gogs is linking the ssh port (even tho my git is down, the link is the issue).

The link should be "http://git.zefie.net/zefie/lge_g6_kernel_scripts" but is linked as "http://git.zefie.net/2222/zefie/lge_g6_kernel_scripts", because the module used "ssh://git.zefie.net:2222/"

@unknwon unknwon added 💊 bug Something isn't working and removed status: needs feedback Tell me more about it labels Oct 25, 2018
@psyciknz
Copy link

I've just created a submodule link also using ssh (to port 8022).
My main project is:
ssh://git@git.domain:8022/Docker/Docker.git
my submodule is

[submodule "openhab/conf"]
url = ssh://git@git.8022/HomeAutomation/OpenHAB.git

In the web UI of Gogs the link for the conf folder in the openhab directory is for
https://git.domain/8022/HomeAutomation/OpenHAB/commit/f49efa46370da23ec34055d568a6b8401755516a

So it's taken the :8022 port and made a folder as part of the link.

@swearl
Copy link

swearl commented Oct 18, 2019

same issue.... 2 years neved fix?

@chill1n
Copy link

chill1n commented Apr 18, 2021

This is still a problem with the latest version:
Application version
0.13.0+dev
Git version
2.24.3

In my case I have in app.ini:
[server]
SSH_PORT = 8022
OFFLINE_MODE = true

In .gitmodules I have:
[submodule "generic"]
path = generic
url = ssh://git@:8022/<repo_name>
In the gogs UI the submodule link reads:
http://:8022/<repo_name>
but it should read:
http:///<repo_name>

@zefie
Copy link
Author

zefie commented Apr 18, 2021

I am not familiar with the go language but this seems fairly trivial:

if (first 3 letters of repo = ssh) then do not include port in URL
else include port in url

@TheDarkUndoing
Copy link
Contributor

If someone finds the section in the codebase, I'll write a patch for it. I have intermediate experience with Go.

@unknwon
Copy link
Member

unknwon commented Dec 9, 2022

If someone finds the section in the codebase, I'll write a patch for it. I have intermediate experience with Go.

This is the function that infers the URL for submodule.

@bioinformatist
Copy link

@juning98 @unknwon I also met this problem. When creating submodule with ssh link, the repo will also direct wrongly to ssh port with webUI. So could you fix it since all of us seems not familar with Go language...

Thanks in advance!:smile:

@TheDarkUndoing
Copy link
Contributor

If someone finds the section in the codebase, I'll write a patch for it. I have intermediate experience with Go.

This is the function that infers the URL for submodule.

I might be missing something but I dont see the function.

@unknwon
Copy link
Member

unknwon commented Feb 28, 2023

If someone finds the section in the codebase, I'll write a patch for it. I have intermediate experience with Go.

This is the function that infers the URL for submodule.

I might be missing something but I dont see the function.

Sorry! 😂 did not realize I didn't paste the link in:

func InferSubmoduleURL(baseURL string, mod *git.Submodule) string {

@TheDarkUndoing
Copy link
Contributor

If someone finds the section in the codebase, I'll write a patch for it. I have intermediate experience with Go.

This is the function that infers the URL for submodule.

I might be missing something but I dont see the function.

Sorry! 😂 did not realize I didn't paste the link in:

func InferSubmoduleURL(baseURL string, mod *git.Submodule) string {

Thank you, I think the logic would go in here somewhere. I need to figure out how to test this though.

@unknwon
Copy link
Member

unknwon commented Feb 28, 2023

I need to figure out how to test this though.

I think you can get very far by just add a test case and check the result: https://github.com/gogs/gogs/blob/fb6693f6123c0a176097e8213b0aaaa7cef34187/internal/gitutil/submodule_test.go

@TheDarkUndoing
Copy link
Contributor

TheDarkUndoing commented Feb 28, 2023

Thank you for pointing that out, was about to waste alot of time building the whole app

@TheDarkUndoing
Copy link
Contributor

I would like to get some eyes on the patch I added. #7383

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💊 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants