1- import { datePrefixedLabel , formatRelativeTime , GitHub } from "@array/core" ;
1+ import {
2+ type DiffStats ,
3+ datePrefixedLabel ,
4+ formatRelativeTime ,
5+ GitHub ,
6+ } from "@array/core" ;
27import {
38 cyan ,
49 dim ,
@@ -11,6 +16,16 @@ import {
1116} from "../utils/output" ;
1217import { createJJ , unwrap } from "../utils/run" ;
1318
19+ function formatDiffStats ( stats : DiffStats ) : string {
20+ if ( stats . filesChanged === 0 ) return "" ;
21+ const parts : string [ ] = [ ] ;
22+ if ( stats . insertions > 0 ) parts . push ( green ( `+${ stats . insertions } ` ) ) ;
23+ if ( stats . deletions > 0 ) parts . push ( red ( `-${ stats . deletions } ` ) ) ;
24+ const filesLabel = stats . filesChanged === 1 ? "file" : "files" ;
25+ parts . push ( dim ( `${ stats . filesChanged } ${ filesLabel } ` ) ) ;
26+ return dim ( "(" ) + parts . join ( dim ( ", " ) ) + dim ( ")" ) ;
27+ }
28+
1429interface PRInfo {
1530 number : number ;
1631 state : "open" | "merged" | "closed" ;
@@ -58,6 +73,21 @@ export async function log(): Promise<void> {
5873 }
5974 }
6075
76+ // Fetch diff stats for all entries in parallel
77+ // Use unpushed stats for modified changes, total stats otherwise
78+ const diffStatsMap = new Map < string , DiffStats > ( ) ;
79+ const statsPromises = entries . map ( async ( entry ) => {
80+ const bookmark = entry . change . bookmarks [ 0 ] ;
81+ const result =
82+ entry . isModified && bookmark
83+ ? await jj . getUnpushedDiffStats ( entry . change . changeId , bookmark )
84+ : await jj . getDiffStats ( entry . change . changeId ) ;
85+ if ( result . ok ) {
86+ diffStatsMap . set ( entry . change . changeId , result . value ) ;
87+ }
88+ } ) ;
89+ await Promise . all ( statsPromises ) ;
90+
6191 console . log ( ) ;
6292
6393 // Show empty working copy if present
@@ -82,25 +112,27 @@ export async function log(): Promise<void> {
82112 entries [ i ] ;
83113 const label = datePrefixedLabel ( change . description , change . timestamp ) ;
84114
85- // Track modified changes for summary
115+ // Track unpushed changes for summary
86116 if ( isModified ) modifiedCount ++ ;
87117
88118 // Determine status badges
89119 const badges : string [ ] = [ ] ;
90- if ( isModified ) badges . push ( yellow ( "modified " ) ) ;
120+ if ( isModified ) badges . push ( yellow ( "unpushed " ) ) ;
91121 if ( change . hasConflicts ) badges . push ( yellow ( "conflicts" ) ) ;
92122
93123 // Don't show current marker on entries when empty WC is shown above
94124 const marker = isCurrent && ! hasEmptyWorkingCopy ? green ( "◉" ) : "○" ;
95125 const badgeStr =
96126 badges . length > 0 ? ` ${ dim ( "(" ) } ${ badges . join ( ", " ) } ${ dim ( ")" ) } ` : "" ;
97127
98- // Line 1: marker + branch name + change ID + badges
128+ // Line 1: marker + branch name + change ID + stats + badges
99129 const shortId = formatChangeId (
100130 change . changeId . slice ( 0 , 8 ) ,
101131 change . changeIdPrefix ,
102132 ) ;
103- console . log ( `${ prefix } ${ marker } ${ label } ${ shortId } ${ badgeStr } ` ) ;
133+ const stats = diffStatsMap . get ( change . changeId ) ;
134+ const statsStr = stats ? ` ${ formatDiffStats ( stats ) } ` : "" ;
135+ console . log ( `${ prefix } ${ marker } ${ label } ${ shortId } ${ statsStr } ${ badgeStr } ` ) ;
104136
105137 // Line 2: relative time
106138 console . log ( `${ prefix } │ ${ dim ( formatRelativeTime ( change . timestamp ) ) } ` ) ;
@@ -155,11 +187,11 @@ export async function log(): Promise<void> {
155187 }
156188 console . log ( ) ;
157189
158- // Show summary/guidance when there are modified changes
190+ // Show summary/guidance when there are unpushed changes
159191 if ( modifiedCount > 0 ) {
160- const changeWord = modifiedCount === 1 ? "change" : "changes" ;
192+ const changeWord = modifiedCount === 1 ? "change has " : "changes have " ;
161193 console . log (
162- `${ modifiedCount } ${ changeWord } modified . Run ${ cyan ( "arr submit" ) } to update PRs.` ,
194+ `${ modifiedCount } ${ changeWord } unpushed commits . Run ${ cyan ( "arr submit" ) } to update PRs.` ,
163195 ) ;
164196 console . log ( ) ;
165197 }
0 commit comments