Skip to content

fix(datasource/go): Remove .git suffix for go dependencies when calling go-get api#32181

Merged
rarkins merged 2 commits intorenovatebot:mainfrom
d-velop:fix/32105-gitlab-selfhosted-go-git-suffix
Oct 29, 2024
Merged

fix(datasource/go): Remove .git suffix for go dependencies when calling go-get api#32181
rarkins merged 2 commits intorenovatebot:mainfrom
d-velop:fix/32105-gitlab-selfhosted-go-git-suffix

Conversation

@malmor
Copy link
Copy Markdown
Contributor

@malmor malmor commented Oct 28, 2024

Changes

This PR fixes the way Renovate calls the go-get API endpoint when looking for go packages. This is specifically important when working with private GitLab repositories because the API returns HTTP 404 when the .git suffix is part of the request URL:

curl -n https://git.dev.local/development/libraries/go-sdk?go-get=1
<html><head><meta name="go-import" content="git.dev.local/development/libraries/go-sdk git https://git.dev.local/development/libraries/go-sdk.git"></head><body>go get git.dev.local/development/libraries/go-sdk</body></html>

curl -n https://git.dev.local/development/libraries/go-sdk.git?go-get=1
404 Not Found

The updated regex will strip of any .git suffix and additional subfolders, not only .git/v2. The regex can be tested here: https://regex101.com/r/PQbIdY/2

Context

See #32105 for more information

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@rarkins
Copy link
Copy Markdown
Contributor

rarkins commented Oct 29, 2024

@malmor no need to merge from main unless it's conflicted

Copy link
Copy Markdown
Collaborator

@zharinov zharinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a self-hosted GitLab intance with some go package to test against, but code looks okay 🤷‍♂️

@malmor
Copy link
Copy Markdown
Contributor Author

malmor commented Oct 29, 2024

FYI @zharinov if you want to test these kind of changes (now or in the future) you could use the GitLab docker image which can be run locally: https://docs.gitlab.com/ee/install/docker/installation.html

# Docs: https://docs.gitlab.com/ee/install/docker/installation.html
# Images: https://hub.docker.com/r/gitlab/gitlab-ce/tags

version: "3.8"
services:
  gitlab:
    image: gitlab/gitlab-ce:17.4.2-ce.0
    container_name: gitlab
    restart: always
    hostname: "git.dev.local"
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://git.dev.local'
    ports:
      - "80:80"
      - "443:443"
      # - "22:22"
    volumes:
      - "./config:/etc/gitlab"
      - "./logs:/var/log/gitlab"
      - "./data:/var/opt/gitlab"
    shm_size: "256m"

I did have a few issues with certificates (didn't want to spend much time troubleshooting Let's Encrypt), but afterwards you have an empty GitLab instance where you can create projects, groups, ... and play around with different changes 😃

@zharinov
Copy link
Copy Markdown
Collaborator

Oh yes, we want to know how to test this better, thank you

@rarkins rarkins added this pull request to the merge queue Oct 29, 2024
Merged via the queue into renovatebot:main with commit 209a162 Oct 29, 2024
@renovate-release
Copy link
Copy Markdown

🎉 This PR is included in version 38.134.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@malmor
Copy link
Copy Markdown
Contributor Author

malmor commented Oct 30, 2024

Thanks a lot for merging this - I can confirm that the issue has been fixed after upgrading to v38.134.1 🚀

@rarkins
Copy link
Copy Markdown
Contributor

rarkins commented Oct 30, 2024

Thanks for the PR!

@malmor malmor deleted the fix/32105-gitlab-selfhosted-go-git-suffix branch November 1, 2024 21:05
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants