Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: correct action position (#15922)
h3n4l2bd78e584cea
diff --git a/action/azure_devops.go b/action/azure_devops.goindex d7b8e83524..bfafcfaa0c 100644--- a/action/azure_devops.go+++ b/action/azure_devops.go@@ -5,6 +5,7 @@ import ("github.com/pkg/errors"+ "github.com/bytebase/bytebase/backend/common"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")@@ -34,22 +35,7 @@ func loggingReleaseChecks(resp *v1pb.CheckReleaseResponse) error {hasError = true}- var position string- switch {- case advice.StartPosition != nil && advice.EndPosition != nil:- start := advice.StartPosition- end := advice.EndPosition- if start.Line == end.Line && start.Column == end.Column {- position = fmt.Sprintf("line %d, col %d", start.Line, start.Column)- } else {- position = fmt.Sprintf("line %d, col %d to line %d, col %d",- start.Line, start.Column, end.Line, end.Column)- }- case advice.Line != 0 || advice.Column != 0:- position = fmt.Sprintf("line %d, col %d", advice.Line, advice.Column)- default:- position = "unknown position"- }+ position := fmt.Sprintf("line %d", common.ConvertLineToActionLine(int(advice.Line)))fmt.Printf("* (%s) Code %d - %s (%s): %s\n", advice.Status.String(), advice.Code, advice.Title, position, advice.Content)}}diff --git a/action/bitbucket.go b/action/bitbucket.goindex fbde179fd3..93f6060e42 100644--- a/action/bitbucket.go+++ b/action/bitbucket.go@@ -11,6 +11,7 @@ import ("github.com/pkg/errors"+ "github.com/bytebase/bytebase/backend/common"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")@@ -125,7 +126,7 @@ func createBitbucketReport(checkResponse *v1pb.CheckReleaseResponse) error {Severity: severity,Result: res,Path: result.File,- Line: int(advice.Line),+ Line: common.ConvertLineToActionLine(int(advice.Line)),})count++}diff --git a/action/github/github.go b/action/github/github.goindex 81844d04e6..1739a88c69 100644--- a/action/github/github.go+++ b/action/github/github.go@@ -4,11 +4,13 @@ import ("encoding/json""fmt""os"+ "strconv""strings""github.com/caarlos0/env/v11""github.com/pkg/errors"+ "github.com/bytebase/bytebase/backend/common"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")@@ -185,9 +187,7 @@ func writeAnnotations(resp *v1pb.CheckReleaseResponse) error {_, _ = sb.WriteString(" file=")_, _ = sb.WriteString(result.File)_, _ = sb.WriteString(",line=")- _, _ = sb.WriteString(string(advice.Line))- _, _ = sb.WriteString(",col=")- _, _ = sb.WriteString(string(advice.Column))+ _, _ = sb.WriteString(strconv.Itoa(common.ConvertLineToActionLine(int(advice.Line))))_, _ = sb.WriteString(",title=")_, _ = sb.WriteString(advice.Title)_, _ = sb.WriteString(" (")diff --git a/action/gitlab.go b/action/gitlab.goindex 1ec45494ef..a22c196950 100644--- a/action/gitlab.go+++ b/action/gitlab.go@@ -7,6 +7,7 @@ import ("github.com/pkg/errors"+ "github.com/bytebase/bytebase/backend/common"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")@@ -85,7 +86,7 @@ func writeReleaseCheckToCodeQualityJSON(resp *v1pb.CheckReleaseResponse) error {Location: Location{Path: result.File,Lines: Lines{- Begin: int(advice.Line),+ Begin: common.ConvertLineToActionLine(int(advice.Line)),},},})diff --git a/backend/common/position.go b/backend/common/position.goindex 33c7ef4185..29c7ab5c56 100644--- a/backend/common/position.go+++ b/backend/common/position.go@@ -197,3 +197,10 @@ func ConvertPGParserErrorCursorPosToPosition(cursorPos int, text string) *storepColumn: int32(column),}}++func ConvertLineToActionLine(line int) int {+ if line < 0 {+ return 1+ }+ return line + 1+}