You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

pullrequest.go 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Copyright 2018 Jonas Franz. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package base
  6. import (
  7. "fmt"
  8. "time"
  9. )
  10. // PullRequest defines a standard pull request information
  11. type PullRequest struct {
  12. Number int64
  13. OriginalNumber int64
  14. Title string
  15. PosterName string
  16. PosterID int64
  17. PosterEmail string
  18. Content string
  19. Milestone string
  20. State string
  21. Created time.Time
  22. Updated time.Time
  23. Closed *time.Time
  24. Labels []*Label
  25. PatchURL string
  26. Merged bool
  27. MergedTime *time.Time
  28. MergeCommitSHA string
  29. Head PullRequestBranch
  30. Base PullRequestBranch
  31. Assignee string
  32. Assignees []string
  33. IsLocked bool
  34. Reactions []*Reaction
  35. }
  36. // IsForkPullRequest returns true if the pull request from a forked repository but not the same repository
  37. func (p *PullRequest) IsForkPullRequest() bool {
  38. return p.Head.RepoPath() != p.Base.RepoPath()
  39. }
  40. // PullRequestBranch represents a pull request branch
  41. type PullRequestBranch struct {
  42. CloneURL string
  43. Ref string
  44. SHA string
  45. RepoName string
  46. OwnerName string
  47. }
  48. // RepoPath returns pull request repo path
  49. func (p PullRequestBranch) RepoPath() string {
  50. return fmt.Sprintf("%s/%s", p.OwnerName, p.RepoName)
  51. }