GithubHelp home page GithubHelp logo

nikolausweingartmair / pre-commit-search-and-replace Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mattlqx/pre-commit-search-and-replace

0.0 0.0 0.0 21 KB

Plugin for pre-commit for arbitrary search and replace on committed files.

License: MIT License

Ruby 100.00%

pre-commit-search-and-replace's Introduction

pre-commit-search-and-replace

This is a plugin for pre-commit that will run search and replace string operations against files to be committed. Note that this plugin operates on each line of a file therefore multiple line patterns are not supported.

Usage

By default, a YAML config file is loaded at .pre-commit-search-and-replace.yaml in the root of the repo. This config file should be a list of entries specifying any of the following keys:

  • search: (required) the string or regexp to search for. To use a regexp, start and end with slashes. e.g. /^mypattern/
  • replacement: the string to replace matched strings with. If specified, files will "fixed". Match groups can be referenced here (e.g. \1)
  • insensitive: boolean whether the regexp should be case-insensitive. default: false
  • extended: boolean whether the regexp should be extended. default: false
  • description: short text description of purpose of the entry.

The config file name can be changed by passing a --config PATH argument to the hook in the pre-commit config. A single search and replacement can be specified with --search STRING and --replacement STRING arguments as well instead of using a config file.

Example pre-commit config:

- repo: https://github.com/mattlqx/pre-commit-search-and-replace
  rev: v1.0.5
  hooks:
  - id: search-and-replace

Example search-and-replace config:

- search: /Something [bB]ad/
  replacement: Something Good
- search: foobar
  insensitive: true
  replacement: FOOBAR
- search: JustFailIfThisStringIsFound

pre-commit-search-and-replace's People

Contributors

mattlqx avatar aerickson avatar dependabot[bot] avatar

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.