hiroyuki-sato opened a new issue, #44528:
URL: https://github.com/apache/arrow/issues/44528

   ### Describe the enhancement requested
   
   The `pre-commit` command has the feature format the source.
   It will be more useful if the `pre-commit` commands support reformatting the 
code for specific languages only.
   
   ## Current behavior.
   
   For example,
   There are three wrong format files.
   
   ```
   % git status .
   On branch pre-commit
   Changes not staged for commit:
     (use "git add <file>..." to update what will be committed)
     (use "git restore <file>..." to discard changes in working directory)
        modified:   c_glib/arrow-glib/basic-data-type.cpp
        modified:   cpp/src/arrow/type.cc
        modified:   r/src/dataset.cpp
   no changes added to commit (use "git add" and/or "git commit -a")
   ```
   
   `pre-commit run --color=always --all-files` check and reformat codes in all 
sub directories.
   
   ```
   pre-commit run --color=always --all-files
   Release Audit 
Tool.......................................................Passed
   Docker 
Format............................................................Failed
   - hook id: hadolint-docker
   - exit code: 125
   
   docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. 
Is the docker daemon running?.
   See 'docker run --help'.
   
   Python 
Format............................................................Passed
   
cython-lint..............................................................Passed
   C++ 
Format...............................................................Failed
   - hook id: clang-format
   - files were modified by this hook
   C++ 
Lint.................................................................Passed
   C/GLib 
Format............................................................Failed
   - hook id: clang-format
   - files were modified by this hook
   MATLAB (C++) 
Format......................................................Passed
   Python (C++) 
Format......................................................Passed
   R (C++) 
Format...........................................................Failed
   - hook id: clang-format
   - files were modified by this hook
   CMake 
Format.............................................................Passed
   Sphinx 
Lint..............................................................Passed
   ```
   
   The tree files have been reformated by the `pre-commit` command.
   
   ```
   % git status .
   On branch pre-commit
   nothing to commit, working tree clean
   ```
   
   
   ## New commands
   
   For example, the following command reformat codes in `c_glib` directory only.
   
   ```
   % pre-commit run --color=always --all-files c-glib-format
   C/GLib 
Format............................................................Failed
   - hook id: clang-format
   - files were modified by this hook
   ```
   
   `r` and `cpp` directories don't change the code.
   
   ```
   % git status .
   On branch pre-commit
   Changes not staged for commit:
     (use "git add <file>..." to update what will be committed)
     (use "git restore <file>..." to discard changes in working directory)
        modified:   cpp/src/arrow/type.cc
        modified:   r/src/dataset.cpp
   
   no changes added to commit (use "git add" and/or "git commit -a")
   ```
   
   This command reformat codes in the `r` subdirectory only.
   
   ```
   pre-commit run --color=always --all-files r-format
   R (C++) 
Format...........................................................Failed
   - hook id: clang-format
   - files were modified by this hook
   ```
   
   ```
   git status .
   On branch pre-commit
   Changes not staged for commit:
     (use "git add <file>..." to update what will be committed)
     (use "git restore <file>..." to discard changes in working directory)
        modified:   c_glib/arrow-glib/basic-data-type.cpp
        modified:   cpp/src/arrow/type.cc
   
   no changes added to commit (use "git add" and/or "git commit -a")
   ```
   
   ### Component(s)
   
   Developer Tools


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to