MCPcopy Create free account
hub / github.com/gogs/gogs / GetIssueByRef

Function GetIssueByRef

internal/database/issue.go:825–847  ·  view source on GitHub ↗

GetIssueByRef returns an Issue specified by a GFM reference, e.g. owner/repo#123.

(ref string)

Source from the content-addressed store, hash-verified

823
824// GetIssueByRef returns an Issue specified by a GFM reference, e.g. owner/repo#123.
825func GetIssueByRef(ref string) (*Issue, error) {
826 n := strings.IndexByte(ref, byte('#'))
827 if n == -1 {
828 return nil, ErrIssueNotExist{args: map[string]any{"ref": ref}}
829 }
830
831 index := com.StrTo(ref[n+1:]).MustInt64()
832 if index == 0 {
833 return nil, ErrIssueNotExist{args: map[string]any{"ref": ref}}
834 }
835
836 repo, err := GetRepositoryByRef(ref[:n])
837 if err != nil {
838 return nil, err
839 }
840
841 issue, err := GetIssueByIndex(repo.ID, index)
842 if err != nil {
843 return nil, err
844 }
845
846 return issue, issue.LoadAttributes()
847}
848
849// GetRawIssueByIndex returns raw issue without loading attributes by index in a repository.
850func GetRawIssueByIndex(repoID, index int64) (*Issue, error) {

Callers 1

Calls 3

GetRepositoryByRefFunction · 0.85
GetIssueByIndexFunction · 0.85
LoadAttributesMethod · 0.45

Tested by

no test coverage detected