项目作者: allancalix

项目描述 :
A language agnostic Git integrated formatter
高级语言: Rust
项目地址: git://github.com/allancalix/git-fmt.git
创建时间: 2019-09-18T02:58:50Z
项目社区:https://github.com/allancalix/git-fmt

开源协议:

下载


git-fmt

git-fmt extends git to easily apply a variety of formatters to a set of changes.
Each formatter will be applied (in order) with the provided command to all
matching file extensions. Formatters are only applied to staged files to
provide a chance to review changes made.

The basic workflow anticipated might look something like:

  1. git add .
  2. git fmt
  3. git diff # Examine changes made by formatters.
  4. git add . && git commit -m 'I like the formatter changes!'

Installation

  1. git-fmt is a standalone binary. To install, you can either build from source
    or download the (OSX only) binary from
    releases.

    Building from source

    1. git clone https://github.com/allancalix/git-fmt.git && cd git-fmt
    2. cargo build --release
  2. Place the binary somewhere in $PATH.

Configuration

git-fmt is supported by the standard git config options. This means you can
define formatters for all your projects by modifying your global
.gitconfig or apply formatter commands only to a specific repository by
modifying the .git/config file found in every repository.

You could apply changes by using the cli. For example…

  1. # Local repository changes.
  2. git config fmt.rust.command "rustfmt {{STAGED_FILE}}"
  3. git config fmt.rust.extensions "rs"
  4. # Global changes that apply to all repositories.
  5. git config --global fmt.rust.command "rustfmt {{STAGED_FILE}}"
  6. git config --global fmt.rust.extensions "rs"

You could also apply changes directly to your global gitconfig file.

  1. [fmt "rust"]
  2. command = "rustfmt {{STAGED_FILE}}"
  3. extensions = "rs"
  4. [fmt "go"]
  5. command = "gofmt -w {{STAGED_FILE}}"
  6. extensions = "go, gox" # Separate additional extensions with commas.