Skip to content

Commit 6a957b8

Browse files
committed
Show unresolved comments in the approved column
Instead of a separate comments column in the status grid, fold the unresolved-comments state into the approved column as a third value: 💬 means approved but has unresolved comments. This keeps the grid compact while surfacing the feedback signal where it belongs. A PR with unresolved comments is still considered mergeable (matches isMergeable behavior). Also truncate status subjects at 72 characters, share the truncateSubject helper between status and compare, and generate permalinks in the stub client so the status preview test renders URLs like real output does. commit-id: Ic91df327
1 parent e2288f5 commit 6a957b8

4 files changed

Lines changed: 86 additions & 89 deletions

File tree

‎git-jaspr/src/main/kotlin/sims/michael/gitjaspr/Compare.kt‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,6 @@ fun renderCompare(
275275
*/
276276
const val DEFAULT_MAX_SUBJECT_LENGTH = 50
277277

278-
private fun truncateSubject(subject: String, max: Int): String =
279-
if (subject.length <= max) subject else subject.take(max - 1) + "…"
280-
281278
private fun formatCell(
282279
row: CompareRow,
283280
isLocal: Boolean,

‎git-jaspr/src/main/kotlin/sims/michael/gitjaspr/GitJaspr.kt‎

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ class GitJaspr(
233233
} else {
234234
statuses.fold(emptyList()) { currentStack, status ->
235235
val allFlagsAreSuccess =
236-
status.toStatusList(commitsWithDuplicateIds).all { it == SUCCESS }
236+
status.toStatusList(commitsWithDuplicateIds).all {
237+
it == SUCCESS || it == COMMENT
238+
}
237239
val currentStackIsAllTrue = currentStack.all { it }
238240
currentStack + (currentStackIsAllTrue && allFlagsAreSuccess)
239241
}
@@ -245,8 +247,7 @@ class GitJaspr(
245247
val lineContent = buildString {
246248
append("[")
247249
val flags = status.toStatusList(commitsWithDuplicateIds)
248-
val commentsFlag = status.toCommentsFlag()
249-
val statusList = flags + commentsFlag + if (stackCheck) SUCCESS else EMPTY
250+
val statusList = flags + if (stackCheck) SUCCESS else EMPTY
250251
// On the cursor row, skip styles that use ANSI intensity (dim) -- their inner
251252
// resets fight the outer bold wrap and the result reads as visually uneven.
252253
// Specifically: theme.muted on EMPTY and theme.hash on the SHA both use dim.
@@ -265,7 +266,9 @@ class GitJaspr(
265266
append(theme.url(status.pullRequest.permalink))
266267
append(" : ")
267268
}
268-
append(theme.value(status.localCommit.shortMessage))
269+
val subject = status.localCommit.shortMessage
270+
val truncatedSubject = truncateSubject(subject, MAX_STATUS_SUBJECT_LENGTH)
271+
append(theme.value(truncatedSubject))
269272
}
270273
appendLine(if (isCursor) theme.emphasis(lineContent) else lineContent)
271274
}
@@ -2100,20 +2103,13 @@ class GitJaspr(
21002103
when {
21012104
pullRequest == null -> EMPTY
21022105
approved == null -> EMPTY
2106+
approved == true && (unresolvedReviewThreadCount ?: 0) > 0 -> COMMENT
21032107
approved -> SUCCESS
21042108
else -> FAIL
21052109
},
21062110
)
21072111
.toList()
21082112

2109-
private fun RemoteCommitStatus.toCommentsFlag() =
2110-
when {
2111-
pullRequest == null -> EMPTY
2112-
unresolvedReviewThreadCount == null -> EMPTY
2113-
unresolvedReviewThreadCount > 0 -> COMMENT
2114-
else -> SUCCESS
2115-
}
2116-
21172113
private fun List<PullRequest>.updateDescriptionsWithStackInfo(
21182114
stack: List<Commit>,
21192115
stackName: String? = null,
@@ -4152,16 +4148,16 @@ class GitJaspr(
41524148

41534149
private val HEADER =
41544150
"""
4155-
| ┌───────────── commit pushed
4156-
| │ ┌───────────── exists ┐
4157-
| │ │ ┌─────────── checks pass │
4158-
| │ │ │ ┌───────── ready │ PR
4159-
| │ │ │ │ ┌─────── approved │
4160-
| │ │ │ │ │ ┌───── comments ┘
4161-
| │ │ │ │ │ │ ┌─ stack check
4162-
| │ │ │ │ │ │ │
4151+
| ┌─────────── commit pushed
4152+
| │ ┌─────────── exists ┐
4153+
| │ │ ┌───────── checks pass │
4154+
| │ │ │ ┌─────── ready │ PR
4155+
| │ │ │ │ ┌───── approved ┘
4156+
| │ │ │ │ │ ┌─ stack check
4157+
| │ │ │ │ │ │
41634158
|"""
41644159
.trimMargin()
4160+
private const val MAX_STATUS_SUBJECT_LENGTH = 72
41654161
private const val COMMIT_MSG_HOOK = "commit-msg"
41664162
private const val POST_CHECKOUT_HOOK = "post-checkout"
41674163
private const val POST_CHECKOUT_HOOK_RESOURCE = "post-checkout-jaspr-section"
@@ -4186,3 +4182,6 @@ fun <T : Any> Iterable<T>.windowedPairs(): List<Pair<T?, T>> {
41864182

41874183
/** Convert [ZonedDateTime] to the simplest representation as an offset from UTC. */
41884184
fun ZonedDateTime.canonicalize(): ZonedDateTime = toOffsetDateTime().toZonedDateTime()
4185+
4186+
fun truncateSubject(subject: String, max: Int): String =
4187+
if (subject.length <= max) subject else subject.take(max - 1) + "…"

‎git-jaspr/src/test/kotlin/sims/michael/gitjaspr/GitJasprTest.kt‎

Lines changed: 64 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,9 +3262,9 @@ interface GitJasprTest {
32623262
val actual = getAndPrintStatusString()
32633263
assertEquals(
32643264
"""
3265-
|[ㄧㄧㄧㄧㄧㄧㄧ] %s : three
3266-
|[ㄧㄧㄧㄧㄧㄧㄧ] %s : two
3267-
|[ㄧㄧㄧㄧㄧㄧㄧ] %s : one
3265+
|[ㄧㄧㄧㄧㄧㄧ] %s : three
3266+
|[ㄧㄧㄧㄧㄧㄧ] %s : two
3267+
|[ㄧㄧㄧㄧㄧㄧ] %s : one
32683268
"""
32693269
.trimMargin()
32703270
.toStatusString(actual),
@@ -3296,9 +3296,9 @@ interface GitJasprTest {
32963296
val actual = getAndPrintStatusString()
32973297
assertEquals(
32983298
"""
3299-
|[ㄧㄧㄧㄧㄧㄧㄧ] %s : three
3300-
|[ㄧㄧㄧㄧㄧㄧㄧ] %s : two
3301-
|[✅ㄧㄧㄧㄧㄧㄧ] %s : one
3299+
|[ㄧㄧㄧㄧㄧㄧ] %s : three
3300+
|[ㄧㄧㄧㄧㄧㄧ] %s : two
3301+
|[✅ㄧㄧㄧㄧㄧ] %s : one
33023302
"""
33033303
.trimMargin()
33043304
.toStatusString(actual),
@@ -3335,9 +3335,9 @@ interface GitJasprTest {
33353335
val actual = getAndPrintStatusString()
33363336
assertEquals(
33373337
"""
3338-
|[ㄧㄧㄧㄧㄧㄧㄧ] %s : three
3339-
|[ㄧㄧㄧㄧㄧㄧㄧ] %s : two
3340-
|[✅✅⌛✅ㄧ✅ㄧ] %s : %s : one
3338+
|[ㄧㄧㄧㄧㄧㄧ] %s : three
3339+
|[ㄧㄧㄧㄧㄧㄧ] %s : two
3340+
|[✅✅⌛✅ㄧㄧ] %s : %s : one
33413341
"""
33423342
.trimMargin()
33433343
.toStatusString(actual),
@@ -3377,9 +3377,9 @@ interface GitJasprTest {
33773377
val actual = getAndPrintStatusString()
33783378
assertEquals(
33793379
"""
3380-
|[ㄧㄧㄧㄧㄧㄧㄧ] %s : three
3381-
|[ㄧㄧㄧㄧㄧㄧㄧ] %s : two
3382-
|[✅✅✅✅ㄧ✅ㄧ] %s : %s : one
3380+
|[ㄧㄧㄧㄧㄧㄧ] %s : three
3381+
|[ㄧㄧㄧㄧㄧㄧ] %s : two
3382+
|[✅✅✅✅ㄧㄧ] %s : %s : one
33833383
"""
33843384
.trimMargin()
33853385
.toStatusString(actual),
@@ -3436,9 +3436,9 @@ interface GitJasprTest {
34363436
val actual = getAndPrintStatusString()
34373437
assertEquals(
34383438
"""
3439-
|[✅✅✅✅ㄧ✅ㄧ] %s : %s : three
3440-
|[✅✅✅✅ㄧ✅ㄧ] %s : %s : two
3441-
|[✅✅✅✅✅✅✅] %s : %s : one
3439+
|[✅✅✅✅ㄧㄧ] %s : %s : three
3440+
|[✅✅✅✅ㄧㄧ] %s : %s : two
3441+
|[✅✅✅✅✅✅] %s : %s : one
34423442
"""
34433443
.trimMargin()
34443444
.toStatusString(actual),
@@ -3487,8 +3487,8 @@ interface GitJasprTest {
34873487
val actual = getAndPrintStatusString()
34883488
assertEquals(
34893489
"""
3490-
|[✅✅✅✅✅💬✅] %s : %s : two
3491-
|[✅✅✅✅✅✅✅] %s : %s : one
3490+
|[✅✅✅✅💬✅] %s : %s : two
3491+
|[✅✅✅✅✅✅] %s : %s : one
34923492
"""
34933493
.trimMargin()
34943494
.toStatusString(actual),
@@ -3556,9 +3556,9 @@ interface GitJasprTest {
35563556
val actual = getAndPrintStatusString()
35573557
assertEquals(
35583558
"""
3559-
|[✅✅✅✅✅✅ㄧ] %s : %s : three
3560-
|[✅✅✅✅✅✅ㄧ] %s : %s : two
3561-
|[✅✅✅✅✅✅ㄧ] %s : %s : one
3559+
|[✅✅✅✅✅ㄧ] %s : %s : three
3560+
|[✅✅✅✅✅ㄧ] %s : %s : two
3561+
|[✅✅✅✅✅ㄧ] %s : %s : one
35623562
|
35633563
|Your stack is out-of-date with the base branch (1 commit behind main).
35643564
|You'll need to rebase it (`jaspr rebase`) before your stack will be mergeable.
@@ -3630,9 +3630,9 @@ interface GitJasprTest {
36303630
val actual = getAndPrintStatusString()
36313631
assertEquals(
36323632
"""
3633-
|[✅✅✅✅✅✅ㄧ] %s : %s : three
3634-
|[✅✅✅✅✅✅ㄧ] %s : %s : two
3635-
|[✅✅✅✅✅✅ㄧ] %s : %s : one
3633+
|[✅✅✅✅✅ㄧ] %s : %s : three
3634+
|[✅✅✅✅✅ㄧ] %s : %s : two
3635+
|[✅✅✅✅✅ㄧ] %s : %s : one
36363636
|
36373637
|Your stack is out-of-date with the base branch (2 commits behind main).
36383638
|You'll need to rebase it (`jaspr rebase`) before your stack will be mergeable.
@@ -3694,9 +3694,9 @@ interface GitJasprTest {
36943694
val actual = getAndPrintStatusString()
36953695
assertEquals(
36963696
"""
3697-
|[✅✅✅✅✅✅✅] %s : %s : three
3698-
|[✅✅✅✅✅✅✅] %s : %s : two
3699-
|[✅✅✅✅✅✅✅] %s : %s : one
3697+
|[✅✅✅✅✅✅] %s : %s : three
3698+
|[✅✅✅✅✅✅] %s : %s : two
3699+
|[✅✅✅✅✅✅] %s : %s : one
37003700
"""
37013701
.trimMargin()
37023702
.toStatusString(actual),
@@ -3758,9 +3758,9 @@ interface GitJasprTest {
37583758
val actual = getAndPrintStatusString()
37593759
assertEquals(
37603760
"""
3761-
|[✅✅✅ㄧ✅✅ㄧ] %s : %s : draft: three
3762-
|[✅✅✅✅✅✅✅] %s : %s : two
3763-
|[✅✅✅✅✅✅✅] %s : %s : one
3761+
|[✅✅✅ㄧ✅ㄧ] %s : %s : draft: three
3762+
|[✅✅✅✅✅✅] %s : %s : two
3763+
|[✅✅✅✅✅✅] %s : %s : one
37643764
"""
37653765
.trimMargin()
37663766
.toStatusString(actual),
@@ -3820,9 +3820,9 @@ interface GitJasprTest {
38203820
val actual = getAndPrintStatusString()
38213821
assertEventuallyEquals(
38223822
"""
3823-
|[✅✅✅✅ㄧ✅ㄧ] %s : %s : three
3824-
|[✅✅✅✅✅✅ㄧ] %s : %s : two
3825-
|[✅✅✅✅ㄧ✅ㄧ] %s : %s : one
3823+
|[✅✅✅✅ㄧㄧ] %s : %s : three
3824+
|[✅✅✅✅✅ㄧ] %s : %s : two
3825+
|[✅✅✅✅ㄧㄧ] %s : %s : one
38263826
"""
38273827
.trimMargin()
38283828
.toStatusString(actual, NamedStackInfo(stackName, 0, 0, remoteName)),
@@ -3881,9 +3881,9 @@ interface GitJasprTest {
38813881
val actual = getAndPrintStatusString()
38823882
assertEquals(
38833883
"""
3884-
|[✅✅✅✅ㄧ✅ㄧ] %s : %s : three
3885-
|[✅✅❌✅ㄧ✅ㄧ] %s : %s : two
3886-
|[✅✅✅✅ㄧ✅ㄧ] %s : %s : one
3884+
|[✅✅✅✅ㄧㄧ] %s : %s : three
3885+
|[✅✅❌✅ㄧㄧ] %s : %s : two
3886+
|[✅✅✅✅ㄧㄧ] %s : %s : one
38873887
"""
38883888
.trimMargin()
38893889
.toStatusString(actual, NamedStackInfo(stackName, 0, 0, remoteName)),
@@ -3929,7 +3929,7 @@ interface GitJasprTest {
39293929
val actual = getAndPrintStatusString(RefSpec("development", "development"))
39303930
assertEquals(
39313931
"""
3932-
|[✅✅✅✅✅✅✅] %s : %s : three
3932+
|[✅✅✅✅✅✅] %s : %s : three
39333933
"""
39343934
.trimMargin()
39353935
.toStatusString(actual),
@@ -4019,9 +4019,9 @@ interface GitJasprTest {
40194019
val actual = getAndPrintStatusString(RefSpec("development", "main"))
40204020
assertEquals(
40214021
"""
4022-
|[❗✅✅✅✅✅ㄧ] %s : %s : four
4023-
|[❗✅✅✅✅✅ㄧ] %s : %s : three
4024-
|[✅✅✅✅✅✅✅] %s : %s : one
4022+
|[❗✅✅✅✅ㄧ] %s : %s : four
4023+
|[❗✅✅✅✅ㄧ] %s : %s : three
4024+
|[✅✅✅✅✅✅] %s : %s : one
40254025
"""
40264026
.trimMargin()
40274027
.toStatusString(actual),
@@ -4057,9 +4057,9 @@ interface GitJasprTest {
40574057
val actual = getAndPrintStatusString()
40584058
assertEquals(
40594059
"""
4060-
|[ㄧㄧㄧㄧㄧㄧㄧ] %s : three
4061-
|[❗ㄧㄧㄧㄧㄧㄧ] %s : two
4062-
|[❗ㄧㄧㄧㄧㄧㄧ] %s : one
4060+
|[ㄧㄧㄧㄧㄧㄧ] %s : three
4061+
|[❗ㄧㄧㄧㄧㄧ] %s : two
4062+
|[❗ㄧㄧㄧㄧㄧ] %s : one
40634063
|
40644064
|Some commits in your local stack have duplicate IDs:
40654065
|- a: (one, two)
@@ -4146,8 +4146,8 @@ interface GitJasprTest {
41464146

41474147
assertEquals(
41484148
"""
4149-
|[✅✅✅✅✅✅✅] %s : %s : two
4150-
|[✅✅✅✅✅✅✅] %s : %s : one
4149+
|[✅✅✅✅✅✅] %s : %s : two
4150+
|[✅✅✅✅✅✅] %s : %s : one
41514151
"""
41524152
.trimMargin()
41534153
.toStatusString(actual, NamedStackInfo(stackName, 0, 0, remoteName)),
@@ -4206,7 +4206,7 @@ interface GitJasprTest {
42064206

42074207
assertEquals(
42084208
"""
4209-
|[✅✅✅✅✅✅✅] %s : %s : one
4209+
|[✅✅✅✅✅✅] %s : %s : one
42104210
"""
42114211
.trimMargin()
42124212
.toStatusString(
@@ -4281,8 +4281,8 @@ interface GitJasprTest {
42814281

42824282
assertEquals(
42834283
"""
4284-
|[✅ㄧㄧㄧㄧㄧㄧ] %s : two
4285-
|[✅✅✅✅✅✅✅] %s : %s : one
4284+
|[✅ㄧㄧㄧㄧㄧ] %s : two
4285+
|[✅✅✅✅✅✅] %s : %s : one
42864286
"""
42874287
.trimMargin()
42884288
.toStatusString(
@@ -4368,8 +4368,8 @@ interface GitJasprTest {
43684368

43694369
assertEquals(
43704370
"""
4371-
|[✅ㄧㄧㄧㄧㄧㄧ] %s : three
4372-
|[✅✅✅✅✅✅✅] %s : %s : one
4371+
|[✅ㄧㄧㄧㄧㄧ] %s : three
4372+
|[✅✅✅✅✅✅] %s : %s : one
43734373
"""
43744374
.trimMargin()
43754375
.toStatusString(
@@ -6050,9 +6050,9 @@ interface GitJasprTest {
60506050
val actual = getAndPrintStatusString()
60516051
assertEquals(
60526052
"""
6053-
|[✅✅✅✅✅✅✅] %s : %s : three
6054-
|[✅✅✅✅✅✅✅] %s : %s : two
6055-
|[✅✅✅✅✅✅✅] %s : %s : one
6053+
|[✅✅✅✅✅✅] %s : %s : three
6054+
|[✅✅✅✅✅✅] %s : %s : two
6055+
|[✅✅✅✅✅✅] %s : %s : one
60566056
"""
60576057
.trimMargin()
60586058
.toStatusString(actual, NamedStackInfo(secondStackName, 0, 0, remoteName)),
@@ -6066,8 +6066,8 @@ interface GitJasprTest {
60666066
val detachedHeadActual = getAndPrintStatusString()
60676067
assertEquals(
60686068
"""
6069-
|[✅✅✅✅✅✅✅] %s : %s : two
6070-
|[✅✅✅✅✅✅✅] %s : %s : one
6069+
|[✅✅✅✅✅✅] %s : %s : two
6070+
|[✅✅✅✅✅✅] %s : %s : one
60716071
"""
60726072
.trimMargin()
60736073
.toStatusString(
@@ -9442,7 +9442,7 @@ interface GitJasprTest {
94429442
// Extract commit hashes and URLs from the actual string and put them into the expected. I
94439443
// can't predict what they will be, so I only want to validate that they are present.
94449444
val extracts =
9445-
"] (.*?) : (?:(http.*?) : )?.*?\n"
9445+
"] (.*?) : (?:(http\\S+) : )?.*?\n"
94469446
.toRegex()
94479447
.findAll(actual)
94489448
.flatMap { result -> result.groupValues.drop(1) }
@@ -9526,14 +9526,13 @@ interface GitJasprTest {
95269526
?.let { "\n$it" }
95279527
.orEmpty()
95289528
return """
9529-
| ┌───────────── commit pushed
9530-
| │ ┌───────────── exists ┐
9531-
| │ │ ┌─────────── checks pass │
9532-
| │ │ │ ┌───────── ready │ PR
9533-
| │ │ │ │ ┌─────── approved │
9534-
| │ │ │ │ │ ┌───── comments ┘
9535-
| │ │ │ │ │ │ ┌─ stack check
9536-
| │ │ │ │ │ │ │
9529+
| ┌─────────── commit pushed
9530+
| │ ┌─────────── exists ┐
9531+
| │ │ ┌───────── checks pass │
9532+
| │ │ │ ┌─────── ready │ PR
9533+
| │ │ │ │ ┌───── approved ┘
9534+
| │ │ │ │ │ ┌─ stack check
9535+
| │ │ │ │ │ │
95379536
|$formattedString
95389537
95399538
"""
@@ -10064,8 +10063,8 @@ interface GitJasprTest {
1006410063
val actual = getAndPrintStatusString()
1006510064
assertEquals(
1006610065
"""
10067-
|[✅✅✅✅✅✅✅] %s : %s : two
10068-
|[✅✅✅✅✅✅✅] %s : %s : one
10066+
|[✅✅✅✅✅✅] %s : %s : two
10067+
|[✅✅✅✅✅✅] %s : %s : one
1006910068
"""
1007010069
.trimMargin()
1007110070
.toStatusString(actual),

0 commit comments

Comments
 (0)