2019-05-07 03:12:51 +02:00
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
|
|
// Copyright 2018 Jonas Franz. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2021-11-16 16:25:33 +01:00
|
|
|
package migration
|
2019-05-07 03:12:51 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
2021-12-02 08:28:08 +01:00
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/git"
|
2019-05-07 03:12:51 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// PullRequest defines a standard pull request information
|
|
|
|
type PullRequest struct {
|
|
|
|
Number int64
|
|
|
|
Title string
|
2020-12-27 04:34:19 +01:00
|
|
|
PosterName string `yaml:"poster_name"`
|
|
|
|
PosterID int64 `yaml:"poster_id"`
|
|
|
|
PosterEmail string `yaml:"poster_email"`
|
2019-05-07 03:12:51 +02:00
|
|
|
Content string
|
|
|
|
Milestone string
|
|
|
|
State string
|
|
|
|
Created time.Time
|
2020-01-14 11:29:22 +01:00
|
|
|
Updated time.Time
|
2019-05-07 03:12:51 +02:00
|
|
|
Closed *time.Time
|
|
|
|
Labels []*Label
|
2020-12-27 04:34:19 +01:00
|
|
|
PatchURL string `yaml:"patch_url"`
|
2019-05-07 03:12:51 +02:00
|
|
|
Merged bool
|
2020-12-27 04:34:19 +01:00
|
|
|
MergedTime *time.Time `yaml:"merged_time"`
|
|
|
|
MergeCommitSHA string `yaml:"merge_commit_sha"`
|
2019-05-07 03:12:51 +02:00
|
|
|
Head PullRequestBranch
|
|
|
|
Base PullRequestBranch
|
|
|
|
Assignees []string
|
2020-12-27 04:34:19 +01:00
|
|
|
IsLocked bool `yaml:"is_locked"`
|
2020-01-15 12:14:07 +01:00
|
|
|
Reactions []*Reaction
|
2021-08-22 00:47:45 +02:00
|
|
|
Context IssueContext `yaml:"-"`
|
2019-05-07 03:12:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// IsForkPullRequest returns true if the pull request from a forked repository but not the same repository
|
|
|
|
func (p *PullRequest) IsForkPullRequest() bool {
|
|
|
|
return p.Head.RepoPath() != p.Base.RepoPath()
|
|
|
|
}
|
|
|
|
|
2021-10-08 11:59:35 +02:00
|
|
|
// GetGitRefName returns pull request relative path to head
|
|
|
|
func (p PullRequest) GetGitRefName() string {
|
2021-12-02 20:36:50 +01:00
|
|
|
return fmt.Sprintf("%s%d/head", git.PullPrefix, p.Number)
|
2021-10-08 11:59:35 +02:00
|
|
|
}
|
|
|
|
|
2019-05-07 03:12:51 +02:00
|
|
|
// PullRequestBranch represents a pull request branch
|
|
|
|
type PullRequestBranch struct {
|
2020-12-27 04:34:19 +01:00
|
|
|
CloneURL string `yaml:"clone_url"`
|
2019-05-07 03:12:51 +02:00
|
|
|
Ref string
|
|
|
|
SHA string
|
2020-12-27 04:34:19 +01:00
|
|
|
RepoName string `yaml:"repo_name"`
|
|
|
|
OwnerName string `yaml:"owner_name"`
|
2019-05-07 03:12:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// RepoPath returns pull request repo path
|
|
|
|
func (p PullRequestBranch) RepoPath() string {
|
|
|
|
return fmt.Sprintf("%s/%s", p.OwnerName, p.RepoName)
|
|
|
|
}
|