From ef8109893260eeb797aa881f694f41dbe750cff7 Mon Sep 17 00:00:00 2001 From: Jefffrey Date: Wed, 29 Jul 2026 08:16:39 +0900 Subject: [PATCH] chore: remove pre-commit scripts --- .pre-commit-config.yaml | 69 --------------------------------- CONTRIBUTING.md | 25 ------------ pre-commit.sh | 86 ----------------------------------------- 3 files changed, 180 deletions(-) delete mode 100644 .pre-commit-config.yaml delete mode 100755 pre-commit.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 5331a5313ca2..000000000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,69 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# To use this, install the python package `pre-commit` and -# run once `pre-commit install`. This will setup a git pre-commit-hook -# that is executed on each commit and will report the linting problems. -# To run all hooks on all files use `pre-commit run -a` - -repos: - - repo: local - hooks: - - id: rat - name: Release Audit Tool - language: system - entry: bash -c "git archive HEAD --prefix=apache-arrow/ --output=arrow-src.tar && ./dev/release/run-rat.sh arrow-src.tar" - always_run: true - pass_filenames: false - - id: rustfmt - name: Rust Format - language: system - entry: bash -c "cargo +stable fmt --all -- --check" - files: ^.*\.rs$ - types: - - file - - rust - - id: cmake-format - name: CMake Format - language: python - entry: python run-cmake-format.py - types: [cmake] - additional_dependencies: - - cmake_format==0.5.2 - - id: hadolint - name: Docker Format - language: docker_image - types: - - dockerfile - entry: --entrypoint /bin/hadolint hadolint/hadolint:latest - - exclude: ^dev/.*$ - - repo: git://github.com/pre-commit/pre-commit-hooks - sha: v1.2.3 - hooks: - - id: flake8 - name: Python Format - files: ^(python|dev|integration)/ - types: - - file - - python - - id: flake8 - name: Cython Format - files: ^python/ - types: - - file - - cython - args: [--config=python/.flake8.cython] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 48075c5ef771..c2d57f20ca4c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -232,31 +232,6 @@ If you need to add new benchmarks to cover your change, make a separate PR first [#9729]: https://github.com/apache/arrow-rs/pull/9729 -## Git Pre-Commit Hook - -We can use [git pre-commit hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to automate various kinds of git pre-commit checking/formatting. - -Suppose you are in the root directory of the project. - -First check if the file already exists: - -```bash -ls -l .git/hooks/pre-commit -``` - -If the file already exists, to avoid mistakenly **overriding**, you MAY have to check -the link source or file content. Else if not exist, let's safely soft link [pre-commit.sh](pre-commit.sh) as file `.git/hooks/pre-commit`: - -```bash -ln -s ../../pre-commit.sh .git/hooks/pre-commit -``` - -If sometimes you want to commit without checking, just run `git commit` with `--no-verify`: - -```bash -git commit --no-verify -m "... commit message ..." -``` - ## AI Generated Submissions This project follows the guidance for AI generated submissions used by the diff --git a/pre-commit.sh b/pre-commit.sh deleted file mode 100755 index f82390e229a9..000000000000 --- a/pre-commit.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# This file is git pre-commit hook. -# -# Soft link it as git hook under top dir of apache arrow git repository: -# $ ln -s ../../pre-commit.sh .git/hooks/pre-commit -# -# This file be run directly: -# $ ./pre-commit.sh - -function RED() { - echo "\033[0;31m$@\033[0m" -} - -function GREEN() { - echo "\033[0;32m$@\033[0m" -} - -function BYELLOW() { - echo "\033[1;33m$@\033[0m" -} - -# env GIT_DIR is set by git when run a pre-commit hook. -if [ -z "${GIT_DIR}" ]; then - GIT_DIR=$(git rev-parse --show-toplevel) -fi - -cd ${GIT_DIR} - -NUM_CHANGES=$(git diff --cached --name-only . | - grep -e ".*/*.rs$" | - awk '{print $1}' | - wc -l) - -if [ ${NUM_CHANGES} -eq 0 ]; then - echo -e "$(GREEN INFO): no staged changes in *.rs, $(GREEN skip cargo fmt/clippy)" - exit 0 -fi - -# 1. cargo clippy - -echo -e "$(GREEN INFO): cargo clippy ..." - -# Cargo clippy always return exit code 0, and `tee` doesn't work. -# So let's just run cargo clippy. -cargo clippy -echo -e "$(GREEN INFO): cargo clippy done" - -# 2. cargo fmt: format with nightly and stable. - -CHANGED_BY_CARGO_FMT=false -echo -e "$(GREEN INFO): cargo fmt with nightly and stable ..." - -for version in nightly stable; do - CMD="cargo +${version} fmt" - ${CMD} --all -q -- --check 2>/dev/null - if [ $? -ne 0 ]; then - ${CMD} --all - echo -e "$(BYELLOW WARN): ${CMD} changed some files" - CHANGED_BY_CARGO_FMT=true - fi -done - -if ${CHANGED_BY_CARGO_FMT}; then - echo -e "$(RED FAIL): git commit $(RED ABORTED), please have a look and run git add/commit again" - exit 1 -fi - -exit 0