@@ -49,6 +49,7 @@ func GetSummaryCommand() *cobra.Command {
4949 remoteFlag , _ := cmd .Flags ().GetBool ("remote" )
5050 markdownFlag , _ := cmd .Flags ().GetBool ("markdown" )
5151 extRefs , _ := cmd .Flags ().GetBool ("ext-refs" )
52+ errOnDiff , _ := cmd .Flags ().GetBool ("error-on-diff" )
5253
5354 if noColorFlag {
5455 pterm .DisableStyling ()
@@ -182,7 +183,7 @@ func GetSummaryCommand() *cobra.Command {
182183 }
183184
184185 er := runGithubHistorySummary (user , repo , filePath , latestFlag , limitFlag , limitTimeFlag , updateChan ,
185- errorChan , baseFlag , remoteFlag , markdownFlag , extRefs )
186+ errorChan , baseFlag , remoteFlag , markdownFlag , extRefs , errOnDiff )
186187 // wait for things to be completed.
187188 <- doneChan
188189 if er != nil {
@@ -237,7 +238,7 @@ func GetSummaryCommand() *cobra.Command {
237238 go listenForUpdates (updateChan , errorChan )
238239
239240 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 )
241242
242243 <- doneChan
243244
@@ -264,7 +265,7 @@ func GetSummaryCommand() *cobra.Command {
264265 return urlErr
265266 }
266267
267- errs := runLeftRightSummary (left , right , updateChan , errorChan , baseFlag , remoteFlag , markdownFlag , extRefs )
268+ errs := runLeftRightSummary (left , right , updateChan , errorChan , baseFlag , remoteFlag , markdownFlag , extRefs , errOnDiff )
268269 <- doneChan
269270 if len (errs ) > 0 {
270271 for e := range errs {
@@ -283,6 +284,7 @@ func GetSummaryCommand() *cobra.Command {
283284 }
284285 cmd .Flags ().BoolP ("no-color" , "n" , false , "Disable color and style output (very useful for CI/CD)" )
285286 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" )
286288 return cmd
287289}
288290
@@ -322,7 +324,7 @@ func checkURL(urlString string, errorChan chan model.ProgressError) (string, err
322324}
323325
324326func 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 {
326328
327329 var leftBytes , rightBytes []byte
328330 // var errs []error
@@ -373,7 +375,7 @@ func runLeftRightSummary(left, right string, updateChan chan *model.ProgressUpda
373375 model .SendProgressUpdate ("extraction" ,
374376 fmt .Sprintf ("extracted %d commits from history" , len (commits )), true , updateChan )
375377
376- e := printSummaryDetails (commits , markdown )
378+ e := printSummaryDetails (commits , markdown , errOnDiff )
377379 if e != nil {
378380 model .SendProgressError ("git" , e .Error (), errorChan )
379381 close (updateChan )
@@ -384,7 +386,7 @@ func runLeftRightSummary(left, right string, updateChan chan *model.ProgressUpda
384386}
385387
386388func 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 {
388390 commitHistory , _ := git .ProcessGithubRepo (username , repo , filePath , progressChan , errorChan ,
389391 false , limit , limitTime , base , remote , extRefs )
390392
@@ -397,11 +399,11 @@ func runGithubHistorySummary(username, repo, filePath string, latest bool, limit
397399
398400 close (progressChan )
399401
400- return printSummaryDetails (commitHistory , markdown )
402+ return printSummaryDetails (commitHistory , markdown , errOnDiff )
401403}
402404
403405func 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 ,
405407 globalRevisions bool , limit int , limitTime int ) error {
406408
407409 if gitPath == "" || filePath == "" {
@@ -429,15 +431,15 @@ func runGitHistorySummary(gitPath, filePath string, latest bool,
429431 commitHistory = commitHistory [:1 ]
430432 }
431433
432- err := printSummaryDetails (commitHistory , markdown )
434+ err := printSummaryDetails (commitHistory , markdown , errOnDiff )
433435
434436 model .SendProgressUpdate ("extraction" ,
435437 fmt .Sprintf ("extracted %d commits from history\n " , len (commitHistory )), true , updateChan )
436438 close (updateChan )
437439 return err
438440}
439441
440- func printSummaryDetails (commitHistory []* model.Commit , markdown bool ) error {
442+ func printSummaryDetails (commitHistory []* model.Commit , markdown , errOnDiff bool ) error {
441443 tt := 0
442444 tb := 0
443445 pterm .Println ()
@@ -571,6 +573,8 @@ func printSummaryDetails(commitHistory []*model.Commit, markdown bool) error {
571573
572574 if tb > 0 {
573575 return errors .New ("breaking changes discovered" )
576+ } else if tt > 0 && errOnDiff {
577+ return errors .New ("differences discovered" )
574578 } else {
575579 return nil
576580 }
0 commit comments