gitech

Форк
0
/
pullrequest.go 
74 строки · 2.5 Кб
1
// Copyright 2019 The Gitea Authors. All rights reserved.
2
// Copyright 2018 Jonas Franz. All rights reserved.
3
// SPDX-License-Identifier: MIT
4

5
package migration
6

7
import (
8
	"fmt"
9
	"time"
10

11
	"code.gitea.io/gitea/modules/git"
12
)
13

14
// PullRequest defines a standard pull request information
15
type PullRequest struct {
16
	Number         int64
17
	Title          string
18
	PosterName     string `yaml:"poster_name"`
19
	PosterID       int64  `yaml:"poster_id"`
20
	PosterEmail    string `yaml:"poster_email"`
21
	Content        string
22
	Milestone      string
23
	State          string
24
	Created        time.Time
25
	Updated        time.Time
26
	Closed         *time.Time
27
	Labels         []*Label
28
	PatchURL       string `yaml:"patch_url"` // SECURITY: This must be safe to download directly from
29
	Merged         bool
30
	MergedTime     *time.Time `yaml:"merged_time"`
31
	MergeCommitSHA string     `yaml:"merge_commit_sha"`
32
	Head           PullRequestBranch
33
	Base           PullRequestBranch
34
	Assignees      []string
35
	IsLocked       bool `yaml:"is_locked"`
36
	Reactions      []*Reaction
37
	ForeignIndex   int64
38
	Context        DownloaderContext `yaml:"-"`
39
	EnsuredSafe    bool              `yaml:"ensured_safe"`
40
}
41

42
func (p *PullRequest) GetLocalIndex() int64          { return p.Number }
43
func (p *PullRequest) GetForeignIndex() int64        { return p.ForeignIndex }
44
func (p *PullRequest) GetContext() DownloaderContext { return p.Context }
45

46
// IsForkPullRequest returns true if the pull request from a forked repository but not the same repository
47
func (p *PullRequest) IsForkPullRequest() bool {
48
	return p.Head.RepoPath() != p.Base.RepoPath()
49
}
50

51
// GetGitRefName returns pull request relative path to head
52
func (p PullRequest) GetGitRefName() string {
53
	return fmt.Sprintf("%s%d/head", git.PullPrefix, p.Number)
54
}
55

56
// PullRequestBranch represents a pull request branch
57
type PullRequestBranch struct {
58
	CloneURL  string `yaml:"clone_url"` // SECURITY: This must be safe to download from
59
	Ref       string // SECURITY: this must be a git.IsValidRefPattern
60
	SHA       string // SECURITY: this must be a git.IsValidSHAPattern
61
	RepoName  string `yaml:"repo_name"`
62
	OwnerName string `yaml:"owner_name"`
63
}
64

65
// RepoPath returns pull request repo path
66
func (p PullRequestBranch) RepoPath() string {
67
	return fmt.Sprintf("%s/%s", p.OwnerName, p.RepoName)
68
}
69

70
// GetExternalName ExternalUserMigrated interface
71
func (p *PullRequest) GetExternalName() string { return p.PosterName }
72

73
// ExternalID ExternalUserMigrated interface
74
func (p *PullRequest) GetExternalID() int64 { return p.PosterID }
75

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.