* Close notes issue when entry is deleted
(collectionName: string, slug: string)
| 1958 | * Close notes issue when entry is deleted |
| 1959 | */ |
| 1960 | async closeEntryNotesIssue(collectionName: string, slug: string): Promise<void> { |
| 1961 | try { |
| 1962 | const searchQuery = `repo:${this.repo} label:${API.NOTES_LABEL} "${collectionName}/${slug}" in:body state:open`; |
| 1963 | const searchResponse = await this.request('/search/issues', { |
| 1964 | params: { q: searchQuery }, |
| 1965 | }); |
| 1966 | |
| 1967 | if (searchResponse.items && searchResponse.items.length > 0) { |
| 1968 | const issue = searchResponse.items[0]; |
| 1969 | await this.request(`${this.repoURL}/issues/${issue.number}`, { |
| 1970 | method: 'PATCH', |
| 1971 | body: JSON.stringify({ |
| 1972 | state: 'closed', |
| 1973 | labels: [...(issue.labels || []).map((l: { name: string }) => l.name), 'entry-deleted'], |
| 1974 | }), |
| 1975 | }); |
| 1976 | } |
| 1977 | } catch (error) { |
| 1978 | console.warn('Failed to close notes issue:', error); |
| 1979 | } |
| 1980 | } |
| 1981 | |
| 1982 | /** |
| 1983 | * Get PR metadata from branch name |
no test coverage detected