From 05e0220823eeea9c74bb2c8f5ffbb252d7d4e673 Mon Sep 17 00:00:00 2001 From: Art Chaidarun Date: Fri, 15 Oct 2021 17:29:37 -0400 Subject: [PATCH 1/9] Format SQL --- Dockerfile | 1 + README.md | 1 + entry.ts | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/Dockerfile b/Dockerfile index b4e08ed..fd7ba25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,7 @@ RUN apk add --no-cache --virtual .build-deps \ && npm install -g \ @types/node@16.6.2 \ prettier@2.3.2 \ + sql-formatter@4.0.2 \ svgo@1.3.2 \ typescript@4.3.5 \ && apk del .build-deps \ diff --git a/README.md b/README.md index 80ef6d6..9813334 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This repo currently contains a single [pre-commit](https://pre-commit.com/) hook - [ktfmt](https://github.com/facebookincubator/ktfmt) v0.28 for Kotlin - [scalafmt](https://scalameta.org/scalafmt/) v2.7.5 for Scala - [shfmt](https://github.com/mvdan/sh) v3.3.1 for Shell +- [SQL Formatter](https://github.com/zeroturnaround/sql-formatter) v4.0.2 for SQL - [terraform fmt](https://github.com/hashicorp/terraform) v0.11.14 and v0.12.29 for Terraform - [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) v11.1.0 for Protobuf - [SVGO](https://github.com/svg/svgo) v1.3.2 for SVG diff --git a/entry.ts b/entry.ts index 2532005..3246bc9 100644 --- a/entry.ts +++ b/entry.ts @@ -77,6 +77,7 @@ const enum HookName { Scalafmt = "scalafmt", Sed = "sed", Shfmt = "shfmt", + SqlFormatter = "SQL Formatter", Svgo = "SVGO", TerraformFmt = "terraform fmt", } @@ -310,6 +311,24 @@ const HOOKS: Record = { include: /./, runAfter: [HookName.Sed], }), + [HookName.SqlFormatter]: createLockableHook({ + action: sources => + Promise.all( + sources.map(source => + run( + "sql-formatter", + "--output", + source, + "--language", + "mysql", + "--uppercase", + source, + ), + ), + ), + include: /\.sql$/, + runAfter: [HookName.Sed], + }), [HookName.Svgo]: createLockableHook({ action: sources => run( From e8454fb17ceb2a2c9b4024286ec021bb3ab72e0c Mon Sep 17 00:00:00 2001 From: Art Chaidarun Date: Fri, 15 Oct 2021 17:40:20 -0400 Subject: [PATCH 2/9] Use docker hook --- .pre-commit-hooks.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 010e52c..53667f6 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,5 +1,5 @@ - id: duolingo name: Duolingo - entry: duolingo/pre-commit-hooks:1.5.2 /entry - language: docker_image + entry: /entry + language: docker types: [text] From 8c4f0283f7fd24998d43f91021cb46a843e12789 Mon Sep 17 00:00:00 2001 From: Art Chaidarun Date: Tue, 1 Mar 2022 17:49:51 -0500 Subject: [PATCH 3/9] Revert "Format SQL" This reverts commit 05e0220823eeea9c74bb2c8f5ffbb252d7d4e673. --- Dockerfile | 1 - README.md | 1 - entry.ts | 19 ------------------- 3 files changed, 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index fd7ba25..b4e08ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,6 @@ RUN apk add --no-cache --virtual .build-deps \ && npm install -g \ @types/node@16.6.2 \ prettier@2.3.2 \ - sql-formatter@4.0.2 \ svgo@1.3.2 \ typescript@4.3.5 \ && apk del .build-deps \ diff --git a/README.md b/README.md index 9813334..80ef6d6 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ This repo currently contains a single [pre-commit](https://pre-commit.com/) hook - [ktfmt](https://github.com/facebookincubator/ktfmt) v0.28 for Kotlin - [scalafmt](https://scalameta.org/scalafmt/) v2.7.5 for Scala - [shfmt](https://github.com/mvdan/sh) v3.3.1 for Shell -- [SQL Formatter](https://github.com/zeroturnaround/sql-formatter) v4.0.2 for SQL - [terraform fmt](https://github.com/hashicorp/terraform) v0.11.14 and v0.12.29 for Terraform - [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) v11.1.0 for Protobuf - [SVGO](https://github.com/svg/svgo) v1.3.2 for SVG diff --git a/entry.ts b/entry.ts index 3246bc9..2532005 100644 --- a/entry.ts +++ b/entry.ts @@ -77,7 +77,6 @@ const enum HookName { Scalafmt = "scalafmt", Sed = "sed", Shfmt = "shfmt", - SqlFormatter = "SQL Formatter", Svgo = "SVGO", TerraformFmt = "terraform fmt", } @@ -311,24 +310,6 @@ const HOOKS: Record = { include: /./, runAfter: [HookName.Sed], }), - [HookName.SqlFormatter]: createLockableHook({ - action: sources => - Promise.all( - sources.map(source => - run( - "sql-formatter", - "--output", - source, - "--language", - "mysql", - "--uppercase", - source, - ), - ), - ), - include: /\.sql$/, - runAfter: [HookName.Sed], - }), [HookName.Svgo]: createLockableHook({ action: sources => run( From 955aa2afa19c03f5dea34f294342baad073c8196 Mon Sep 17 00:00:00 2001 From: Art Chaidarun Date: Tue, 1 Mar 2022 18:08:34 -0500 Subject: [PATCH 4/9] Use SQLFluff --- Dockerfile | 1 + README.md | 1 + entry.ts | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index b4e08ed..32e43c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ RUN apk add --no-cache --virtual .build-deps \ autoflake==1.4 \ black==21.7b0 \ isort==5.9.3 \ + sqlfluff==0.10.1 \ && npm install -g \ @types/node@16.6.2 \ prettier@2.3.2 \ diff --git a/README.md b/README.md index 80ef6d6..c4c1a56 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This repo currently contains a single [pre-commit](https://pre-commit.com/) hook - [ktfmt](https://github.com/facebookincubator/ktfmt) v0.28 for Kotlin - [scalafmt](https://scalameta.org/scalafmt/) v2.7.5 for Scala - [shfmt](https://github.com/mvdan/sh) v3.3.1 for Shell +- [SQLFluff](https://github.com/sqlfluff/sqlfluff) v0.10.1 for SQL - [terraform fmt](https://github.com/hashicorp/terraform) v0.11.14 and v0.12.29 for Terraform - [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) v11.1.0 for Protobuf - [SVGO](https://github.com/svg/svgo) v1.3.2 for SVG diff --git a/entry.ts b/entry.ts index 2532005..d9d9ffd 100644 --- a/entry.ts +++ b/entry.ts @@ -77,6 +77,7 @@ const enum HookName { Scalafmt = "scalafmt", Sed = "sed", Shfmt = "shfmt", + SqlFluff = "SQLFluff", Svgo = "SVGO", TerraformFmt = "terraform fmt", } @@ -310,6 +311,12 @@ const HOOKS: Record = { include: /./, runAfter: [HookName.Sed], }), + [HookName.SqlFluff]: createLockableHook({ + action: sources => + run("sqlfluff", "fix", "--force", "--ignore-local-config", ...sources), + include: /\.sql$/, + runAfter: [HookName.Sed], + }), [HookName.Svgo]: createLockableHook({ action: sources => run( From fa9030c5059e686be0d55316390e34cc5953ca73 Mon Sep 17 00:00:00 2001 From: Lavanya Aprameya Date: Mon, 7 Mar 2022 15:44:17 -0500 Subject: [PATCH 5/9] Update dialect --- entry.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entry.ts b/entry.ts index d9d9ffd..e4d1c52 100644 --- a/entry.ts +++ b/entry.ts @@ -313,7 +313,7 @@ const HOOKS: Record = { }), [HookName.SqlFluff]: createLockableHook({ action: sources => - run("sqlfluff", "fix", "--force", "--ignore-local-config", ...sources), + run("sqlfluff", "fix", "--force", "--ignore-local-config", "--dialect bigquery", ...sources), include: /\.sql$/, runAfter: [HookName.Sed], }), From 8f4485dda2cfca36c172607076c892c0faf65f51 Mon Sep 17 00:00:00 2001 From: Art Chaidarun Date: Mon, 18 Jul 2022 16:31:28 -0400 Subject: [PATCH 6/9] Update SQLFluff to 1.2.1 --- Dockerfile | 2 +- entry.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 32e43c7..e0cdbfc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ RUN apk add --no-cache --virtual .build-deps \ autoflake==1.4 \ black==21.7b0 \ isort==5.9.3 \ - sqlfluff==0.10.1 \ + sqlfluff==1.2.1 \ && npm install -g \ @types/node@16.6.2 \ prettier@2.3.2 \ diff --git a/entry.ts b/entry.ts index e4d1c52..6496cc2 100644 --- a/entry.ts +++ b/entry.ts @@ -313,7 +313,14 @@ const HOOKS: Record = { }), [HookName.SqlFluff]: createLockableHook({ action: sources => - run("sqlfluff", "fix", "--force", "--ignore-local-config", "--dialect bigquery", ...sources), + run( + "sqlfluff", + "fix", + "--dialect bigquery", + "--force", + "--ignore-local-config", + ...sources, + ), include: /\.sql$/, runAfter: [HookName.Sed], }), From d6bb2b5acc57a9a8bfc5f9cb90e44c5556ee4617 Mon Sep 17 00:00:00 2001 From: Art Chaidarun Date: Mon, 18 Jul 2022 16:38:05 -0400 Subject: [PATCH 7/9] Fix command --- entry.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entry.ts b/entry.ts index 83bf754..6894326 100644 --- a/entry.ts +++ b/entry.ts @@ -346,7 +346,8 @@ const HOOKS: Record = { run( "sqlfluff", "fix", - "--dialect bigquery", + "--dialect", + "bigquery", "--force", "--ignore-local-config", ...sources, From 06fde8b3453e3f686e0d624ee82e69242aec931d Mon Sep 17 00:00:00 2001 From: Lavanya Aprameya Date: Fri, 10 Mar 2023 10:59:59 -0500 Subject: [PATCH 8/9] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 79b700e..f0a427a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN apk add --no-cache --virtual .build-deps \ autoflake==1.4 \ black==22.3.0 \ isort==5.10.1 \ - sqlfluff==1.2.1 \ + sqlfluff==1.4.5 \ && python3 -m venv /black21-venv \ && source /black21-venv/bin/activate \ && pip3 install black==21.12b0 click==8.0.4 \ From 7a915a2061798eb8328d2adc47fd2c4c0f3b4533 Mon Sep 17 00:00:00 2001 From: Lavanya Aprameya Date: Fri, 10 Mar 2023 11:00:17 -0500 Subject: [PATCH 9/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 38771fa..7f4e573 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This repo currently contains a single [pre-commit](https://pre-commit.com/) hook - [ktfmt](https://github.com/facebookincubator/ktfmt) v0.35 for Kotlin - [scalafmt](https://scalameta.org/scalafmt/) v3.5.1 for Scala - [shfmt](https://github.com/mvdan/sh) v3.4.3 for Shell -- [SQLFluff](https://github.com/sqlfluff/sqlfluff) v1.2.1 for SQL +- [SQLFluff](https://github.com/sqlfluff/sqlfluff) v1.4.5 for SQL - [xsltproc](http://www.xmlsoft.org/xslt/xsltproc.html) from libxslt v10135 for XML - [terraform fmt](https://github.com/hashicorp/terraform) v1.1.8 for Terraform - [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) v13.0.1 for Protobuf