Code Monkey home page Code Monkey logo

pre-commit-shfmt's Introduction

pre-commit-shfmt

shfmt hook for pre-commit, with auto install.

Usage in .pre-commit-config.yaml:

- repo: https://github.com/scop/pre-commit-shfmt
  rev: v3.8.0-1
  hooks:
    # Choose one of:
    - id: shfmt         # prebuilt upstream executable
    - id: shfmt-src     # build from source (requires/installs Go to build)
    - id: shfmt-docker  # Docker image (requires Docker to run)

Note

From v3.7.0-2 on, the shfmt id points to the variant that uses a prebuilt upstream executable. The one that builds from source is available as shfmt-src.

pre-commit-shfmt's People

Contributors

freed-wu avatar kenji-miyake avatar renovate[bot] avatar scop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pre-commit-shfmt's Issues

ERROR: get: dial tcp: lookup: read udp: read: connection refused

See https://results.pre-commit.ci/run/github/114006193/1699907034.povI7ysrT0KE7N6-XDqIXA

shfmt....................................................................Failed
- hook id: shfmt
- exit code: 1

wrun: ERROR: get https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64#0264c424278b18e22453fe523ec01a19805ce3b8ebf18eaf3aadc1edc23f42e3: Get "https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64#0264c424278b18e22453fe523ec01a19805ce3b8ebf18eaf3aadc1edc23f42e3": dial tcp: lookup github.com on [::1]:53: read udp [::1]:42344->[::1]:53: read: connection refused
wrun: ERROR: get https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64#0264c424278b18e22453fe523ec01a19805ce3b8ebf18eaf3aadc1edc23f42e3: Get "https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64#0264c424278b18e22453fe523ec01a19805ce3b8ebf18eaf3aadc1edc23f42e3": dial tcp: lookup github.com on [::1]:53: read udp [::1]:33573->[::1]:53: read: connection refused

I can no longer use custom `args` with the main hook

I want to use shfmt’s --func-next-line option with one of these hooks. My pre-commit config used to look like this:

    -
        repo: https://github.com/scop/pre-commit-shfmt
        rev: v3.7.0-1
        hooks:
            -
                id: shfmt
                args: ["-fn"]

Once I updated to v3.7.0-2, it started giving me these errors:

shfmt....................................................................Failed
- hook id: shfmt
- exit code: 2

flag provided but not defined: -fn
Usage of /home/jayman/.cache/pre-commit/repoqk0av65h/py_env-python3.11/bin/wrun:
  -http-timeout duration
        HTTP client timeout (default 5m0s)
  -url value
        [<OS>/<architecture>=]URL (at least one required to match)
wrun: ERROR: parse flags: flag provided but not defined: -fn
flag provided but not defined: -fn
Usage of /home/jayman/.cache/pre-commit/repoqk0av65h/py_env-python3.11/bin/wrun:
  -http-timeout duration
        HTTP client timeout (default 5m0s)
  -url value
        [<OS>/<architecture>=]URL (at least one required to match)
wrun: ERROR: parse flags: flag provided but not defined: -fn

I think that this is a result of 286f22a (feat: use prebuilt upstream exe in shfmt, src install in shfmt-src, 2023-11-13). I was able to work around this issue by switching to the shfmt-docker hook.

Fails without verbose enough feedback

Sometimes the hook fails with output like this:

shfmt....................................................................Failed
- hook id: shfmt
- duration: 0.01s
- exit code: 1

wrun: ERROR: prepare hash: invalid fragment format, use hashAlgo-hexDigest
wrun: ERROR: prepare hash: invalid fragment format, use hashAlgo-hexDigest

Error: Process completed with exit code 1.

There is no information on what files these errors originated with, making it impossible to debug deeper. Running hook with verbose: true does not provided additional output.

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.