// Package gitea is a small read-mostly client for the Gitea REST API covering // the endpoints teabot needs: listing issues, pull requests, and comments. package gitea import "time" // User is the subset of a Gitea user teabot cares about. type User struct { Login string `json:"login"` ID int64 `json:"id"` } // Issue represents a Gitea issue. Gitea's issues endpoint also returns pull // requests; the PullRequest field is non-nil for those. type Issue struct { ID int64 `json:"id"` Index int64 `json:"number"` Title string `json:"title"` Body string `json:"body"` State string `json:"state"` Poster User `json:"user"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` HTMLURL string `json:"html_url"` PullRequest *PullRequestRef `json:"pull_request,omitempty"` } // IsPull reports whether this issue is actually a pull request. func (i Issue) IsPull() bool { return i.PullRequest != nil } // PullRequestRef is the marker Gitea attaches to issues that are PRs. type PullRequestRef struct { Merged bool `json:"merged"` } // PullRequest represents a Gitea pull request. type PullRequest struct { ID int64 `json:"id"` Index int64 `json:"number"` Title string `json:"title"` Body string `json:"body"` State string `json:"state"` Poster User `json:"user"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` HTMLURL string `json:"html_url"` Head Branch `json:"head"` Base Branch `json:"base"` } // Branch is one side of a pull request. type Branch struct { Ref string `json:"ref"` Sha string `json:"sha"` } // Comment is a comment on an issue or pull request. type Comment struct { ID int64 `json:"id"` Body string `json:"body"` Poster User `json:"user"` Created time.Time `json:"created_at"` Updated time.Time `json:"updated_at"` HTMLURL string `json:"html_url"` IssueURL string `json:"issue_url"` PRURL string `json:"pull_request_url"` }