@@ -117,58 +117,59 @@ export const format_timestamp_and_offset = (owner) => {
117
117
*/
118
118
export const format_commit = ( commit , oid , options = { } ) => {
119
119
const title_line = ( ) => commit . message . split ( '\n' ) [ 0 ] ;
120
+ const indent = ( text ) => text . split ( '\n' ) . map ( it => ` ${ it } ` ) . join ( '\n' ) ;
120
121
121
122
switch ( options . format || 'medium' ) {
122
123
// TODO: Other formats
123
124
case 'oneline' :
124
- return `${ format_oid ( oid , options ) } ${ title_line ( ) } ` ;
125
+ return `${ chalk . yellow ( format_oid ( oid , options ) ) } ${ title_line ( ) } ` ;
125
126
case 'short' : {
126
127
let s = '' ;
127
- s += `commit ${ format_oid ( oid , options ) } \n` ;
128
+ s += chalk . yellow ( `commit ${ format_oid ( oid , options ) } \n` ) ;
128
129
s += `Author: ${ format_person ( commit . author ) } \n` ;
129
130
s += '\n' ;
130
- s += title_line ( ) ;
131
+ s += indent ( title_line ( ) ) ;
131
132
return s ;
132
133
}
133
134
case 'medium' : {
134
135
let s = '' ;
135
- s += `commit ${ format_oid ( oid , options ) } \n` ;
136
+ s += chalk . yellow ( `commit ${ format_oid ( oid , options ) } \n` ) ;
136
137
s += `Author: ${ format_person ( commit . author ) } \n` ;
137
138
s += `Date: ${ format_date ( commit . author ) } \n` ;
138
139
s += '\n' ;
139
- s += commit . message ;
140
+ s += indent ( commit . message ) ;
140
141
return s ;
141
142
}
142
143
case 'full' : {
143
144
let s = '' ;
144
- s += `commit ${ format_oid ( oid , options ) } \n` ;
145
+ s += chalk . yellow ( `commit ${ format_oid ( oid , options ) } \n` ) ;
145
146
s += `Author: ${ format_person ( commit . author ) } \n` ;
146
147
s += `Commit: ${ format_person ( commit . committer ) } \n` ;
147
148
s += '\n' ;
148
- s += commit . message ;
149
+ s += indent ( commit . message ) ;
149
150
return s ;
150
151
}
151
152
case 'fuller' : {
152
153
let s = '' ;
153
- s += `commit ${ format_oid ( oid , options ) } \n` ;
154
+ s += chalk . yellow ( `commit ${ format_oid ( oid , options ) } \n` ) ;
154
155
s += `Author: ${ format_person ( commit . author ) } \n` ;
155
156
s += `AuthorDate: ${ format_date ( commit . author ) } \n` ;
156
157
s += `Commit: ${ format_person ( commit . committer ) } \n` ;
157
158
s += `CommitDate: ${ format_date ( commit . committer ) } \n` ;
158
159
s += '\n' ;
159
- s += commit . message ;
160
+ s += indent ( commit . message ) ;
160
161
return s ;
161
162
}
162
163
case 'raw' : {
163
164
let s = '' ;
164
- s += `commit ${ oid } \n` ;
165
+ s += chalk . yellow ( `commit ${ oid } \n` ) ;
165
166
s += `tree ${ commit . tree } \n` ;
166
167
if ( commit . parent [ 0 ] )
167
168
s += `parent ${ commit . parent [ 0 ] } \n` ;
168
169
s += `author ${ format_person ( commit . author ) } ${ format_timestamp_and_offset ( commit . author ) } \n` ;
169
170
s += `committer ${ format_person ( commit . committer ) } ${ format_timestamp_and_offset ( commit . committer ) } \n` ;
170
171
s += '\n' ;
171
- s += commit . message ;
172
+ s += indent ( commit . message ) ;
172
173
return s ;
173
174
}
174
175
default : {
@@ -186,7 +187,7 @@ export const format_commit = (commit, oid, options = {}) => {
186
187
*/
187
188
export const format_tree = ( oid , tree , options = { } ) => {
188
189
let s = '' ;
189
- s += `tree ${ oid } \n` ;
190
+ s += chalk . yellow ( `tree ${ oid } \n` ) ;
190
191
s += '\n' ;
191
192
for ( const tree_entry of tree ) {
192
193
s += `${ tree_entry . path } \n` ;
@@ -205,7 +206,7 @@ export const format_tree = (oid, tree, options = {}) => {
205
206
*/
206
207
export const format_tag = ( tag , options = { } ) => {
207
208
let s = '' ;
208
- s += `tag ${ tag . tag } \n` ;
209
+ s += chalk . yellow ( `tag ${ tag . tag } \n` ) ;
209
210
s += `Tagger: ${ format_person ( tag . tagger ) } \n` ;
210
211
s += `Date: ${ format_date ( tag . tagger , options ) } \n` ;
211
212
if ( tag . message ) {
@@ -410,23 +411,23 @@ export const format_diffs = (diffs, options) => {
410
411
411
412
// NOTE: This first line shows `a/$newFileName` for files that are new, not `/dev/null`.
412
413
const first_line_a_path = a_path !== '/dev/null' ? a_path : `${ options . source_prefix } ${ diff . newFileName } ` ;
413
- s += `diff --git ${ first_line_a_path } ${ b_path } \n` ;
414
+ s += chalk . bold ( `diff --git ${ first_line_a_path } ${ b_path } \n` ) ;
414
415
if ( a . mode === b . mode ) {
415
- s += `index ${ shorten_hash ( a . oid ) } ..${ shorten_hash ( b . oid ) } ${ a . mode } ` ;
416
+ s += chalk . bold ( `index ${ shorten_hash ( a . oid ) } ..${ shorten_hash ( b . oid ) } ${ a . mode } \n` ) ;
416
417
} else {
417
418
if ( a . mode === '000000' ) {
418
- s += `new file mode ${ b . mode } \n` ;
419
+ s += chalk . bold ( `new file mode ${ b . mode } \n` ) ;
419
420
} else {
420
- s += `old mode ${ a . mode } \n` ;
421
- s += `new mode ${ b . mode } \n` ;
421
+ s += chalk . bold ( `old mode ${ a . mode } \n` ) ;
422
+ s += chalk . bold ( `new mode ${ b . mode } \n` ) ;
422
423
}
423
- s += `index ${ shorten_hash ( a . oid ) } ..${ shorten_hash ( b . oid ) } \n` ;
424
+ s += chalk . bold ( `index ${ shorten_hash ( a . oid ) } ..${ shorten_hash ( b . oid ) } \n` ) ;
424
425
}
425
426
if ( ! diff . hunks . length )
426
427
continue ;
427
428
428
- s += `--- ${ a_path } \n` ;
429
- s += `+++ ${ b_path } \n` ;
429
+ s += chalk . bold ( `--- ${ a_path } \n` ) ;
430
+ s += chalk . bold ( `+++ ${ b_path } \n` ) ;
430
431
431
432
for ( const hunk of diff . hunks ) {
432
433
s += chalk . blueBright ( `@@ -${ hunk . oldStart } ,${ hunk . oldLines } +${ hunk . newStart } ,${ hunk . newLines } @@\n` ) ;
0 commit comments