Skip to content

Commit 74664b0

Browse files
authored
Support migrating GitHub/GitLab PR draft status (#32242)
Resolve #32196
1 parent 9df5dda commit 74664b0

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

modules/migration/pullrequest.go

+1
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/migrations/gitea_uploader.go

+6-1
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

+1
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

+1
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)