forked from git-workflow/autogits
Compare commits
1 Commits
main
...
new-packag
| Author | SHA256 | Date | |
|---|---|---|---|
| f224f46120 |
@@ -75,6 +75,10 @@ type GiteaLabelSettter interface {
|
||||
SetLabels(org, repo string, idx int64, labels []string) ([]*models.Label, error)
|
||||
}
|
||||
|
||||
type GiteaIssueFetcher interface {
|
||||
GetIssue(org, repo string, idx int64) (*models.Issue, error)
|
||||
}
|
||||
|
||||
type GiteaTimelineFetcher interface {
|
||||
GetTimeline(org, repo string, idx int64) ([]*models.TimelineComment, error)
|
||||
}
|
||||
@@ -200,6 +204,7 @@ type Gitea interface {
|
||||
GiteaSetRepoOptions
|
||||
GiteaLabelGetter
|
||||
GiteaLabelSettter
|
||||
GiteaIssueFetcher
|
||||
|
||||
GetNotifications(Type string, since *time.Time) ([]*models.NotificationThread, error)
|
||||
GetDoneNotifications(Type string, page int64) ([]*models.NotificationThread, error)
|
||||
@@ -508,6 +513,16 @@ func (gitea *GiteaTransport) SetLabels(owner, repo string, idx int64, labels []s
|
||||
return ret.Payload, nil
|
||||
}
|
||||
|
||||
func (gitea *GiteaTransport) GetIssue(owner, repo string, idx int64) (*models.Issue, error) {
|
||||
ret, err := gitea.client.Issue.IssueGetIssue(
|
||||
issue.NewIssueGetIssueParams().WithOwner(owner).WithRepo(repo).WithIndex(idx),
|
||||
gitea.transport.DefaultAuthentication)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret.Payload, nil
|
||||
}
|
||||
|
||||
const (
|
||||
GiteaNotificationType_Pull = "Pull"
|
||||
)
|
||||
|
||||
@@ -626,6 +626,23 @@ func ProcesPullRequest(pr *models.PullRequest, configs []*common.AutogitConfig)
|
||||
return PRProcessor.Process(pr)
|
||||
}
|
||||
|
||||
func ProcessIssue(issue *models.Issue, configs []*common.AutogitConfig) error {
|
||||
title := issue.Title
|
||||
|
||||
if len(title) > 5 && strings.EqualFold(title[0:5], "[ADD]") {
|
||||
// we need "New Package" label and "Approval Required" label, unless already approved
|
||||
// either via Label "Approved" or via review comment.
|
||||
NewIssues := common.FindNewReposInIssueBody(issue.Body)
|
||||
|
||||
} else if len(title) > 4 && strings.EqualFold(title[0:4], "[RM]") {
|
||||
// to remove a package, no approval is required. This should happen via
|
||||
// project git PR reviews
|
||||
} else {
|
||||
common.LogError("Non-standard issue created. Ignoring", common.IssueToString(issue))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w *RequestProcessor) ProcessFunc(request *common.Request) (err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -654,6 +671,18 @@ func (w *RequestProcessor) ProcessFunc(request *common.Request) (err error) {
|
||||
common.LogError("Cannot find PR for issue:", req.Repository.Owner.Username, req.Repository.Name, int64(req.Issue.Number))
|
||||
return err
|
||||
}
|
||||
} else if req, ok := request.Data.(*common.IssueWebhookEvent); ok {
|
||||
issue, err := Gitea.GetIssue(req.Repository.Owner.Username, req.Repository.Name, int64(req.Issue.Number))
|
||||
if err != nil {
|
||||
common.LogError("Cannot find issue for issue event:", req.Repository.Owner.Username, req.Repository.Name, int64(req.Issue.Number))
|
||||
return err
|
||||
}
|
||||
configs, ok := w.configuredRepos[req.Repository.Owner.Username]
|
||||
if !ok {
|
||||
common.LogError("*** Cannot find config for org:", req.Repository.Owner.Username)
|
||||
return nil
|
||||
}
|
||||
return processIssue(issue, configs)
|
||||
} else {
|
||||
common.LogError("*** Invalid data format for PR processing.")
|
||||
return fmt.Errorf("*** Invalid data format for PR processing.")
|
||||
|
||||
Reference in New Issue
Block a user