MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / findLinearIssuesForPRs

Function findLinearIssuesForPRs

scripts/tagLinearIssuesWithRelease.mjs:90–148  ·  view source on GitHub ↗

* Find Linear issues that have attachments linking to the given GitHub PRs

(prNumbers)

Source from the content-addressed store, hash-verified

88 * Find Linear issues that have attachments linking to the given GitHub PRs
89 */
90async function findLinearIssuesForPRs(prNumbers) {
91 const issues = [];
92
93 for (const prNumber of prNumbers) {
94 const prUrl = `https://github.com/${GITHUB_REPO}/pull/${prNumber}`;
95
96 // Query Linear for attachments that match this PR URL
97 const data = await linearGraphQL(
98 `
99 query($url: String!) {
100 attachmentsForURL(url: $url) {
101 nodes {
102 id
103 url
104 issue {
105 id
106 identifier
107 title
108 labels {
109 nodes {
110 id
111 name
112 }
113 }
114 }
115 }
116 }
117 }
118 `,
119 { url: prUrl }
120 );
121
122 if (data.attachmentsForURL?.nodes) {
123 for (const attachment of data.attachmentsForURL.nodes) {
124 if (attachment.issue) {
125 issues.push({
126 issueId: attachment.issue.id,
127 identifier: attachment.issue.identifier,
128 title: attachment.issue.title,
129 existingLabels: attachment.issue.labels?.nodes || [],
130 prNumber,
131 });
132 }
133 }
134 }
135 }
136
137 // Remove duplicate issues (same issue might be linked to multiple PRs)
138 const uniqueIssues = [];
139 const seenIds = new Set();
140 for (const issue of issues) {
141 if (!seenIds.has(issue.issueId)) {
142 seenIds.add(issue.issueId);
143 uniqueIssues.push(issue);
144 }
145 }
146
147 return uniqueIssues;

Callers 1

mainFunction · 0.85

Calls 1

linearGraphQLFunction · 0.85

Tested by

no test coverage detected