Code Monkey home page Code Monkey logo

formatting-automation's Introduction

License: MIT

Formatting Automation

Add git hooks to standardize and format code.

Project Structure

formatting-automation
    .pre-commit-config.yaml
    environment.yml
    LICENSE
    README.md
    setup-windows.bat

.pre-commit-config.yaml

Provides recipe for the git hooks.

environment.yml

Provides recipe for the Conda environment.

setup-windows.bat

Automates creation of the Conda environment and setup of the git hooks.

Environment Setup

The first step is to install Miniconda and clone the GitHub repository.

Install Miniconda:

Clone GitHub repository:

(base) > git clone https://github.com/calekochenour/formatting-automation.git

The next step is to set up the git hooks. The setup-windows.bat file:

  • Creates the Conda environment
  • Installs the git hook scripts
  • Udpates the repo revisions ('rev') the .pre-commit-config.yaml file to the latest stable releases
  • Runs the git hooks against all files in the repository

Set up environment:

(base) > setup-windows.bat

Example output of the setup script. Note that output may differ slightly.

Channels:
 - conda-forge
 - defaults
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done

Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate formatting-automation
#
# To deactivate an active environment, use
#
#     $ conda deactivate

pre-commit installed at .git\hooks\pre-commit

[https://github.com/pre-commit/pre-commit-hooks] already up to date!
[https://github.com/psf/black] already up to date!
[https://github.com/pycqa/isort] already up to date!
[https://github.com/PyCQA/flake8] already up to date!
[https://github.com/pre-commit/mirrors-mypy] already up to date!

check for added large files..............................................Passed
check yaml...............................................................Passed
fix end of files.........................................................Passed
don't commit to branch...................................................Passed
trim trailing whitespace.................................................Passed
black................................................(no files to check)Skipped
isort................................................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
mypy.................................................(no files to check)Skipped

Once installed, the git hooks will run every time a user attempts to commit files for this repository. As directed by the .pre-commit-config.yaml file, the pre-commit routines checks certain files for formatting and modify files as needed to pass the checks. Files that fail the checks will be modified. If any check fails, no files will be committed, but all file modifications from the pre-commit routines will be preserved locally. A user must commit files again will all checks passing in order to push the changes to a remote branch.

Pre-Commit Resources

Additional resources for pre-commit can be found here:

Some useful pre-commit command line references are listed below.

Install hooks:

(formatting-automation) > pre-commit install

Run on all files:

(formatting-automation) > pre-commit run --all-files

Update hook revisions:

 (formatting-automation) > pre-commit autoupdate

Clean cached pre-commit files:

(formatting-automation) > pre-commit clean

Clean unused cached repos:

(formatting-automation) > pre-commit gc

formatting-automation's People

Contributors

calekochenour avatar

Watchers

 avatar

formatting-automation's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.