MCPcopy Index your code
hub / github.com/utterance/utterances / loadIssueByTerm

Function loadIssueByTerm

src/github.ts:133–159  ·  view source on GitHub ↗
(term: string)

Source from the content-addressed store, hash-verified

131}
132
133export function loadIssueByTerm(term: string) {
134 const q = `"${term}" type:issue in:title repo:${owner}/${repo}`;
135 const request = githubRequest(`search/issues?q=${encodeURIComponent(q)}&sort=created&order=asc`);
136 return githubFetch(request).then<IssueSearchResponse>(response => {
137 if (!response.ok) {
138 throw new Error('Error fetching issue via search.');
139 }
140 return response.json();
141 }).then(results => {
142 if (results.total_count === 0) {
143 return null;
144 }
145 if (results.total_count > 1) {
146 // tslint:disable-next-line:no-console
147 console.warn(`Multiple issues match "${q}".`);
148 }
149 term = term.toLowerCase();
150 for (const result of results.items) {
151 if (result.title.toLowerCase().indexOf(term) !== -1) {
152 return result;
153 }
154 }
155 // tslint:disable-next-line:no-console
156 console.warn(`Issue search results do not contain an issue with title matching "${term}". Using first result.`);
157 return results.items[0];
158 });
159}
160
161export function loadIssueByNumber(issueNumber: number) {
162 const request = githubRequest(`repos/${owner}/${repo}/issues/${issueNumber}`);

Callers 1

loadIssueFunction · 0.90

Calls 2

githubRequestFunction · 0.85
githubFetchFunction · 0.85

Tested by

no test coverage detected