@preventive/triage 1.0.0-alpha.76 → 1.0.0-alpha.77

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.
@@ -106,28 +106,39 @@ export function reviewsOf(pkg: LockedPackage, reviews: ReviewsOf): PublishedRevi
106
106
  export const comparedWith = (review: PublishedReview, pkg: LockedPackage, bases: string[] | 'any') => review.basePackage === null
107
107
  || review.basePackage !== pkg.name || bases === 'any' || bases.includes(review.baseVersion ?? '')
108
108
 
109
- const ACCEPTING = new Set(['accept', 'accept-with-nits'])
109
+ // The latest of `reviews`, some, the first of those as late.
110
+ export const latestOf = (reviews: PublishedReview[]) => reviews.reduce((one, other) => other.time > one.time ? other : one)
111
+ // What a review compares its version with, as one continued from it in a new
112
+ // review does too: none (whole), or a package's version; one a pull
113
+ // request's comments make, which revises no review here, of its comments.
114
+ const comparisonOf = (review: PublishedReview) => review.comment ? '\0comment' : review.basePackage === null ? '' : `${review.basePackage}@${review.baseVersion ?? ''}`
115
+
116
+ export const ACCEPTING = new Set(['accept', 'accept-with-nits'])
110
117
  // Where `pkg`'s reviewers stand on it among `reviews`, those of its version,
111
118
  // of an integrity it is locked with, and of its patch: each one's latest
112
- // telling it, any rejecting it holding it unreviewed (`rejected`); those
113
- // accepting it passing it (`passing`), each once, by a full, accepting
114
- // review of theirs, whole, compared with another package's version, or
115
- // compared with one of `bases` of its own (any, for `any`); and how many review it in its pull request's comments
116
- // alone (`commented`), which count for it alone: whose reviews passing it,
117
- // else whose latest, are its comments'. Each reviewer too (`reviewers`), by
118
- // their login, their latest verdict, whether they pass it, and whether that
119
- // verdict is its comments' (`comment`), which counts for it alone.
119
+ // telling it, whatever it was compared with, any rejecting it holding it
120
+ // unreviewed (`rejected`), any not accepting it holding each of theirs
121
+ // before it; those accepting it passing it (`passing`), each once, by a
122
+ // full, accepting review of theirs, the latest of its comparison, which
123
+ // revises those of it before, whole, compared with another package's
124
+ // version, or compared with one of `bases` of its own (any, for `any`); and
125
+ // how many review it in its pull request's comments alone (`commented`),
126
+ // which count for it alone: whose reviews passing it, else whose latest, are
127
+ // its comments'. Each reviewer too (`reviewers`), by their login, their
128
+ // latest verdict, whether they pass it, and whether that verdict is its
129
+ // comments' (`comment`), which counts for it alone.
120
130
  function stancesOf(pkg: LockedPackage, reviews: ReviewsOf, bases: string[] | 'any') {
121
131
  const by = Map.groupBy(reviewsOf(pkg, reviews), review => review.reviewer)
122
132
  const qualifies = (review: PublishedReview) => review.full && ACCEPTING.has(review.status) && comparedWith(review, pkg, bases)
123
133
  let commented = 0, passing = 0, rejected = false
124
134
  const reviewers: Reviewer[] = []
125
135
  for (const theirs of by.values()) {
126
- const latest = theirs.reduce((one, other) => other.time > one.time ? other : one)
127
- const passes = ACCEPTING.has(latest.status) && theirs.some(qualifies)
136
+ const latest = latestOf(theirs)
137
+ const current = [...Map.groupBy(theirs, comparisonOf).values()].map(latestOf).filter(qualifies)
138
+ const passes = ACCEPTING.has(latest.status) && current.length > 0
128
139
  // In its comments alone where those telling where they stand are: those
129
140
  // passing it, where they pass it, else their latest.
130
- const comment = (passes ? theirs.filter(qualifies) : [latest]).every(review => review.comment)
141
+ const comment = (passes ? current : [latest]).every(review => review.comment)
131
142
  if (comment) commented++
132
143
  if (latest.status === 'reject') rejected = true
133
144
  else if (passes) passing++