add support for maintainership directories

This commit is contained in:
2025-01-15 00:46:03 +01:00
parent e63a450c5d
commit fbaeddfcd8
3 changed files with 138 additions and 34 deletions

View File

@@ -22,6 +22,7 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"slices"
"time"
@@ -38,7 +39,10 @@ import (
//go:generate mockgen -source=gitea_utils.go -destination=mock/gitea_utils.go -typed
// maintainer list file in ProjectGit
const MaintainershipFile = "_maitnainership.json"
const (
MaintainershipFile = "_maitnainership.json"
MaintainershipDir = "maintaineirship"
)
const (
// from Gitea
@@ -58,6 +62,7 @@ const (
type GiteaMaintainershipInterface interface {
FetchMaintainershipFile(org, prjGit, branch string) ([]byte, error)
FetchMaintainershipDirFile(org, prjGit, branch, pkg string) ([]byte, error)
}
type GiteaPRFetcher interface {
@@ -115,6 +120,10 @@ func (gitea *GiteaTransport) FetchMaintainershipFile(org, repo, branch string) (
return gitea.GetRepositoryFileContent(org, repo, branch, MaintainershipFile)
}
func (gitea *GiteaTransport) FetchMaintainershipDirFile(org, repo, branch, pkg string) ([]byte, error) {
return gitea.GetRepositoryFileContent(org, repo, branch, path.Join(MaintainershipDir, pkg))
}
func (gitea *GiteaTransport) GetPullRequest(org, project string, num int64) (*models.PullRequest, error) {
pr, err := gitea.client.Repository.RepoGetPullRequest(
repository.NewRepoGetPullRequestParams().