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.3 kB

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