Skip to content

Commit

Permalink
fix: improve error message when no breaking changes detected
Browse files Browse the repository at this point in the history
  • Loading branch information
tinygrasshopper committed Oct 30, 2024
1 parent 334440b commit 014e2c3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ require (
github.com/wI2L/jsondiff v0.6.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/yargevad/filepathx v1.0.0 // indirect
github.com/yuin/goldmark v1.7.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U=
github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down
14 changes: 12 additions & 2 deletions internal/simplebuild/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/tufin/oasdiff/formatters"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -420,8 +421,17 @@ func CheckBreakingChanges(docs DocSet) error {
}
}
if !breakingChange {
return fmt.Errorf("no breaking change detected between versions %s and %s: \n %s",
prevDoc.VersionDate, currDoc.VersionDate, changes)
formatter, err := formatters.Lookup(string(formatters.FormatText), formatters.FormatterOpts{})
if err != nil {
return err
}
diffDetails, err := formatter.RenderDiff(diffReport, formatters.RenderOpts{})
if err != nil {
return err
}
return fmt.Errorf("no breaking changes detected between versions %s and %s, %s should not be created, merge changes into %s\n %s",
prevDoc.VersionDate.Format(time.DateOnly), currDoc.VersionDate.Format(time.DateOnly),
currDoc.VersionDate.Format(time.DateOnly), prevDoc.VersionDate.Format(time.DateOnly), string(diffDetails))
}
}
return nil
Expand Down

0 comments on commit 014e2c3

Please sign in to comment.