@staff0rd/assist 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +17 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -81,7 +81,7 @@ function commit(message) {
81
81
  execSync(`git commit -m "${message.replace(/"/g, '\\"')}"`, {
82
82
  stdio: "inherit"
83
83
  });
84
- const sha = execSync("git rev-parse --short=6 HEAD", {
84
+ const sha = execSync("git rev-parse --short=7 HEAD", {
85
85
  encoding: "utf-8"
86
86
  }).trim();
87
87
  console.log(`Committed: ${sha}`);
@@ -2113,7 +2113,7 @@ function printComments(comments) {
2113
2113
  }
2114
2114
  }
2115
2115
  function fetchThreadIds(org, repo, prNumber) {
2116
- const query = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id comments(first: 100) { nodes { databaseId } } } } } } }`;
2116
+ const query = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id isResolved comments(first: 100) { nodes { databaseId } } } } } } }`;
2117
2117
  const queryFile = join9(tmpdir(), `gh-query-${Date.now()}.graphql`);
2118
2118
  writeFileSync9(queryFile, query);
2119
2119
  try {
@@ -2123,12 +2123,16 @@ function fetchThreadIds(org, repo, prNumber) {
2123
2123
  );
2124
2124
  const response = JSON.parse(result);
2125
2125
  const threadMap = /* @__PURE__ */ new Map();
2126
+ const resolvedThreadIds = /* @__PURE__ */ new Set();
2126
2127
  for (const thread of response.data.repository.pullRequest.reviewThreads.nodes) {
2128
+ if (thread.isResolved) {
2129
+ resolvedThreadIds.add(thread.id);
2130
+ }
2127
2131
  for (const comment of thread.comments.nodes) {
2128
2132
  threadMap.set(comment.databaseId, thread.id);
2129
2133
  }
2130
2134
  }
2131
- return threadMap;
2135
+ return { threadMap, resolvedThreadIds };
2132
2136
  } finally {
2133
2137
  unlinkSync2(queryFile);
2134
2138
  }
@@ -2151,7 +2155,11 @@ async function listComments() {
2151
2155
  const prNumber = getCurrentPrNumber();
2152
2156
  const { org, repo } = getRepoInfo();
2153
2157
  const allComments = [];
2154
- const threadMap = fetchThreadIds(org, repo, prNumber);
2158
+ const { threadMap, resolvedThreadIds } = fetchThreadIds(
2159
+ org,
2160
+ repo,
2161
+ prNumber
2162
+ );
2155
2163
  const reviewResult = execSync12(
2156
2164
  `gh api repos/${org}/${repo}/pulls/${prNumber}/reviews`,
2157
2165
  { encoding: "utf-8" }
@@ -2177,10 +2185,14 @@ async function listComments() {
2177
2185
  if (lineResult.trim()) {
2178
2186
  const lineComments = JSON.parse(lineResult);
2179
2187
  for (const comment of lineComments) {
2188
+ const threadId = threadMap.get(comment.id) ?? "";
2189
+ if (resolvedThreadIds.has(threadId)) {
2190
+ continue;
2191
+ }
2180
2192
  allComments.push({
2181
2193
  type: "line",
2182
2194
  id: comment.id,
2183
- threadId: threadMap.get(comment.id) ?? "",
2195
+ threadId,
2184
2196
  user: comment.user.login,
2185
2197
  path: comment.path,
2186
2198
  line: comment.line,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {