Skip to content

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

Closed

Description

@zefie

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.

Activity

  1. unknwon commented on Oct 25, 2018

    @unknwon
    Member
  2. zefie commented on Oct 25, 2018

    @zefie
    Author

    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/"

  3. added
    💊 bug
    and removed
    status: needs feedback
    on Oct 25, 2018
  4. psyciknz commented on Jun 17, 2019

    @psyciknz

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

    [submodule "openhab/conf"]
    url = ssh://[email protected]/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.

  5. swearl commented on Oct 18, 2019

    @swearl

    same issue.... 2 years neved fix?

  6. chill1n commented on Apr 18, 2021

    @chill1n

    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>

  7. zefie commented on Apr 18, 2021

    @zefie
    Author

    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

  8. TheDarkUndoing commented on Nov 25, 2022

    @TheDarkUndoing
    Contributor

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

  9. unknwon commented on Dec 9, 2022

    @unknwon
    Member

    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.

  10. bioinformatist commented on Jan 9, 2023

    @bioinformatist

    @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:

  11. TheDarkUndoing commented on Jan 9, 2023

    @TheDarkUndoing
    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.

  12. unknwon commented on Feb 28, 2023

    @unknwon
    Member

    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 {

  13. TheDarkUndoing commented on Feb 28, 2023

    @TheDarkUndoing
    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.

  14. unknwon commented on Feb 28, 2023

    @unknwon
    Member

    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

  15. TheDarkUndoing commented on Feb 28, 2023

    @TheDarkUndoing
    Contributor

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

  16. TheDarkUndoing commented on Mar 2, 2023

    @TheDarkUndoing
    Contributor

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

  17. locked as resolved and limited conversation to collaborators on Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

💊 bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions