1
0
Fork 0

Adding upstream version 2.2.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 21:10:22 +01:00
parent 18c908e4f3
commit c0d06915b7
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
199 changed files with 14930 additions and 0 deletions
testing/resources
arbitrary_bytes_repo
arg_per_line_hooks_repo
conda_hooks_repo
docker_hooks_repo
docker_image_hooks_repo
exclude_types_repo
failing_hook_repo
golang_hooks_repo
img1.jpgimg2.jpgimg3.jpg
logfile_repo
modified_file_returns_zero_repo
node_hooks_repo
node_versioned_hooks_repo
not_found_exe
perl_hooks_repo
prints_cwd_repo
python3_hooks_repo
python_hooks_repo
python_venv_hooks_repo
ruby_hooks_repo
ruby_versioned_hooks_repo
rust_hooks_repo
script_hooks_repo
stdout_stderr_repo
swift_hooks_repo
system_hook_with_spaces_repo
types_repo

View file

@ -0,0 +1,5 @@
- id: hook
name: hook
entry: ./hook.sh
language: script
files: \.py$

View file

@ -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

View file

@ -0,0 +1,6 @@
- id: arg-per-line
name: Args per line hook
entry: bin/hook.sh
language: script
files: ''
args: [hello, world]

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
for i in "$@"; do
echo "arg: $i"
done

View file

@ -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$

View file

@ -0,0 +1,6 @@
channels:
- conda-forge
- defaults
dependencies:
- python
- pip

View file

@ -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$

View file

@ -0,0 +1,3 @@
FROM cogniteev/echo
CMD ["echo", "This is overwritten by the .pre-commit-hooks.yaml 'entry'"]

View file

@ -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

View file

@ -0,0 +1,6 @@
- id: python-files
name: Python files
entry: bin/hook.sh
language: script
types: [python]
exclude_types: [python3]

View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo $@
exit 1

View file

@ -0,0 +1,5 @@
- id: failing_hook
name: Failing hook
entry: bin/hook.sh
language: script
files: .

View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
echo 'Fail'
echo $@
exit 1

View file

@ -0,0 +1,5 @@
- id: golang-hook
name: golang example hook
entry: golang-hello-world
language: golang
files: ''

View file

@ -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)
}

BIN
testing/resources/img1.jpg Normal file

Binary file not shown.

After

(image error) Size: 843 B

BIN
testing/resources/img2.jpg Normal file

Binary file not shown.

After

(image error) Size: 891 B

BIN
testing/resources/img3.jpg Normal file

Binary file not shown.

After

(image error) Size: 859 B

View file

@ -0,0 +1,6 @@
- id: logfile test hook
name: Logfile test hook
entry: bin/hook.sh
language: script
files: .
log_file: test.log

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
echo "This is STDOUT output"
echo "This is STDERR output" 1>&2
exit 1

View file

@ -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'

View file

@ -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

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
echo $@

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
for f in $@; do
# Non UTF-8 bytes
echo -e '\x01\x97' > "$f"
done

View file

@ -0,0 +1,5 @@
- id: foo
name: Foo
entry: foo
language: node
files: \.js$

View file

@ -0,0 +1,3 @@
#!/usr/bin/env node
console.log('Hello World');

View file

@ -0,0 +1,5 @@
{
"name": "foo",
"version": "0.0.1",
"bin": {"foo": "./bin/main.js"}
}

View file

@ -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$

View file

@ -0,0 +1,4 @@
#!/usr/bin/env node
console.log(process.version);
console.log('Hello World');

View file

@ -0,0 +1,5 @@
{
"name": "versioned-node-hook",
"version": "0.0.1",
"bin": {"versioned-node-hook": "./bin/main.js"}
}

View file

@ -0,0 +1,5 @@
- id: not-found-exe
name: Not found exe
entry: i-dont-exist-lol
language: system
files: ''

View file

@ -0,0 +1,7 @@
/MYMETA.json
/MYMETA.yml
/Makefile
/PreCommitHello-*.tar.*
/PreCommitHello-*/
/blib/
/pm_to_blib

View file

@ -0,0 +1,5 @@
- id: perl-hook
name: perl example hook
entry: pre-commit-perl-hello
language: perl
files: ''

View file

@ -0,0 +1,4 @@
MANIFEST
Makefile.PL
bin/pre-commit-perl-hello
lib/PreCommitHello.pm

View file

@ -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)],
);

View file

@ -0,0 +1,7 @@
#!/usr/bin/env perl
use strict;
use warnings;
use PreCommitHello;
PreCommitHello::hello();

View file

@ -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;

View file

@ -0,0 +1,5 @@
- id: prints_cwd
name: Prints Cwd
entry: pwd
language: system
files: \.sh$

View file

@ -0,0 +1,6 @@
- id: python3-hook
name: Python 3 Hook
entry: python3-hook
language: python
language_version: python3
files: \.py$

View file

@ -0,0 +1,8 @@
import sys
def main():
print(sys.version_info[0])
print(repr(sys.argv[1:]))
print('Hello World')
return 0

View file

@ -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']},
)

View file

@ -0,0 +1,5 @@
- id: foo
name: Foo
entry: foo
language: python
files: \.py$

View file

@ -0,0 +1,7 @@
import sys
def main():
print(repr(sys.argv[1:]))
print('Hello World')
return 0

View file

@ -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']},
)

View file

@ -0,0 +1,5 @@
- id: foo
name: Foo
entry: foo
language: python_venv
files: \.py$

View file

@ -0,0 +1,7 @@
import sys
def main():
print(repr(sys.argv[1:]))
print('Hello World')
return 0

View file

@ -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']},
)

View file

@ -0,0 +1 @@
*.gem

View file

@ -0,0 +1,5 @@
- id: ruby_hook
name: Ruby Hook
entry: ruby_hook
language: ruby
files: \.rb$

View file

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
puts 'Hello world from a ruby hook'

View file

View file

@ -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

View file

@ -0,0 +1 @@
*.gem

View file

@ -0,0 +1,6 @@
- id: ruby_hook
name: Ruby Hook
entry: ruby_hook
language: ruby
language_version: 2.5.1
files: \.rb$

View file

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
puts RUBY_VERSION
puts 'Hello world from a ruby hook'

View file

@ -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

View file

@ -0,0 +1,5 @@
- id: rust-hook
name: rust example hook
entry: rust-hello-world
language: rust
files: ''

View file

@ -0,0 +1,3 @@
[[package]]
name = "rust-hello-world"
version = "0.1.0"

View file

@ -0,0 +1,3 @@
[package]
name = "rust-hello-world"
version = "0.1.0"

View file

@ -0,0 +1,3 @@
fn main() {
println!("hello world");
}

View file

@ -0,0 +1,5 @@
- id: bash_hook
name: Bash hook
entry: bin/hook.sh
language: script
files: ''

View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
echo $@
echo 'Hello World'

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,4 @@
.DS_Store
/.build
/Packages
/*.xcodeproj

View file

@ -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)$

View file

@ -0,0 +1,7 @@
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "swift_hooks_repo",
targets: [.target(name: "swift_hooks_repo")]
)

View file

@ -0,0 +1 @@
print("Hello, world!")

View file

@ -0,0 +1,5 @@
- id: system-hook-with-spaces
name: System hook with spaces
entry: bash -c 'echo "Hello World"'
language: system
files: \.sh$

View file

@ -0,0 +1,5 @@
- id: python-files
name: Python files
entry: bin/hook.sh
language: script
types: [python]

View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo $@
exit 1