@jphutchins/code-review 0.1.0-alpha.59 → 0.1.0-alpha.60

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.
package/dist/index.js CHANGED
@@ -2903,14 +2903,30 @@ var postInlineReview = async (pr, comments, inDiff, ghApi) => {
2903
2903
  const reviewsEndpoint = [`repos/${pr.repo}/pulls/${String(pr.prNumber)}/reviews`, "--input", "-"];
2904
2904
  try {
2905
2905
  const stdout = await ghApi(reviewsEndpoint, reviewBody(true));
2906
- return { url: parseHtmlUrl(stdout), inlinePosted: comments.length, unposted: [] };
2906
+ return { url: parseHtmlUrl(stdout), posted: true, inlinePosted: comments.length, unposted: [] };
2907
2907
  } catch (err) {
2908
- if (comments.length === 0) throw err;
2908
+ if (comments.length === 0) {
2909
+ process.stderr.write(
2910
+ `::warning:: the review-object POST on PR #${String(pr.prNumber)} failed (${errMsg(err)}) \u2014 the sticky carries the review, but no diff-anchored review object exists this round
2911
+ `
2912
+ );
2913
+ return { url: void 0, posted: false, inlinePosted: 0, unposted: [] };
2914
+ }
2909
2915
  process.stderr.write(
2910
2916
  `Warning: the batched inline review on PR #${String(pr.prNumber)} was rejected (${errMsg(err)}) \u2014 posting the review body-only, then each comment individually to keep the ones GitHub accepts (issue #57)
2911
2917
  `
2912
2918
  );
2913
- const url = parseHtmlUrl(await ghApi(reviewsEndpoint, reviewBody(false)));
2919
+ let url;
2920
+ let posted = false;
2921
+ try {
2922
+ url = parseHtmlUrl(await ghApi(reviewsEndpoint, reviewBody(false)));
2923
+ posted = true;
2924
+ } catch (bodyErr) {
2925
+ process.stderr.write(
2926
+ `::warning:: the body-only review retry on PR #${String(pr.prNumber)} failed (${errMsg(bodyErr)}) \u2014 individual comments still re-post, but no breadcrumb review object exists this round
2927
+ `
2928
+ );
2929
+ }
2914
2930
  const commentsEndpoint = [
2915
2931
  `repos/${pr.repo}/pulls/${String(pr.prNumber)}/comments`,
2916
2932
  "--input",
@@ -2934,7 +2950,7 @@ var postInlineReview = async (pr, comments, inDiff, ghApi) => {
2934
2950
  );
2935
2951
  }
2936
2952
  }
2937
- return { url, inlinePosted, unposted };
2953
+ return { url, posted, inlinePosted, unposted };
2938
2954
  }
2939
2955
  };
2940
2956
  var ISSUE_COMMENTS_JQ = '.[] | {id, user: (.user.login // "(deleted)"), created_at, html_url, body: (.body // "")}';
@@ -3731,6 +3747,7 @@ ${dropNote}` : ""}`,
3731
3747
  );
3732
3748
  const {
3733
3749
  url: reviewUrl,
3750
+ posted: reviewObjectPosted,
3734
3751
  inlinePosted,
3735
3752
  unposted
3736
3753
  } = await postInlineReview(
@@ -3746,15 +3763,19 @@ ${dropNote}` : ""}`,
3746
3763
  ghApi
3747
3764
  );
3748
3765
  process.stderr.write(
3749
- inlineRequested ? `Posted a review with ${String(inlinePosted)} inline comment(s) on PR #${String(prNumber)}
3766
+ reviewObjectPosted ? inlineRequested ? `Posted a review with ${String(inlinePosted)} inline comment(s) on PR #${String(prNumber)}
3750
3767
  ` : `Posted a body-only review on PR #${String(prNumber)}; the findings are in the sticky
3768
+ ` : inlinePosted > 0 ? `No review object posted this round on PR #${String(prNumber)}, but ${String(inlinePosted)} inline comment(s) anchored \u2014 the sticky carries the review
3769
+ ` : `No review object posted this round on PR #${String(prNumber)} \u2014 the sticky carries the review
3751
3770
  `
3752
3771
  );
3753
3772
  const priorReviewIds = botReviews.map((r) => r.id);
3754
- if (priorReviewIds.length > 0) {
3773
+ if (reviewObjectPosted && priorReviewIds.length > 0) {
3755
3774
  await dismissReviews(input.repo, prNumber, priorReviewIds, ghApi);
3756
3775
  }
3757
- await minimizeComments(prNumber, priorInlineComments, ghApi);
3776
+ if (reviewObjectPosted || inlinePosted > 0) {
3777
+ await minimizeComments(prNumber, priorInlineComments, ghApi);
3778
+ }
3758
3779
  const unanchoredCount = unposted.length;
3759
3780
  const finalStrays = unanchoredCount > 0 ? [...unposted, ...strays] : strays;
3760
3781
  const finalDiscussion = unanchoredCount > 0 ? buildStickyDiscussion(