MCPcopy Create free account
hub / github.com/remix-run/react-router / comment

Function comment

scripts/previews/pr.ts:69–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67}
68
69async function comment() {
70 let commentBody = `\
71${STICKY_MARKER}
72### Preview Build Available
73
74Preview builds have been created for this PR. You can install \`react-router\` using:
75
76\`\`\`sh
77pnpm install "remix-run/react-router#${branch}&path:packages/react-router"
78\`\`\`
79
80And/or install other packages via:
81
82\`\`\`sh
83pnpm install "remix-run/react-router#${branch}&path:packages/react-router-dev"
84pnpm install "remix-run/react-router#${branch}&path:packages/react-router-express"
85pnpm install "remix-run/react-router#${branch}&path:packages/react-router-node"
86pnpm install "remix-run/react-router#${branch}&path:packages/react-router-serve"
87\`\`\`
88
89These preview builds will be updated automatically as you push new commits.`;
90
91 // Get existing comments
92 let comments = await getPrComments(prNumber);
93
94 // Only add a comment if one doesn't already exist
95 let stickyComment = comments.find((comment) =>
96 comment.body?.includes(STICKY_MARKER),
97 );
98 if (stickyComment) {
99 console.log("Updating preview comment on PR");
100 await updatePrComment(stickyComment.id, commentBody);
101 } else {
102 console.log("Adding preview comment to PR");
103 await createPrComment(prNumber, commentBody);
104 }
105
106 // Delete cleanup comment if it exists
107 let cleanupComment = comments.find((comment) =>
108 comment.body?.includes(CLEANUP_MARKER),
109 );
110 if (cleanupComment) {
111 console.log("Deleting existing cleanup comment");
112 await deletePrComment(cleanupComment.id);
113 }
114}
115
116async function cleanup() {
117 console.log(`Deleted branch: ${branch}`);

Callers

nothing calls this directly

Calls 5

getPrCommentsFunction · 0.90
updatePrCommentFunction · 0.90
createPrCommentFunction · 0.90
deletePrCommentFunction · 0.90
logMethod · 0.80

Tested by

no test coverage detected