Skip to content

Commit 0f08fe0

Browse files
authored
Merge branch 'main' into zzc/dev/diff-list-view
2 parents f42f02d + 81aec6d commit 0f08fe0

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

modules/migration/pullrequest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type PullRequest struct {
3737
ForeignIndex int64
3838
Context DownloaderContext `yaml:"-"`
3939
EnsuredSafe bool `yaml:"ensured_safe"`
40+
IsDraft bool `yaml:"is_draft"`
4041
}
4142

4243
func (p *PullRequest) GetLocalIndex() int64 { return p.Number }

services/actions/notifier_helper.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,20 @@ func (input *notifyInput) Notify(ctx context.Context) {
116116
}
117117

118118
func notify(ctx context.Context, input *notifyInput) error {
119+
shouldDetectSchedules := input.Event == webhook_module.HookEventPush && input.Ref.BranchName() == input.Repo.DefaultBranch
119120
if input.Doer.IsActions() {
120121
// avoiding triggering cyclically, for example:
121122
// a comment of an issue will trigger the runner to add a new comment as reply,
122123
// and the new comment will trigger the runner again.
123124
log.Debug("ignore executing %v for event %v whose doer is %v", getMethod(ctx), input.Event, input.Doer.Name)
125+
126+
// we should update schedule tasks in this case, because
127+
// 1. schedule tasks cannot be triggered by other events, so cyclic triggering will not occur
128+
// 2. some schedule tasks may update the repo periodically, so the refs of schedule tasks need to be updated
129+
if shouldDetectSchedules {
130+
return DetectAndHandleSchedules(ctx, input.Repo)
131+
}
132+
124133
return nil
125134
}
126135
if input.Repo.IsEmpty || input.Repo.IsArchived {
@@ -174,7 +183,6 @@ func notify(ctx context.Context, input *notifyInput) error {
174183

175184
var detectedWorkflows []*actions_module.DetectedWorkflow
176185
actionsConfig := input.Repo.MustGetUnit(ctx, unit_model.TypeActions).ActionsConfig()
177-
shouldDetectSchedules := input.Event == webhook_module.HookEventPush && input.Ref.BranchName() == input.Repo.DefaultBranch
178186
workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit,
179187
input.Event,
180188
input.Payload,

services/migrations/gitea_uploader.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,15 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*issues_model
760760
pr.Updated = pr.Created
761761
}
762762

763+
prTitle := pr.Title
764+
if pr.IsDraft && !issues_model.HasWorkInProgressPrefix(pr.Title) {
765+
prTitle = fmt.Sprintf("%s %s", setting.Repository.PullRequest.WorkInProgressPrefixes[0], pr.Title)
766+
}
767+
763768
issue := issues_model.Issue{
764769
RepoID: g.repo.ID,
765770
Repo: g.repo,
766-
Title: pr.Title,
771+
Title: prTitle,
767772
Index: pr.Number,
768773
Content: pr.Content,
769774
MilestoneID: milestoneID,

services/migrations/github.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
737737
PatchURL: pr.GetPatchURL(), // see below for SECURITY related issues here
738738
Reactions: reactions,
739739
ForeignIndex: int64(*pr.Number),
740+
IsDraft: pr.GetDraft(),
740741
})
741742

742743
// SECURITY: Ensure that the PR is safe

services/migrations/gitlab.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@ func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullReque
722722
PatchURL: pr.WebURL + ".patch",
723723
ForeignIndex: int64(pr.IID),
724724
Context: gitlabIssueContext{IsMergeRequest: true},
725+
IsDraft: pr.Draft,
725726
})
726727

727728
// SECURITY: Ensure that the PR is safe

0 commit comments

Comments
 (0)