Skip to content

Improve support for fetching refspecs of merge/pull requests from git (self-hosted) forges #182

@MisterDA

Description

@MisterDA

Git forges have a different naming scheme for merge/pull requests.

  • GitlLab:

    fetch = +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
    
  • GitHub:

    fetch = +refs/pull/*:refs/remotes/pull/*
    
  • Gogs/Gitea use the same scheme as GitHub.

  • Bitbucket

    • not supported on BitBucket Cloud (bitbucket.com) BCLOUD-5814;
    • supported on BitBucket Stash (self-hosted) with yet another scheme (doc):
      fetch +refs/pull-requests/*/from:refs/remotes/origin/pr/*
      

This is handled in worker/context.ml, which simply inspects the remote URL. Considering that we're mainly dealing with github.com, gitlab.com, and self-hosted GitLab instances, we check and default to their refspecs in that order.

There's apparently no standard way with git to query the remote for more info (e.g., the type of forge). We could hackishly inspect the headers for certain strings, or use forges REST/GraphQL API for self-hosted domains to detect which kind of refspec it's using.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions