@@ -95,6 +95,11 @@ const cli = yargs(process.argv.slice(2))
95
95
"additional git log arguments as space separated string, example '--first-parent --cherry-pick'" ,
96
96
type : 'string' ,
97
97
} ,
98
+ last : {
99
+ alias : 'l' ,
100
+ description : 'just analyze the last commit; applies if edit=false' ,
101
+ type : 'boolean' ,
102
+ } ,
98
103
format : {
99
104
alias : 'o' ,
100
105
description : 'output format of the results' ,
@@ -214,11 +219,25 @@ async function main(args: MainArgs): Promise<void> {
214
219
215
220
const fromStdin = checkFromStdin ( raw , flags ) ;
216
221
222
+ if (
223
+ Object . hasOwn ( flags , 'last' ) &&
224
+ ( Object . hasOwn ( flags , 'from' ) || Object . hasOwn ( flags , 'to' ) || flags . edit )
225
+ ) {
226
+ const err = new CliError (
227
+ 'Please use the --last flag alone. The --last flag should not be used with --to or --from or --edit.' ,
228
+ pkg . name
229
+ ) ;
230
+ cli . showHelp ( 'log' ) ;
231
+ console . log ( err . message ) ;
232
+ throw err ;
233
+ }
234
+
217
235
const input = await ( fromStdin
218
236
? stdin ( )
219
237
: read ( {
220
238
to : flags . to ,
221
239
from : flags . from ,
240
+ last : flags . last ,
222
241
edit : flags . edit ,
223
242
cwd : flags . cwd ,
224
243
gitLogArgs : flags [ 'git-log-args' ] ,
@@ -231,7 +250,7 @@ async function main(args: MainArgs): Promise<void> {
231
250
232
251
if ( messages . length === 0 && ! checkFromRepository ( flags ) ) {
233
252
const err = new CliError (
234
- '[input] is required: supply via stdin, or --env or --edit or --from and --to' ,
253
+ '[input] is required: supply via stdin, or --env or --edit or --last or -- from and --to' ,
235
254
pkg . name
236
255
) ;
237
256
cli . showHelp ( 'log' ) ;
@@ -374,7 +393,11 @@ function checkFromEdit(flags: CliFlags): boolean {
374
393
}
375
394
376
395
function checkFromHistory ( flags : CliFlags ) : boolean {
377
- return typeof flags . from === 'string' || typeof flags . to === 'string' ;
396
+ return (
397
+ typeof flags . from === 'string' ||
398
+ typeof flags . to === 'string' ||
399
+ typeof flags . last === 'boolean'
400
+ ) ;
378
401
}
379
402
380
403
function normalizeFlags ( flags : CliFlags ) : CliFlags {
0 commit comments