wip
This commit is contained in:
parent
b4a1c5dc01
commit
682397975f
@ -34,6 +34,7 @@ import (
|
||||
"src.opensuse.org/autogits/common/gitea-generated/client/notification"
|
||||
"src.opensuse.org/autogits/common/gitea-generated/client/organization"
|
||||
"src.opensuse.org/autogits/common/gitea-generated/client/repository"
|
||||
"src.opensuse.org/autogits/common/gitea-generated/client/user"
|
||||
"src.opensuse.org/autogits/common/gitea-generated/models"
|
||||
)
|
||||
|
||||
@ -92,6 +93,7 @@ type Gitea interface {
|
||||
GiteaReviewer
|
||||
GiteaPRFetcher
|
||||
GiteaReviewFetcher
|
||||
GiteaMaintainershipReader
|
||||
|
||||
GetPullNotifications(since *time.Time) ([]*models.NotificationThread, error)
|
||||
SetNotificationRead(notificationId int64) error
|
||||
@ -105,7 +107,7 @@ type Gitea interface {
|
||||
GetRecentPullRequests(org, repo string) ([]*models.PullRequest, error)
|
||||
GetRecentCommits(org, repo, branch string, commitNo int64) ([]*models.Commit, error)
|
||||
|
||||
GiteaMaintainershipReader
|
||||
GetCurrentUser() (*models.User, error)
|
||||
}
|
||||
|
||||
type GiteaTransport struct {
|
||||
@ -544,3 +546,16 @@ func (gitea *GiteaTransport) GetRecentCommits(org, repo, branch string, commitNo
|
||||
|
||||
return commits.Payload, nil
|
||||
}
|
||||
|
||||
func (gitea *GiteaTransport) GetCurrentUser() (*models.User, error) {
|
||||
user, err := gitea.client.User.UserGetCurrent(
|
||||
user.NewUserGetCurrentParams(),
|
||||
gitea.transport.DefaultAuthentication,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return user.GetPayload(), nil
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"time"
|
||||
|
||||
"src.opensuse.org/autogits/common"
|
||||
"src.opensuse.org/autogits/common/gitea-generated/models"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -52,6 +53,7 @@ func fetchPrGit(h *common.RequestHandler, pr *models.PullRequest) error {
|
||||
var DebugMode bool
|
||||
var ListPROnly bool
|
||||
var PRID int64
|
||||
var CurrentUser *models.User
|
||||
|
||||
func main() {
|
||||
if err := common.RequireGiteaSecretToken(); err != nil {
|
||||
@ -104,6 +106,11 @@ func main() {
|
||||
|
||||
gitea := common.AllocateGiteaTransport(*giteaHost)
|
||||
|
||||
if CurrentUser, err = gitea.GetCurrentUser(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Println("Running with token from", CurrentUser.UserName)
|
||||
|
||||
req.Synced = &PullRequestSynced{
|
||||
gitea: gitea,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user