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

pullrequest.go 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. Reactions []*Reaction
  34. }
  35. // IsForkPullRequest returns true if the pull request from a forked repository but not the same repository
  36. func (p *PullRequest) IsForkPullRequest() bool {
  37. return p.Head.RepoPath() != p.Base.RepoPath()
  38. }
  39. // PullRequestBranch represents a pull request branch
  40. type PullRequestBranch struct {
  41. CloneURL string
  42. Ref string
  43. SHA string
  44. RepoName string
  45. OwnerName string
  46. }
  47. // RepoPath returns pull request repo path
  48. func (p PullRequestBranch) RepoPath() string {
  49. return fmt.Sprintf("%s/%s", p.OwnerName, p.RepoName)
  50. }