[v13.0/forgejo] fix: add required headers to Pagure migration (#9994)

**Backport:** https://codeberg.org/forgejo/forgejo/pulls/9973

See https://pagure.io/fedora-infrastructure/issue/12886 for details.

Resolves https://codeberg.org/forgejo/forgejo/issues/9974

## Test
1. Go to https://dev.gusted.xyz/repo/migrate?service_type=10
2. Fill in https://pagure.io/slapi-nis
3. Migrate.
4. Verify the migration succeeded.

Co-authored-by: Alexander Bokovoy <ab@samba.org>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9994
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
forgejo-backport-action 2025-11-06 14:36:12 +01:00 committed by Gusted
parent f1a497d3c1
commit dfdcbaf194
3 changed files with 7 additions and 1 deletions

View file

@ -16,6 +16,7 @@ import (
"forgejo.org/modules/log"
base "forgejo.org/modules/migration"
"forgejo.org/modules/proxy"
"forgejo.org/modules/setting"
"forgejo.org/modules/structs"
"forgejo.org/modules/util"
)
@ -279,6 +280,11 @@ func (d *PagureDownloader) callAPI(endpoint string, parameter map[string]string,
if err != nil {
return err
}
// pagure.io is protected by Anubis and requires proper headers
req.Header.Add("Accept", "*/*")
req.Header.Add("User-Agent", "Forgejo/"+setting.AppVer)
if d.privateIssuesOnlyRepo {
req.Header.Set("Authorization", "token "+d.token)
}
@ -344,7 +350,7 @@ func (d *PagureDownloader) GetMilestones() ([]*base.Milestone, error) {
func (d *PagureDownloader) GetLabels() ([]*base.Label, error) {
rawLabels := PagureLabelsList{}
err := d.callAPI("/api/0/"+d.repoName+"/tags", nil, &rawLabels)
err := d.callAPI("/api/0/"+d.repoName+"/tags/", nil, &rawLabels)
if err != nil {
return nil, err
}