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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. Title string
  14. PosterName string
  15. PosterID int64
  16. PosterEmail string
  17. Content string
  18. Milestone string
  19. State string
  20. Created time.Time
  21. Updated time.Time
  22. Closed *time.Time
  23. Labels []*Label
  24. PatchURL string
  25. Merged bool
  26. MergedTime *time.Time
  27. MergeCommitSHA string
  28. Head PullRequestBranch
  29. Base PullRequestBranch
  30. Assignee string
  31. Assignees []string
  32. IsLocked bool
  33. }
  34. // IsForkPullRequest returns true if the pull request from a forked repository but not the same repository
  35. func (p *PullRequest) IsForkPullRequest() bool {
  36. return p.Head.RepoPath() != p.Base.RepoPath()
  37. }
  38. // PullRequestBranch represents a pull request branch
  39. type PullRequestBranch struct {
  40. CloneURL string
  41. Ref string
  42. SHA string
  43. RepoName string
  44. OwnerName string
  45. }
  46. // RepoPath returns pull request repo path
  47. func (p PullRequestBranch) RepoPath() string {
  48. return fmt.Sprintf("%s/%s", p.OwnerName, p.RepoName)
  49. }