upjohnc / pre-commit-sql-remove-lines

pre commit plugin for removing lines at the end of the file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Precommit - Clean sql files

Description

Precommit hook that removes extra lines at the end of a sql file (runs only on sql files). This is needed to keep the file clean so that it can run in Disneystreaming's airflow instance.

The same functionality is in the end-of-file-fixer. The description in pre-commit docs says that it adds a new line rather than removing lines

Usage

Add this to your .pre-commit-config.yaml file

repos:
-   repo: https://github.bamtech.co/cupjohn/pre-commit-sql-remove-lines.git
    rev: v1
    hooks:
    -   id: end-of-file-sql

Testing

There is a .justfile which is like a makefile. Instead of targets they are called recipes. Need to brew install just : brew install just

To get started you will need to create the virtualenv:

  • just install-virtualenv

For running tests locally:

  • just run-pytest

To test the functionality like it would run in pre-commit

  • open another terminal, create a new dir and set up git repo in that dir (git init)
  • create a file in the other dir
  • git add . && pre-commit try-repo ../disney_precommit_sql_file end-of-file-sql
  • instructions at pre-commit doc page

About

pre commit plugin for removing lines at the end of the file


Languages

Language:Python 100.0%