本站源代码
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.

55 lines
1.3KB

  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. Closed *time.Time
  22. Labels []*Label
  23. PatchURL string
  24. Merged bool
  25. MergedTime *time.Time
  26. MergeCommitSHA string
  27. Head PullRequestBranch
  28. Base PullRequestBranch
  29. Assignee string
  30. Assignees []string
  31. IsLocked bool
  32. }
  33. // IsForkPullRequest returns true if the pull request from a forked repository but not the same repository
  34. func (p *PullRequest) IsForkPullRequest() bool {
  35. return p.Head.RepoPath() != p.Base.RepoPath()
  36. }
  37. // PullRequestBranch represents a pull request branch
  38. type PullRequestBranch struct {
  39. CloneURL string
  40. Ref string
  41. SHA string
  42. RepoName string
  43. OwnerName string
  44. }
  45. // RepoPath returns pull request repo path
  46. func (p PullRequestBranch) RepoPath() string {
  47. return fmt.Sprintf("%s/%s", p.OwnerName, p.RepoName)
  48. }
上海开阖软件有限公司 沪ICP备12045867号-1