@@ -49,6 +49,7 @@ func GetSummaryCommand() *cobra.Command {
49
49
remoteFlag , _ := cmd .Flags ().GetBool ("remote" )
50
50
markdownFlag , _ := cmd .Flags ().GetBool ("markdown" )
51
51
extRefs , _ := cmd .Flags ().GetBool ("ext-refs" )
52
+ errOnDiff , _ := cmd .Flags ().GetBool ("error-on-diff" )
52
53
53
54
if noColorFlag {
54
55
pterm .DisableStyling ()
@@ -182,7 +183,7 @@ func GetSummaryCommand() *cobra.Command {
182
183
}
183
184
184
185
er := runGithubHistorySummary (user , repo , filePath , latestFlag , limitFlag , limitTimeFlag , updateChan ,
185
- errorChan , baseFlag , remoteFlag , markdownFlag , extRefs )
186
+ errorChan , baseFlag , remoteFlag , markdownFlag , extRefs , errOnDiff )
186
187
// wait for things to be completed.
187
188
<- doneChan
188
189
if er != nil {
@@ -237,7 +238,7 @@ func GetSummaryCommand() *cobra.Command {
237
238
go listenForUpdates (updateChan , errorChan )
238
239
239
240
err = runGitHistorySummary (args [0 ], args [1 ], latestFlag , updateChan , errorChan ,
240
- baseFlag , remoteFlag , markdownFlag , extRefs , globalRevisionsFlag , limitFlag , limitTimeFlag )
241
+ baseFlag , remoteFlag , markdownFlag , extRefs , errOnDiff , globalRevisionsFlag , limitFlag , limitTimeFlag )
241
242
242
243
<- doneChan
243
244
@@ -264,7 +265,7 @@ func GetSummaryCommand() *cobra.Command {
264
265
return urlErr
265
266
}
266
267
267
- errs := runLeftRightSummary (left , right , updateChan , errorChan , baseFlag , remoteFlag , markdownFlag , extRefs )
268
+ errs := runLeftRightSummary (left , right , updateChan , errorChan , baseFlag , remoteFlag , markdownFlag , extRefs , errOnDiff )
268
269
<- doneChan
269
270
if len (errs ) > 0 {
270
271
for e := range errs {
@@ -283,6 +284,7 @@ func GetSummaryCommand() *cobra.Command {
283
284
}
284
285
cmd .Flags ().BoolP ("no-color" , "n" , false , "Disable color and style output (very useful for CI/CD)" )
285
286
cmd .Flags ().BoolP ("markdown" , "m" , false , "Render output in markdown, using emojis" )
287
+ cmd .Flags ().BoolP ("error-on-diff" , "" , false , "Treat any differences as errors" )
286
288
return cmd
287
289
}
288
290
@@ -322,7 +324,7 @@ func checkURL(urlString string, errorChan chan model.ProgressError) (string, err
322
324
}
323
325
324
326
func runLeftRightSummary (left , right string , updateChan chan * model.ProgressUpdate ,
325
- errorChan chan model.ProgressError , base string , remote , markdown , extRefs bool ) []error {
327
+ errorChan chan model.ProgressError , base string , remote , markdown , extRefs , errOnDiff bool ) []error {
326
328
327
329
var leftBytes , rightBytes []byte
328
330
// var errs []error
@@ -373,7 +375,7 @@ func runLeftRightSummary(left, right string, updateChan chan *model.ProgressUpda
373
375
model .SendProgressUpdate ("extraction" ,
374
376
fmt .Sprintf ("extracted %d commits from history" , len (commits )), true , updateChan )
375
377
376
- e := printSummaryDetails (commits , markdown )
378
+ e := printSummaryDetails (commits , markdown , errOnDiff )
377
379
if e != nil {
378
380
model .SendProgressError ("git" , e .Error (), errorChan )
379
381
close (updateChan )
@@ -384,7 +386,7 @@ func runLeftRightSummary(left, right string, updateChan chan *model.ProgressUpda
384
386
}
385
387
386
388
func runGithubHistorySummary (username , repo , filePath string , latest bool , limit int , limitTime int ,
387
- progressChan chan * model.ProgressUpdate , errorChan chan model.ProgressError , base string , remote , markdown , extRefs bool ) error {
389
+ progressChan chan * model.ProgressUpdate , errorChan chan model.ProgressError , base string , remote , markdown , extRefs , errOnDiff bool ) error {
388
390
commitHistory , _ := git .ProcessGithubRepo (username , repo , filePath , progressChan , errorChan ,
389
391
false , limit , limitTime , base , remote , extRefs )
390
392
@@ -397,11 +399,11 @@ func runGithubHistorySummary(username, repo, filePath string, latest bool, limit
397
399
398
400
close (progressChan )
399
401
400
- return printSummaryDetails (commitHistory , markdown )
402
+ return printSummaryDetails (commitHistory , markdown , errOnDiff )
401
403
}
402
404
403
405
func runGitHistorySummary (gitPath , filePath string , latest bool ,
404
- updateChan chan * model.ProgressUpdate , errorChan chan model.ProgressError , base string , remote , markdown , extRefs bool ,
406
+ updateChan chan * model.ProgressUpdate , errorChan chan model.ProgressError , base string , remote , markdown , extRefs , errOnDiff bool ,
405
407
globalRevisions bool , limit int , limitTime int ) error {
406
408
407
409
if gitPath == "" || filePath == "" {
@@ -429,15 +431,15 @@ func runGitHistorySummary(gitPath, filePath string, latest bool,
429
431
commitHistory = commitHistory [:1 ]
430
432
}
431
433
432
- err := printSummaryDetails (commitHistory , markdown )
434
+ err := printSummaryDetails (commitHistory , markdown , errOnDiff )
433
435
434
436
model .SendProgressUpdate ("extraction" ,
435
437
fmt .Sprintf ("extracted %d commits from history\n " , len (commitHistory )), true , updateChan )
436
438
close (updateChan )
437
439
return err
438
440
}
439
441
440
- func printSummaryDetails (commitHistory []* model.Commit , markdown bool ) error {
442
+ func printSummaryDetails (commitHistory []* model.Commit , markdown , errOnDiff bool ) error {
441
443
tt := 0
442
444
tb := 0
443
445
pterm .Println ()
@@ -571,6 +573,8 @@ func printSummaryDetails(commitHistory []*model.Commit, markdown bool) error {
571
573
572
574
if tb > 0 {
573
575
return errors .New ("breaking changes discovered" )
576
+ } else if tt > 0 && errOnDiff {
577
+ return errors .New ("differences discovered" )
574
578
} else {
575
579
return nil
576
580
}
0 commit comments