Skip to content

Cannot run pre-commit hooks in GitHub Desktop #21317

@tougiTakahiro

Description

@tougiTakahiro

The problem

I tried to run pre-commit hooks below.

#!/bin/sh

# コミット対象の編集された.xlsxファイルを取得
xlsx_files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.xlsx$')

# .xlsxファイルがある場合はCheckSheetConflictを実行
if [ -n "$xlsx_files" ]; then
    echo "Checking sheet conflicts for: $xlsx_files"
    
    # publishディレクトリのパスを取得
    repo_root=$(git rev-parse --show-toplevel)
    
    publish_dir="$repo_root/hoge/publish/mac"
    
    # Check if publish directory exists
    if [ ! -d "$publish_dir" ]; then
        echo "Error: Publish directory not found: $publish_dir"
        exit 1
    fi
    
    executable="$publish_dir/hoge"
    
    # CheckSheetConflictを実行
    "$executable" CheckSheetConflict $xlsx_files

    # 実行結果を確認
    if [ $? -ne 0 ]; then
        echo "CheckSheetConflict failed. Commit aborted."
        exit 1
    fi
    
    echo "CheckSheetConflict passed."
fi

exit 0

When I try to commit by CLI, this hook run successfully, but by desktop, this hooks didn't run and commit passed in any situation.

"executable" contains google oauth, and googlr api access.

Release version

3.5.4

Operating system

macOS

Steps to reproduce the behavior

No response

Log files

No response

Screenshots

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bugs or reports that are very likely to be bugs

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions