GetIssueByRef returns an Issue specified by a GFM reference, e.g. owner/repo#123.
(ref string)
| 823 | |
| 824 | // GetIssueByRef returns an Issue specified by a GFM reference, e.g. owner/repo#123. |
| 825 | func 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. |
| 850 | func GetRawIssueByIndex(repoID, index int64) (*Issue, error) { |
no test coverage detected