forked from mirrors/forgejo
fix: add required headers to pagure migration (#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.
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9973
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Alexander Bokovoy <ab@samba.org>
Co-committed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit e7ef2eb370)
This commit is contained in:
parent
f1a497d3c1
commit
621106123a
3 changed files with 7 additions and 1 deletions
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"forgejo.org/modules/log"
|
"forgejo.org/modules/log"
|
||||||
base "forgejo.org/modules/migration"
|
base "forgejo.org/modules/migration"
|
||||||
"forgejo.org/modules/proxy"
|
"forgejo.org/modules/proxy"
|
||||||
|
"forgejo.org/modules/setting"
|
||||||
"forgejo.org/modules/structs"
|
"forgejo.org/modules/structs"
|
||||||
"forgejo.org/modules/util"
|
"forgejo.org/modules/util"
|
||||||
)
|
)
|
||||||
|
|
@ -279,6 +280,11 @@ func (d *PagureDownloader) callAPI(endpoint string, parameter map[string]string,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
if d.privateIssuesOnlyRepo {
|
||||||
req.Header.Set("Authorization", "token "+d.token)
|
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) {
|
func (d *PagureDownloader) GetLabels() ([]*base.Label, error) {
|
||||||
rawLabels := PagureLabelsList{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue