MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / findOrCreateReleaseLabel

Function findOrCreateReleaseLabel

scripts/tagLinearIssuesWithRelease.mjs:176–227  ·  view source on GitHub ↗

* Find or create a label for the release version

(teamId, version)

Source from the content-addressed store, hash-verified

174 * Find or create a label for the release version
175 */
176async function findOrCreateReleaseLabel(teamId, version) {
177 const labelName = `v${version}`;
178
179 // First, search for existing label
180 const searchData = await linearGraphQL(
181 `
182 query($teamId: String!) {
183 team(id: $teamId) {
184 labels {
185 nodes {
186 id
187 name
188 }
189 }
190 }
191 }
192 `,
193 { teamId }
194 );
195
196 const existingLabel = searchData.team?.labels?.nodes?.find(
197 (label) => label.name === labelName
198 );
199
200 if (existingLabel) {
201 console.log(`Found existing label: ${labelName}`);
202 return existingLabel.id;
203 }
204
205 // Create the label if it doesn't exist
206 console.log(`Creating new label: ${labelName}`);
207 const createData = await linearGraphQL(
208 `
209 mutation($teamId: String!, $name: String!) {
210 issueLabelCreate(input: { teamId: $teamId, name: $name, color: "#10B981" }) {
211 issueLabel {
212 id
213 name
214 }
215 success
216 }
217 }
218 `,
219 { teamId, name: labelName }
220 );
221
222 if (!createData.issueLabelCreate?.success) {
223 throw new Error(`Failed to create label: ${labelName}`);
224 }
225
226 return createData.issueLabelCreate.issueLabel.id;
227}
228
229/**
230 * Add a label to an issue

Callers 1

mainFunction · 0.85

Calls 1

linearGraphQLFunction · 0.85

Tested by

no test coverage detected