From 63fad53303381388673073de580a32088a4ef0fe Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 24 Mar 2020 22:59:15 +0100 Subject: Adding upstream version 2.2.0. Signed-off-by: Daniel Baumann --- .../arbitrary_bytes_repo/.pre-commit-hooks.yaml | 5 +++++ testing/resources/arbitrary_bytes_repo/hook.sh | 7 +++++++ .../arg_per_line_hooks_repo/.pre-commit-hooks.yaml | 6 ++++++ testing/resources/arg_per_line_hooks_repo/bin/hook.sh | 5 +++++ .../resources/conda_hooks_repo/.pre-commit-hooks.yaml | 10 ++++++++++ testing/resources/conda_hooks_repo/environment.yml | 6 ++++++ .../resources/docker_hooks_repo/.pre-commit-hooks.yaml | 17 +++++++++++++++++ testing/resources/docker_hooks_repo/Dockerfile | 3 +++ .../docker_image_hooks_repo/.pre-commit-hooks.yaml | 8 ++++++++ .../exclude_types_repo/.pre-commit-hooks.yaml | 6 ++++++ testing/resources/exclude_types_repo/bin/hook.sh | 3 +++ .../resources/failing_hook_repo/.pre-commit-hooks.yaml | 5 +++++ testing/resources/failing_hook_repo/bin/hook.sh | 4 ++++ .../resources/golang_hooks_repo/.pre-commit-hooks.yaml | 5 +++++ .../golang_hooks_repo/golang-hello-world/main.go | 17 +++++++++++++++++ testing/resources/img1.jpg | Bin 0 -> 843 bytes testing/resources/img2.jpg | Bin 0 -> 891 bytes testing/resources/img3.jpg | Bin 0 -> 859 bytes testing/resources/logfile_repo/.pre-commit-hooks.yaml | 6 ++++++ testing/resources/logfile_repo/bin/hook.sh | 5 +++++ .../.pre-commit-hooks.yaml | 15 +++++++++++++++ .../modified_file_returns_zero_repo/bin/hook.sh | 7 +++++++ .../modified_file_returns_zero_repo/bin/hook2.sh | 2 ++ .../modified_file_returns_zero_repo/bin/hook3.sh | 6 ++++++ .../resources/node_hooks_repo/.pre-commit-hooks.yaml | 5 +++++ testing/resources/node_hooks_repo/bin/main.js | 3 +++ testing/resources/node_hooks_repo/package.json | 5 +++++ .../node_versioned_hooks_repo/.pre-commit-hooks.yaml | 6 ++++++ .../resources/node_versioned_hooks_repo/bin/main.js | 4 ++++ .../resources/node_versioned_hooks_repo/package.json | 5 +++++ testing/resources/not_found_exe/.pre-commit-hooks.yaml | 5 +++++ testing/resources/perl_hooks_repo/.gitignore | 7 +++++++ .../resources/perl_hooks_repo/.pre-commit-hooks.yaml | 5 +++++ testing/resources/perl_hooks_repo/MANIFEST | 4 ++++ testing/resources/perl_hooks_repo/Makefile.PL | 10 ++++++++++ .../perl_hooks_repo/bin/pre-commit-perl-hello | 7 +++++++ .../resources/perl_hooks_repo/lib/PreCommitHello.pm | 12 ++++++++++++ .../resources/prints_cwd_repo/.pre-commit-hooks.yaml | 5 +++++ .../python3_hooks_repo/.pre-commit-hooks.yaml | 6 ++++++ testing/resources/python3_hooks_repo/py3_hook.py | 8 ++++++++ testing/resources/python3_hooks_repo/setup.py | 8 ++++++++ .../resources/python_hooks_repo/.pre-commit-hooks.yaml | 5 +++++ testing/resources/python_hooks_repo/foo.py | 7 +++++++ testing/resources/python_hooks_repo/setup.py | 8 ++++++++ .../python_venv_hooks_repo/.pre-commit-hooks.yaml | 5 +++++ testing/resources/python_venv_hooks_repo/foo.py | 7 +++++++ testing/resources/python_venv_hooks_repo/setup.py | 8 ++++++++ testing/resources/ruby_hooks_repo/.gitignore | 1 + .../resources/ruby_hooks_repo/.pre-commit-hooks.yaml | 5 +++++ testing/resources/ruby_hooks_repo/bin/ruby_hook | 3 +++ testing/resources/ruby_hooks_repo/lib/.gitignore | 0 testing/resources/ruby_hooks_repo/ruby_hook.gemspec | 9 +++++++++ testing/resources/ruby_versioned_hooks_repo/.gitignore | 1 + .../ruby_versioned_hooks_repo/.pre-commit-hooks.yaml | 6 ++++++ .../resources/ruby_versioned_hooks_repo/bin/ruby_hook | 4 ++++ .../resources/ruby_versioned_hooks_repo/lib/.gitignore | 0 .../ruby_versioned_hooks_repo/ruby_hook.gemspec | 9 +++++++++ .../resources/rust_hooks_repo/.pre-commit-hooks.yaml | 5 +++++ testing/resources/rust_hooks_repo/Cargo.lock | 3 +++ testing/resources/rust_hooks_repo/Cargo.toml | 3 +++ testing/resources/rust_hooks_repo/src/main.rs | 3 +++ .../resources/script_hooks_repo/.pre-commit-hooks.yaml | 5 +++++ testing/resources/script_hooks_repo/bin/hook.sh | 4 ++++ .../stdout_stderr_repo/.pre-commit-hooks.yaml | 8 ++++++++ .../resources/stdout_stderr_repo/stdout-stderr-entry | 7 +++++++ testing/resources/stdout_stderr_repo/tty-check-entry | 11 +++++++++++ testing/resources/swift_hooks_repo/.gitignore | 4 ++++ .../resources/swift_hooks_repo/.pre-commit-hooks.yaml | 6 ++++++ testing/resources/swift_hooks_repo/Package.swift | 7 +++++++ .../Sources/swift_hooks_repo/main.swift | 1 + .../.pre-commit-hooks.yaml | 5 +++++ testing/resources/types_repo/.pre-commit-hooks.yaml | 5 +++++ testing/resources/types_repo/bin/hook.sh | 3 +++ 73 files changed, 411 insertions(+) create mode 100644 testing/resources/arbitrary_bytes_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/arbitrary_bytes_repo/hook.sh create mode 100644 testing/resources/arg_per_line_hooks_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/arg_per_line_hooks_repo/bin/hook.sh create mode 100644 testing/resources/conda_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/conda_hooks_repo/environment.yml create mode 100644 testing/resources/docker_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/docker_hooks_repo/Dockerfile create mode 100644 testing/resources/docker_image_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/exclude_types_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/exclude_types_repo/bin/hook.sh create mode 100644 testing/resources/failing_hook_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/failing_hook_repo/bin/hook.sh create mode 100644 testing/resources/golang_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/golang_hooks_repo/golang-hello-world/main.go create mode 100644 testing/resources/img1.jpg create mode 100644 testing/resources/img2.jpg create mode 100644 testing/resources/img3.jpg create mode 100644 testing/resources/logfile_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/logfile_repo/bin/hook.sh create mode 100644 testing/resources/modified_file_returns_zero_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/modified_file_returns_zero_repo/bin/hook.sh create mode 100755 testing/resources/modified_file_returns_zero_repo/bin/hook2.sh create mode 100755 testing/resources/modified_file_returns_zero_repo/bin/hook3.sh create mode 100644 testing/resources/node_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/node_hooks_repo/bin/main.js create mode 100644 testing/resources/node_hooks_repo/package.json create mode 100644 testing/resources/node_versioned_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/node_versioned_hooks_repo/bin/main.js create mode 100644 testing/resources/node_versioned_hooks_repo/package.json create mode 100644 testing/resources/not_found_exe/.pre-commit-hooks.yaml create mode 100644 testing/resources/perl_hooks_repo/.gitignore create mode 100644 testing/resources/perl_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/perl_hooks_repo/MANIFEST create mode 100644 testing/resources/perl_hooks_repo/Makefile.PL create mode 100755 testing/resources/perl_hooks_repo/bin/pre-commit-perl-hello create mode 100644 testing/resources/perl_hooks_repo/lib/PreCommitHello.pm create mode 100644 testing/resources/prints_cwd_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/python3_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/python3_hooks_repo/py3_hook.py create mode 100644 testing/resources/python3_hooks_repo/setup.py create mode 100644 testing/resources/python_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/python_hooks_repo/foo.py create mode 100644 testing/resources/python_hooks_repo/setup.py create mode 100644 testing/resources/python_venv_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/python_venv_hooks_repo/foo.py create mode 100644 testing/resources/python_venv_hooks_repo/setup.py create mode 100644 testing/resources/ruby_hooks_repo/.gitignore create mode 100644 testing/resources/ruby_hooks_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/ruby_hooks_repo/bin/ruby_hook create mode 100644 testing/resources/ruby_hooks_repo/lib/.gitignore create mode 100644 testing/resources/ruby_hooks_repo/ruby_hook.gemspec create mode 100644 testing/resources/ruby_versioned_hooks_repo/.gitignore create mode 100644 testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/ruby_versioned_hooks_repo/bin/ruby_hook create mode 100644 testing/resources/ruby_versioned_hooks_repo/lib/.gitignore create mode 100644 testing/resources/ruby_versioned_hooks_repo/ruby_hook.gemspec create mode 100644 testing/resources/rust_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/rust_hooks_repo/Cargo.lock create mode 100644 testing/resources/rust_hooks_repo/Cargo.toml create mode 100644 testing/resources/rust_hooks_repo/src/main.rs create mode 100644 testing/resources/script_hooks_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/script_hooks_repo/bin/hook.sh create mode 100644 testing/resources/stdout_stderr_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/stdout_stderr_repo/stdout-stderr-entry create mode 100755 testing/resources/stdout_stderr_repo/tty-check-entry create mode 100644 testing/resources/swift_hooks_repo/.gitignore create mode 100644 testing/resources/swift_hooks_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/swift_hooks_repo/Package.swift create mode 100644 testing/resources/swift_hooks_repo/Sources/swift_hooks_repo/main.swift create mode 100644 testing/resources/system_hook_with_spaces_repo/.pre-commit-hooks.yaml create mode 100644 testing/resources/types_repo/.pre-commit-hooks.yaml create mode 100755 testing/resources/types_repo/bin/hook.sh (limited to 'testing/resources') diff --git a/testing/resources/arbitrary_bytes_repo/.pre-commit-hooks.yaml b/testing/resources/arbitrary_bytes_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..c2aec9b --- /dev/null +++ b/testing/resources/arbitrary_bytes_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: hook + name: hook + entry: ./hook.sh + language: script + files: \.py$ diff --git a/testing/resources/arbitrary_bytes_repo/hook.sh b/testing/resources/arbitrary_bytes_repo/hook.sh new file mode 100755 index 0000000..9df0c5a --- /dev/null +++ b/testing/resources/arbitrary_bytes_repo/hook.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# Intentionally write mixed encoding to the output. This should not crash +# pre-commit and should write bytes to the output. +# '☃'.encode() + '²'.encode('latin1') +echo -e '\xe2\x98\x83\xb2' +# exit 1 to trigger printing +exit 1 diff --git a/testing/resources/arg_per_line_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/arg_per_line_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..4c101db --- /dev/null +++ b/testing/resources/arg_per_line_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: arg-per-line + name: Args per line hook + entry: bin/hook.sh + language: script + files: '' + args: [hello, world] diff --git a/testing/resources/arg_per_line_hooks_repo/bin/hook.sh b/testing/resources/arg_per_line_hooks_repo/bin/hook.sh new file mode 100755 index 0000000..47fd21d --- /dev/null +++ b/testing/resources/arg_per_line_hooks_repo/bin/hook.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +for i in "$@"; do + echo "arg: $i" +done diff --git a/testing/resources/conda_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/conda_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..a0d274c --- /dev/null +++ b/testing/resources/conda_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,10 @@ +- id: sys-exec + name: sys-exec + entry: python -c 'import os; import sys; print(sys.executable.split(os.path.sep)[-2]) if os.name == "nt" else print(sys.executable.split(os.path.sep)[-3])' + language: conda + files: \.py$ +- id: additional-deps + name: additional-deps + entry: python + language: conda + files: \.py$ diff --git a/testing/resources/conda_hooks_repo/environment.yml b/testing/resources/conda_hooks_repo/environment.yml new file mode 100644 index 0000000..e23c079 --- /dev/null +++ b/testing/resources/conda_hooks_repo/environment.yml @@ -0,0 +1,6 @@ +channels: + - conda-forge + - defaults +dependencies: + - python + - pip diff --git a/testing/resources/docker_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/docker_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..5295739 --- /dev/null +++ b/testing/resources/docker_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,17 @@ +- id: docker-hook + name: Docker test hook + entry: echo + language: docker + files: \.txt$ + +- id: docker-hook-arg + name: Docker test hook + entry: echo -n + language: docker + files: \.txt$ + +- id: docker-hook-failing + name: Docker test hook with nonzero exit code + entry: bork + language: docker + files: \.txt$ diff --git a/testing/resources/docker_hooks_repo/Dockerfile b/testing/resources/docker_hooks_repo/Dockerfile new file mode 100644 index 0000000..841b151 --- /dev/null +++ b/testing/resources/docker_hooks_repo/Dockerfile @@ -0,0 +1,3 @@ +FROM cogniteev/echo + +CMD ["echo", "This is overwritten by the .pre-commit-hooks.yaml 'entry'"] diff --git a/testing/resources/docker_image_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/docker_image_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..1b385aa --- /dev/null +++ b/testing/resources/docker_image_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,8 @@ +- id: echo-entrypoint + name: echo (via --entrypoint) + language: docker_image + entry: --entrypoint echo cogniteev/echo +- id: echo-cmd + name: echo (via cmd) + language: docker_image + entry: cogniteev/echo echo diff --git a/testing/resources/exclude_types_repo/.pre-commit-hooks.yaml b/testing/resources/exclude_types_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..ed8794f --- /dev/null +++ b/testing/resources/exclude_types_repo/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: python-files + name: Python files + entry: bin/hook.sh + language: script + types: [python] + exclude_types: [python3] diff --git a/testing/resources/exclude_types_repo/bin/hook.sh b/testing/resources/exclude_types_repo/bin/hook.sh new file mode 100755 index 0000000..bdade51 --- /dev/null +++ b/testing/resources/exclude_types_repo/bin/hook.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo $@ +exit 1 diff --git a/testing/resources/failing_hook_repo/.pre-commit-hooks.yaml b/testing/resources/failing_hook_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..118cc8b --- /dev/null +++ b/testing/resources/failing_hook_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: failing_hook + name: Failing hook + entry: bin/hook.sh + language: script + files: . diff --git a/testing/resources/failing_hook_repo/bin/hook.sh b/testing/resources/failing_hook_repo/bin/hook.sh new file mode 100755 index 0000000..229ccaf --- /dev/null +++ b/testing/resources/failing_hook_repo/bin/hook.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +echo 'Fail' +echo $@ +exit 1 diff --git a/testing/resources/golang_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/golang_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..206733b --- /dev/null +++ b/testing/resources/golang_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: golang-hook + name: golang example hook + entry: golang-hello-world + language: golang + files: '' diff --git a/testing/resources/golang_hooks_repo/golang-hello-world/main.go b/testing/resources/golang_hooks_repo/golang-hello-world/main.go new file mode 100644 index 0000000..1e3c591 --- /dev/null +++ b/testing/resources/golang_hooks_repo/golang-hello-world/main.go @@ -0,0 +1,17 @@ +package main + + +import ( + "fmt" + "github.com/BurntSushi/toml" +) + +type Config struct { + What string +} + +func main() { + var conf Config + toml.Decode("What = 'world'\n", &conf) + fmt.Printf("hello %v\n", conf.What) +} diff --git a/testing/resources/img1.jpg b/testing/resources/img1.jpg new file mode 100644 index 0000000..dea4262 Binary files /dev/null and b/testing/resources/img1.jpg differ diff --git a/testing/resources/img2.jpg b/testing/resources/img2.jpg new file mode 100644 index 0000000..68568e5 Binary files /dev/null and b/testing/resources/img2.jpg differ diff --git a/testing/resources/img3.jpg b/testing/resources/img3.jpg new file mode 100644 index 0000000..392d2cf Binary files /dev/null and b/testing/resources/img3.jpg differ diff --git a/testing/resources/logfile_repo/.pre-commit-hooks.yaml b/testing/resources/logfile_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..dcaba2e --- /dev/null +++ b/testing/resources/logfile_repo/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: logfile test hook + name: Logfile test hook + entry: bin/hook.sh + language: script + files: . + log_file: test.log diff --git a/testing/resources/logfile_repo/bin/hook.sh b/testing/resources/logfile_repo/bin/hook.sh new file mode 100755 index 0000000..890d941 --- /dev/null +++ b/testing/resources/logfile_repo/bin/hook.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +echo "This is STDOUT output" +echo "This is STDERR output" 1>&2 + +exit 1 diff --git a/testing/resources/modified_file_returns_zero_repo/.pre-commit-hooks.yaml b/testing/resources/modified_file_returns_zero_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..8d79ef3 --- /dev/null +++ b/testing/resources/modified_file_returns_zero_repo/.pre-commit-hooks.yaml @@ -0,0 +1,15 @@ +- id: bash_hook + name: Bash hook + entry: bin/hook.sh + language: script + files: 'foo.py' +- id: bash_hook2 + name: Bash hook + entry: bin/hook2.sh + language: script + files: '' +- id: bash_hook3 + name: Bash hook + entry: bin/hook3.sh + language: script + files: 'bar.py' diff --git a/testing/resources/modified_file_returns_zero_repo/bin/hook.sh b/testing/resources/modified_file_returns_zero_repo/bin/hook.sh new file mode 100755 index 0000000..98b05f9 --- /dev/null +++ b/testing/resources/modified_file_returns_zero_repo/bin/hook.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +for f in $@; do + # Non UTF-8 bytes + echo -e '\x01\x97' > "$f" + echo "Modified: $f!" +done diff --git a/testing/resources/modified_file_returns_zero_repo/bin/hook2.sh b/testing/resources/modified_file_returns_zero_repo/bin/hook2.sh new file mode 100755 index 0000000..5af177a --- /dev/null +++ b/testing/resources/modified_file_returns_zero_repo/bin/hook2.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +echo $@ diff --git a/testing/resources/modified_file_returns_zero_repo/bin/hook3.sh b/testing/resources/modified_file_returns_zero_repo/bin/hook3.sh new file mode 100755 index 0000000..3180eb3 --- /dev/null +++ b/testing/resources/modified_file_returns_zero_repo/bin/hook3.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +for f in $@; do + # Non UTF-8 bytes + echo -e '\x01\x97' > "$f" +done diff --git a/testing/resources/node_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/node_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..257698a --- /dev/null +++ b/testing/resources/node_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: foo + name: Foo + entry: foo + language: node + files: \.js$ diff --git a/testing/resources/node_hooks_repo/bin/main.js b/testing/resources/node_hooks_repo/bin/main.js new file mode 100644 index 0000000..8e0f025 --- /dev/null +++ b/testing/resources/node_hooks_repo/bin/main.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +console.log('Hello World'); diff --git a/testing/resources/node_hooks_repo/package.json b/testing/resources/node_hooks_repo/package.json new file mode 100644 index 0000000..050b630 --- /dev/null +++ b/testing/resources/node_hooks_repo/package.json @@ -0,0 +1,5 @@ +{ + "name": "foo", + "version": "0.0.1", + "bin": {"foo": "./bin/main.js"} +} diff --git a/testing/resources/node_versioned_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/node_versioned_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..e7ad5ea --- /dev/null +++ b/testing/resources/node_versioned_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: versioned-node-hook + name: Versioned node hook + entry: versioned-node-hook + language: node + language_version: 9.3.0 + files: \.js$ diff --git a/testing/resources/node_versioned_hooks_repo/bin/main.js b/testing/resources/node_versioned_hooks_repo/bin/main.js new file mode 100644 index 0000000..df12cbe --- /dev/null +++ b/testing/resources/node_versioned_hooks_repo/bin/main.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node + +console.log(process.version); +console.log('Hello World'); diff --git a/testing/resources/node_versioned_hooks_repo/package.json b/testing/resources/node_versioned_hooks_repo/package.json new file mode 100644 index 0000000..18c7787 --- /dev/null +++ b/testing/resources/node_versioned_hooks_repo/package.json @@ -0,0 +1,5 @@ +{ + "name": "versioned-node-hook", + "version": "0.0.1", + "bin": {"versioned-node-hook": "./bin/main.js"} +} diff --git a/testing/resources/not_found_exe/.pre-commit-hooks.yaml b/testing/resources/not_found_exe/.pre-commit-hooks.yaml new file mode 100644 index 0000000..566f3c1 --- /dev/null +++ b/testing/resources/not_found_exe/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: not-found-exe + name: Not found exe + entry: i-dont-exist-lol + language: system + files: '' diff --git a/testing/resources/perl_hooks_repo/.gitignore b/testing/resources/perl_hooks_repo/.gitignore new file mode 100644 index 0000000..7af9940 --- /dev/null +++ b/testing/resources/perl_hooks_repo/.gitignore @@ -0,0 +1,7 @@ +/MYMETA.json +/MYMETA.yml +/Makefile +/PreCommitHello-*.tar.* +/PreCommitHello-*/ +/blib/ +/pm_to_blib diff --git a/testing/resources/perl_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/perl_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..11e6f6c --- /dev/null +++ b/testing/resources/perl_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: perl-hook + name: perl example hook + entry: pre-commit-perl-hello + language: perl + files: '' diff --git a/testing/resources/perl_hooks_repo/MANIFEST b/testing/resources/perl_hooks_repo/MANIFEST new file mode 100644 index 0000000..4a20084 --- /dev/null +++ b/testing/resources/perl_hooks_repo/MANIFEST @@ -0,0 +1,4 @@ +MANIFEST +Makefile.PL +bin/pre-commit-perl-hello +lib/PreCommitHello.pm diff --git a/testing/resources/perl_hooks_repo/Makefile.PL b/testing/resources/perl_hooks_repo/Makefile.PL new file mode 100644 index 0000000..6c70e10 --- /dev/null +++ b/testing/resources/perl_hooks_repo/Makefile.PL @@ -0,0 +1,10 @@ +use strict; +use warnings; + +use ExtUtils::MakeMaker; + +WriteMakefile( + NAME => "PreCommitHello", + VERSION_FROM => "lib/PreCommitHello.pm", + EXE_FILES => [qw(bin/pre-commit-perl-hello)], +); diff --git a/testing/resources/perl_hooks_repo/bin/pre-commit-perl-hello b/testing/resources/perl_hooks_repo/bin/pre-commit-perl-hello new file mode 100755 index 0000000..9474009 --- /dev/null +++ b/testing/resources/perl_hooks_repo/bin/pre-commit-perl-hello @@ -0,0 +1,7 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use PreCommitHello; + +PreCommitHello::hello(); diff --git a/testing/resources/perl_hooks_repo/lib/PreCommitHello.pm b/testing/resources/perl_hooks_repo/lib/PreCommitHello.pm new file mode 100644 index 0000000..c76521c --- /dev/null +++ b/testing/resources/perl_hooks_repo/lib/PreCommitHello.pm @@ -0,0 +1,12 @@ +package PreCommitHello; + +use strict; +use warnings; + +our $VERSION = "0.1.0"; + +sub hello { + print "Hello from perl-commit Perl!\n"; +} + +1; diff --git a/testing/resources/prints_cwd_repo/.pre-commit-hooks.yaml b/testing/resources/prints_cwd_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..7092379 --- /dev/null +++ b/testing/resources/prints_cwd_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: prints_cwd + name: Prints Cwd + entry: pwd + language: system + files: \.sh$ diff --git a/testing/resources/python3_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/python3_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..2c23700 --- /dev/null +++ b/testing/resources/python3_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: python3-hook + name: Python 3 Hook + entry: python3-hook + language: python + language_version: python3 + files: \.py$ diff --git a/testing/resources/python3_hooks_repo/py3_hook.py b/testing/resources/python3_hooks_repo/py3_hook.py new file mode 100644 index 0000000..8c9cda4 --- /dev/null +++ b/testing/resources/python3_hooks_repo/py3_hook.py @@ -0,0 +1,8 @@ +import sys + + +def main(): + print(sys.version_info[0]) + print(repr(sys.argv[1:])) + print('Hello World') + return 0 diff --git a/testing/resources/python3_hooks_repo/setup.py b/testing/resources/python3_hooks_repo/setup.py new file mode 100644 index 0000000..9125dc1 --- /dev/null +++ b/testing/resources/python3_hooks_repo/setup.py @@ -0,0 +1,8 @@ +from setuptools import setup + +setup( + name='python3_hook', + version='0.0.0', + py_modules=['py3_hook'], + entry_points={'console_scripts': ['python3-hook = py3_hook:main']}, +) diff --git a/testing/resources/python_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/python_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..e10ad50 --- /dev/null +++ b/testing/resources/python_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: foo + name: Foo + entry: foo + language: python + files: \.py$ diff --git a/testing/resources/python_hooks_repo/foo.py b/testing/resources/python_hooks_repo/foo.py new file mode 100644 index 0000000..9c4368e --- /dev/null +++ b/testing/resources/python_hooks_repo/foo.py @@ -0,0 +1,7 @@ +import sys + + +def main(): + print(repr(sys.argv[1:])) + print('Hello World') + return 0 diff --git a/testing/resources/python_hooks_repo/setup.py b/testing/resources/python_hooks_repo/setup.py new file mode 100644 index 0000000..0559271 --- /dev/null +++ b/testing/resources/python_hooks_repo/setup.py @@ -0,0 +1,8 @@ +from setuptools import setup + +setup( + name='foo', + version='0.0.0', + py_modules=['foo'], + entry_points={'console_scripts': ['foo = foo:main']}, +) diff --git a/testing/resources/python_venv_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/python_venv_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..a666ed8 --- /dev/null +++ b/testing/resources/python_venv_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: foo + name: Foo + entry: foo + language: python_venv + files: \.py$ diff --git a/testing/resources/python_venv_hooks_repo/foo.py b/testing/resources/python_venv_hooks_repo/foo.py new file mode 100644 index 0000000..9c4368e --- /dev/null +++ b/testing/resources/python_venv_hooks_repo/foo.py @@ -0,0 +1,7 @@ +import sys + + +def main(): + print(repr(sys.argv[1:])) + print('Hello World') + return 0 diff --git a/testing/resources/python_venv_hooks_repo/setup.py b/testing/resources/python_venv_hooks_repo/setup.py new file mode 100644 index 0000000..0559271 --- /dev/null +++ b/testing/resources/python_venv_hooks_repo/setup.py @@ -0,0 +1,8 @@ +from setuptools import setup + +setup( + name='foo', + version='0.0.0', + py_modules=['foo'], + entry_points={'console_scripts': ['foo = foo:main']}, +) diff --git a/testing/resources/ruby_hooks_repo/.gitignore b/testing/resources/ruby_hooks_repo/.gitignore new file mode 100644 index 0000000..c111b33 --- /dev/null +++ b/testing/resources/ruby_hooks_repo/.gitignore @@ -0,0 +1 @@ +*.gem diff --git a/testing/resources/ruby_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/ruby_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..aa15872 --- /dev/null +++ b/testing/resources/ruby_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: ruby_hook + name: Ruby Hook + entry: ruby_hook + language: ruby + files: \.rb$ diff --git a/testing/resources/ruby_hooks_repo/bin/ruby_hook b/testing/resources/ruby_hooks_repo/bin/ruby_hook new file mode 100755 index 0000000..5a7e5ed --- /dev/null +++ b/testing/resources/ruby_hooks_repo/bin/ruby_hook @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby + +puts 'Hello world from a ruby hook' diff --git a/testing/resources/ruby_hooks_repo/lib/.gitignore b/testing/resources/ruby_hooks_repo/lib/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/testing/resources/ruby_hooks_repo/ruby_hook.gemspec b/testing/resources/ruby_hooks_repo/ruby_hook.gemspec new file mode 100644 index 0000000..75f4e8f --- /dev/null +++ b/testing/resources/ruby_hooks_repo/ruby_hook.gemspec @@ -0,0 +1,9 @@ +Gem::Specification.new do |s| + s.name = 'ruby_hook' + s.version = '0.1.0' + s.authors = ['Anthony Sottile'] + s.summary = 'A ruby hook!' + s.description = 'A ruby hook!' + s.files = ['bin/ruby_hook'] + s.executables = ['ruby_hook'] +end diff --git a/testing/resources/ruby_versioned_hooks_repo/.gitignore b/testing/resources/ruby_versioned_hooks_repo/.gitignore new file mode 100644 index 0000000..c111b33 --- /dev/null +++ b/testing/resources/ruby_versioned_hooks_repo/.gitignore @@ -0,0 +1 @@ +*.gem diff --git a/testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..63e1dd4 --- /dev/null +++ b/testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: ruby_hook + name: Ruby Hook + entry: ruby_hook + language: ruby + language_version: 2.5.1 + files: \.rb$ diff --git a/testing/resources/ruby_versioned_hooks_repo/bin/ruby_hook b/testing/resources/ruby_versioned_hooks_repo/bin/ruby_hook new file mode 100755 index 0000000..2406f04 --- /dev/null +++ b/testing/resources/ruby_versioned_hooks_repo/bin/ruby_hook @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +puts RUBY_VERSION +puts 'Hello world from a ruby hook' diff --git a/testing/resources/ruby_versioned_hooks_repo/lib/.gitignore b/testing/resources/ruby_versioned_hooks_repo/lib/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/testing/resources/ruby_versioned_hooks_repo/ruby_hook.gemspec b/testing/resources/ruby_versioned_hooks_repo/ruby_hook.gemspec new file mode 100644 index 0000000..75f4e8f --- /dev/null +++ b/testing/resources/ruby_versioned_hooks_repo/ruby_hook.gemspec @@ -0,0 +1,9 @@ +Gem::Specification.new do |s| + s.name = 'ruby_hook' + s.version = '0.1.0' + s.authors = ['Anthony Sottile'] + s.summary = 'A ruby hook!' + s.description = 'A ruby hook!' + s.files = ['bin/ruby_hook'] + s.executables = ['ruby_hook'] +end diff --git a/testing/resources/rust_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/rust_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..df1269f --- /dev/null +++ b/testing/resources/rust_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: rust-hook + name: rust example hook + entry: rust-hello-world + language: rust + files: '' diff --git a/testing/resources/rust_hooks_repo/Cargo.lock b/testing/resources/rust_hooks_repo/Cargo.lock new file mode 100644 index 0000000..36fbfda --- /dev/null +++ b/testing/resources/rust_hooks_repo/Cargo.lock @@ -0,0 +1,3 @@ +[[package]] +name = "rust-hello-world" +version = "0.1.0" diff --git a/testing/resources/rust_hooks_repo/Cargo.toml b/testing/resources/rust_hooks_repo/Cargo.toml new file mode 100644 index 0000000..cd83b43 --- /dev/null +++ b/testing/resources/rust_hooks_repo/Cargo.toml @@ -0,0 +1,3 @@ +[package] +name = "rust-hello-world" +version = "0.1.0" diff --git a/testing/resources/rust_hooks_repo/src/main.rs b/testing/resources/rust_hooks_repo/src/main.rs new file mode 100644 index 0000000..ad379d6 --- /dev/null +++ b/testing/resources/rust_hooks_repo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("hello world"); +} diff --git a/testing/resources/script_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/script_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..21cad4a --- /dev/null +++ b/testing/resources/script_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: bash_hook + name: Bash hook + entry: bin/hook.sh + language: script + files: '' diff --git a/testing/resources/script_hooks_repo/bin/hook.sh b/testing/resources/script_hooks_repo/bin/hook.sh new file mode 100755 index 0000000..6565ee4 --- /dev/null +++ b/testing/resources/script_hooks_repo/bin/hook.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +echo $@ +echo 'Hello World' diff --git a/testing/resources/stdout_stderr_repo/.pre-commit-hooks.yaml b/testing/resources/stdout_stderr_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..6800d25 --- /dev/null +++ b/testing/resources/stdout_stderr_repo/.pre-commit-hooks.yaml @@ -0,0 +1,8 @@ +- id: stdout-stderr + name: stdout-stderr + language: script + entry: ./stdout-stderr-entry +- id: tty-check + name: tty-check + language: script + entry: ./tty-check-entry diff --git a/testing/resources/stdout_stderr_repo/stdout-stderr-entry b/testing/resources/stdout_stderr_repo/stdout-stderr-entry new file mode 100755 index 0000000..7563df5 --- /dev/null +++ b/testing/resources/stdout_stderr_repo/stdout-stderr-entry @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +echo 0 +echo 1 1>&2 +echo 2 +echo 3 1>&2 +echo 4 +echo 5 1>&2 diff --git a/testing/resources/stdout_stderr_repo/tty-check-entry b/testing/resources/stdout_stderr_repo/tty-check-entry new file mode 100755 index 0000000..01a9d38 --- /dev/null +++ b/testing/resources/stdout_stderr_repo/tty-check-entry @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +t() { + if [ -t "$1" ]; then + echo "$2: True" + else + echo "$2: False" + fi +} +t 0 stdin +t 1 stdout +t 2 stderr diff --git a/testing/resources/swift_hooks_repo/.gitignore b/testing/resources/swift_hooks_repo/.gitignore new file mode 100644 index 0000000..02c0875 --- /dev/null +++ b/testing/resources/swift_hooks_repo/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj diff --git a/testing/resources/swift_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/swift_hooks_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..c08df87 --- /dev/null +++ b/testing/resources/swift_hooks_repo/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: swift-hooks-repo + name: Swift hooks repo example + description: Runs the hello world app generated by swift package init --type executable (binary called swift_hooks_repo here) + entry: swift_hooks_repo + language: swift + files: \.(swift)$ diff --git a/testing/resources/swift_hooks_repo/Package.swift b/testing/resources/swift_hooks_repo/Package.swift new file mode 100644 index 0000000..04976d3 --- /dev/null +++ b/testing/resources/swift_hooks_repo/Package.swift @@ -0,0 +1,7 @@ +// swift-tools-version:5.0 +import PackageDescription + +let package = Package( + name: "swift_hooks_repo", + targets: [.target(name: "swift_hooks_repo")] +) diff --git a/testing/resources/swift_hooks_repo/Sources/swift_hooks_repo/main.swift b/testing/resources/swift_hooks_repo/Sources/swift_hooks_repo/main.swift new file mode 100644 index 0000000..f7cf60e --- /dev/null +++ b/testing/resources/swift_hooks_repo/Sources/swift_hooks_repo/main.swift @@ -0,0 +1 @@ +print("Hello, world!") diff --git a/testing/resources/system_hook_with_spaces_repo/.pre-commit-hooks.yaml b/testing/resources/system_hook_with_spaces_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..b2c347c --- /dev/null +++ b/testing/resources/system_hook_with_spaces_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: system-hook-with-spaces + name: System hook with spaces + entry: bash -c 'echo "Hello World"' + language: system + files: \.sh$ diff --git a/testing/resources/types_repo/.pre-commit-hooks.yaml b/testing/resources/types_repo/.pre-commit-hooks.yaml new file mode 100644 index 0000000..2e5e4a6 --- /dev/null +++ b/testing/resources/types_repo/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: python-files + name: Python files + entry: bin/hook.sh + language: script + types: [python] diff --git a/testing/resources/types_repo/bin/hook.sh b/testing/resources/types_repo/bin/hook.sh new file mode 100755 index 0000000..bdade51 --- /dev/null +++ b/testing/resources/types_repo/bin/hook.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo $@ +exit 1 -- cgit v1.2.3