From c54b5f2c9164d5a4da39cd5c7328c03e9f961aa8 Mon Sep 17 00:00:00 2001
From: "Giau. Tran Minh" <12751435+giautm@users.noreply.github.com>
Date: Thu, 19 Dec 2024 19:55:00 +0700
Subject: [PATCH] atlasaction: remove `
` in markdown (#285)
---
atlasaction/action.go | 1 +
atlasaction/comments/bitbucket.md | 4 ++--
atlasaction/testdata/templates/migrate-lint-md.txtar | 12 ++++++------
atlasaction/testdata/templates/schema-plan-md.txtar | 2 +-
4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/atlasaction/action.go b/atlasaction/action.go
index c2f2f383..048615a8 100644
--- a/atlasaction/action.go
+++ b/atlasaction/action.go
@@ -1217,6 +1217,7 @@ var (
return fmt.Sprintf(``, src, attrs), nil
},
"nl2br": func(s string) string { return strings.ReplaceAll(s, "\n", "
") },
+ "nl2sp": func(s string) string { return strings.ReplaceAll(s, "\n", " ") },
}).
ParseFS(comments, "comments/*"),
)
diff --git a/atlasaction/comments/bitbucket.md b/atlasaction/comments/bitbucket.md
index 2b12039a..bbdd14b6 100644
--- a/atlasaction/comments/bitbucket.md
+++ b/atlasaction/comments/bitbucket.md
@@ -3,7 +3,7 @@
| Status | Step | Result |
| :----: | :--- | :----- |
-| {{ template "lint-check/md" "success.svg" }} | {{ filesDetected .Files }} | {{ join (fileNames .Files) "
" }} |
+| {{ template "lint-check/md" "success.svg" }} | {{ filesDetected .Files }} | {{ join (fileNames .Files) " " }} |
{{ template "lint-report/md" . }}
{{- end -}}
{{- define "schema-plan/md" -}}
@@ -34,7 +34,7 @@
{{ end }}
{{- with (.Steps | filterIssues) -}}
{{ range $step := . -}}
-| {{ template "lint-check/md" (or (and ($step | stepIsError) "error.svg") "warning.svg") }} | {{ stepSummary $step | nl2br }} | {{ stepDetails $step | nl2br }} |
+| {{ template "lint-check/md" (or (and ($step | stepIsError) "error.svg") "warning.svg") }} | {{ stepSummary $step | nl2sp }} | {{ stepDetails $step | nl2sp }} |
{{ end -}}
{{- else -}}
| {{ template "lint-check/md" "success.svg" }} | No issues found | {{ with .URL -}}[View Report]({{- . -}}){{- end }} |
diff --git a/atlasaction/testdata/templates/migrate-lint-md.txtar b/atlasaction/testdata/templates/migrate-lint-md.txtar
index e54880e1..19af86af 100644
--- a/atlasaction/testdata/templates/migrate-lint-md.txtar
+++ b/atlasaction/testdata/templates/migrate-lint-md.txtar
@@ -37,7 +37,7 @@ cmp stdout golden-4.md
| :----: | :--- | :----- |
| ![](https://release.ariga.io/images/assets/success.svg?v=1) | 1 new migration file detected | 20230925192914.sql |
| ![](https://release.ariga.io/images/assets/success.svg?v=1) | ERD and visual diff generated | [View Visualization](https://migration-lint-report-url#erd) |
-| ![](https://release.ariga.io/images/assets/warning.svg?v=1) | Analyze 20230925192914.sql
2 reports were found in analysis | **Data dependent changes detected**
Adding a unique index "idx_unique_fullname" on table "Persons" might fail in case columns "FirstName", "LastName" contain duplicate entries [(MF101)](https://atlasgo.io/lint/analyzers#MF101)
Adding a non-nullable "varchar" column "City" on table "Persons" without a default value implicitly sets existing rows with "" [(MY101)](https://atlasgo.io/lint/analyzers#MY101) |
+| ![](https://release.ariga.io/images/assets/warning.svg?v=1) | Analyze 20230925192914.sql 2 reports were found in analysis | **Data dependent changes detected** Adding a unique index "idx_unique_fullname" on table "Persons" might fail in case columns "FirstName", "LastName" contain duplicate entries [(MF101)](https://atlasgo.io/lint/analyzers#MF101) Adding a non-nullable "varchar" column "City" on table "Persons" without a default value implicitly sets existing rows with "" [(MY101)](https://atlasgo.io/lint/analyzers#MY101) |
-- data-2.json --
{"URL":"https://migration-lint-report-url","Env":{"Dir":"testdata/migrations"},"Schema":{},"Steps":[{"Name":"Migration Integrity Check","Text":"File atlas.sum is valid"},{"Name":"Detect New Migration Files","Text":"Found 1 new migration files (from 1 total)"},{"Name":"Analyze 20230925192914.sql","Text":"1 reports were found in analysis","Result":{"Name":"20230925192914.sql","Text":"CREATE UNIQUE INDEX idx_unique_fullname ON Persons (FirstName, LastName);","Reports":[{"Text":"data dependent changes detected","Diagnostics":[{"Pos":0,"Text":"Adding a unique index \"idx_unique_fullname\" on table \"Persons\" might fail in case columns \"FirstName\", \"LastName\" contain duplicate entries","Code":"MF101"}]}]}},{"Name":"Analyze 20240625104520_destructive.sql","Text":"1 reports were found in analysis","Result":{"Name":"20240625104520_destructive.sql","Text":"DROP TABLE Persons;\n\n","Reports":[{"Text":"destructive changes detected","Diagnostics":[{"Pos":0,"Text":"Dropping table \"Persons\"","Code":"DS102"}]}],"Error":"Destructive changes detected"}}],"Files":[{"Name":"20230925192914.sql","Error":"Destructive changes detected"},{"Name":"20230925192915.sql","Reports":[{"Text":"","Diagnostics":[{"Pos":0,"Text":"Missing the CONCURRENTLY in index creation","Code":"PG101"}]}]}]}
-- golden-2.md --
@@ -45,10 +45,10 @@ cmp stdout golden-4.md
| Status | Step | Result |
| :----: | :--- | :----- |
-| ![](https://release.ariga.io/images/assets/success.svg?v=1) | 2 new migration files detected | 20230925192914.sql
20230925192915.sql |
+| ![](https://release.ariga.io/images/assets/success.svg?v=1) | 2 new migration files detected | 20230925192914.sql 20230925192915.sql |
| ![](https://release.ariga.io/images/assets/success.svg?v=1) | ERD and visual diff generated | [View Visualization](https://migration-lint-report-url#erd) |
-| ![](https://release.ariga.io/images/assets/warning.svg?v=1) | Analyze 20230925192914.sql
1 reports were found in analysis | **Data dependent changes detected**
Adding a unique index "idx_unique_fullname" on table "Persons" might fail in case columns "FirstName", "LastName" contain duplicate entries [(MF101)](https://atlasgo.io/lint/analyzers#MF101) |
-| ![](https://release.ariga.io/images/assets/error.svg?v=1) | Analyze 20240625104520_destructive.sql
1 reports were found in analysis | **Destructive changes detected**
Dropping table "Persons" [(DS102)](https://atlasgo.io/lint/analyzers#DS102) |
+| ![](https://release.ariga.io/images/assets/warning.svg?v=1) | Analyze 20230925192914.sql 1 reports were found in analysis | **Data dependent changes detected** Adding a unique index "idx_unique_fullname" on table "Persons" might fail in case columns "FirstName", "LastName" contain duplicate entries [(MF101)](https://atlasgo.io/lint/analyzers#MF101) |
+| ![](https://release.ariga.io/images/assets/error.svg?v=1) | Analyze 20240625104520_destructive.sql 1 reports were found in analysis | **Destructive changes detected** Dropping table "Persons" [(DS102)](https://atlasgo.io/lint/analyzers#DS102) |
-- data-3.json --
{"URL":"https://migration-lint-report-url","Env":{"Dir":"testdata/migrations"},"Schema":{},"Steps":[{"Name":"Migration Integrity Check","Text":"File atlas.sum is invalid","Error":"checksum mismatch"}],"Files":[{"Name":"20230925192914.sql","Error":"checksum mismatch"}]}
-- golden-3.md --
@@ -58,7 +58,7 @@ cmp stdout golden-4.md
| :----: | :--- | :----- |
| ![](https://release.ariga.io/images/assets/success.svg?v=1) | 1 new migration file detected | 20230925192914.sql |
| ![](https://release.ariga.io/images/assets/success.svg?v=1) | ERD and visual diff generated | [View Visualization](https://migration-lint-report-url#erd) |
-| ![](https://release.ariga.io/images/assets/error.svg?v=1) | Migration Integrity Check
File atlas.sum is invalid | checksum mismatch |
+| ![](https://release.ariga.io/images/assets/error.svg?v=1) | Migration Integrity Check File atlas.sum is invalid | checksum mismatch |
-- data-4.json --
{"URL":"https://migration-lint-report-url","Env":{"Dir":"testdata/migrations"},"Schema":{},"Steps":[{"Name":"Migration Integrity Check","Text":"File atlas.sum is valid"},{"Name":"Detected 1 non-additive change","Text":"Pulling the the latest git changes might fix this warning","Result":{"Reports":[{"Text":"","Diagnostics":[{"Pos":0,"Text":"File 20240613102407.sql is missing or has been removed. Changes that have already been applied will not be reverted","Code":""}]}]}}]}
-- golden-4.md --
@@ -68,4 +68,4 @@ cmp stdout golden-4.md
| :----: | :--- | :----- |
| ![](https://release.ariga.io/images/assets/success.svg?v=1) | No migration files detected | |
| ![](https://release.ariga.io/images/assets/success.svg?v=1) | ERD and visual diff generated | [View Visualization](https://migration-lint-report-url#erd) |
-| ![](https://release.ariga.io/images/assets/warning.svg?v=1) | Detected 1 non-additive change
Pulling the the latest git changes might fix this warning | File 20240613102407.sql is missing or has been removed. Changes that have already been applied will not be reverted |
+| ![](https://release.ariga.io/images/assets/warning.svg?v=1) | Detected 1 non-additive change Pulling the the latest git changes might fix this warning | File 20240613102407.sql is missing or has been removed. Changes that have already been applied will not be reverted |
diff --git a/atlasaction/testdata/templates/schema-plan-md.txtar b/atlasaction/testdata/templates/schema-plan-md.txtar
index 9855fc57..856d1b2c 100644
--- a/atlasaction/testdata/templates/schema-plan-md.txtar
+++ b/atlasaction/testdata/templates/schema-plan-md.txtar
@@ -71,7 +71,7 @@ ALTER TABLE [MySchema].[Image] DROP COLUMN [StorageKey];
| Status | Step | Result |
| :----: | :--- | :----- |
| ![](https://release.ariga.io/images/assets/success.svg?v=1) | Detect schema changes | 2 new statements detected |
-| ![](https://release.ariga.io/images/assets/error.svg?v=1) | Analyze pr-3-ae2Xr0Ir.sql
1 reports were found in analysis | **Destructive changes detected**
Dropping non-virtual column "Description" [(DS103)](https://atlasgo.io/lint/analyzers#DS103)
Dropping non-virtual column "StorageKey" [(DS103)](https://atlasgo.io/lint/analyzers#DS103) |
+| ![](https://release.ariga.io/images/assets/error.svg?v=1) | Analyze pr-3-ae2Xr0Ir.sql 1 reports were found in analysis | **Destructive changes detected** Dropping non-virtual column "Description" [(DS103)](https://atlasgo.io/lint/analyzers#DS103) Dropping non-virtual column "StorageKey" [(DS103)](https://atlasgo.io/lint/analyzers#DS103) |
---