Skip to content

Commit

Permalink
atlasaction: remove <br/> in markdown (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored Dec 19, 2024
1 parent 088144f commit c54b5f2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions atlasaction/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,7 @@ var (
return fmt.Sprintf(`<picture><source media="(prefers-color-scheme: light)" srcset=%q><img %s/></picture>`, src, attrs), nil
},
"nl2br": func(s string) string { return strings.ReplaceAll(s, "\n", "<br/>") },
"nl2sp": func(s string) string { return strings.ReplaceAll(s, "\n", " ") },
}).
ParseFS(comments, "comments/*"),
)
Expand Down
4 changes: 2 additions & 2 deletions atlasaction/comments/bitbucket.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

| Status | Step | Result |
| :----: | :--- | :----- |
| {{ template "lint-check/md" "success.svg" }} | {{ filesDetected .Files }} | {{ join (fileNames .Files) "<br/>" }} |
| {{ template "lint-check/md" "success.svg" }} | {{ filesDetected .Files }} | {{ join (fileNames .Files) " " }} |
{{ template "lint-report/md" . }}
{{- end -}}
{{- define "schema-plan/md" -}}
Expand Down Expand Up @@ -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 }} |
Expand Down
12 changes: 6 additions & 6 deletions atlasaction/testdata/templates/migrate-lint-md.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ 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<br/>2 reports were found in analysis | **Data dependent changes detected**<br/>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)<br/>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 --
`atlas migrate lint` on **testdata/migrations**

| Status | Step | Result |
| :----: | :--- | :----- |
| ![](https://release.ariga.io/images/assets/success.svg?v=1) | 2 new migration files detected | 20230925192914.sql<br/>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<br/>1 reports were found in analysis | **Data dependent changes detected**<br/>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<br/>1 reports were found in analysis | **Destructive changes detected**<br/>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 --
Expand All @@ -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<br/>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 --
Expand All @@ -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<br/>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 |
2 changes: 1 addition & 1 deletion atlasaction/testdata/templates/schema-plan-md.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -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<br/>1 reports were found in analysis | **Destructive changes detected**<br/>Dropping non-virtual column "Description" [(DS103)](https://atlasgo.io/lint/analyzers#DS103)<br/>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) |


---
Expand Down

0 comments on commit c54b5f2

Please sign in to comment.