Skip to content

Forcing to use git (or ssh protocol) when URL ends with .git is problematic when you want https instead #71317

Closed as not planned
@grecinto

Description

@grecinto

Does replace example.com/foo/bar vX.Y.Z => private.example.com/foo/bar.git vX.Y.Z not work?

As far as I can tell it does not work with github.com and other "commonly-used VCS hosting sites" (refer to noVSCSuffix in cmd/go/internal/vcs/vcs.go). Go 1.15 gives you "invalid version control suffix in github.com/ path".

@bcmills, if a user could do

replace (
  github.com/foo/bar <version> => github.com/foo/bar.git <version>
)

forcing the use of git instead of https, that could solve it.

How about if you want the opposite behavior? That is, you specified replace .. .git BUT wanted to use HTTPS protocol instead of SSH? Non-github hosting sites like (private) gitlab.com enforces .git extension, but there are cases where developer needs to work on pre-existing code set(e.g. - migrated code to gitlab!) and wanted to retain to use HTTPS but importing in the new gitlab repository, which has .git extension in the url.

Example, this replace will force "go get" or "go mod tidy" to use ssh protocol on fetch, but is there a way to say use HTTPs?

replace (
   github.com/foo/bar <version> => gitlab.com/foo/bar.git <version>
)

Originally posted by @grecinto in #39536

There are cases one wants to use HTTPs even if module URL ends w/ .git. Example, migration of code from GitHub to private GitLab repos. Being able to continue using HTTPs protocol on "go get" or "go mod tidy" (module fetch) will give flexibility to continue using the current code and change it to use git(ssh protocol) at a later point in time, or not at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    OtherNone of the above.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions