<commit_before>#!/bin/bash

#
# Setup git hooks in this or all repositories.
#
# Run this script once to configure your system to work with our Git workflow.
#

ROOT=$(git rev-parse --show-toplevel)
if [[ -n "$WINDIR" ]]; then
  # https://stackoverflow.com/a/39160850/1836776
  SCRIPT_DIR=$(cmd //C cd)
else
  SCRIPT_DIR="$(dirname "$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")")"
fi

case $1 in
  --global)
    # Requires Git 2.9 or later.
    coreHooksPath=`git config --global core.hooksPath`
    if [[ -z "$coreHooksPath" ]]; then coreHooksPath="(not set)"; fi
    echo "Current Git core.hooksPath is: $coreHooksPath"

    git config --global core.hooksPath $SCRIPT_DIR/resources/git-hooks
    echo "Git is now configured to use $SCRIPT_DIR/resources/git-hooks for all repositories"

    ;;
  --local)
    if [[ -n "$WINDIR" ]]; then
      # https://stackoverflow.com/a/39160850/1836776
      WinPWD=$(cmd //C cd)
      cmd //C "mklink $WinPWD\\.git\\hooks\\commit-msg $WinPWD\\resources\\git-hooks\\commit-msg"
      cmd //C "mklink $WinPWD\\.git\\hooks\\prepare-commit-msg $WinPWD\\resources\\git-hooks\\prepare-commit-msg"
    else
      ln -sf "$SCRIPT_DIR/resources/git-hooks/commit-msg" "$ROOT/.git/hooks/commit-msg"
      ln -sf "$SCRIPT_DIR/resources/git-hooks/prepare-commit-msg" "$ROOT/.git/hooks/prepare-commit-msg"<commit_msg>feat(common): Support git worktree when configuring local hooks<commit_after>#!/bin/bash

#
# Setup git hooks in this or all repositories.
#
# Run this script once to configure your system to work with our Git workflow.
#

if [[ -n "$WINDIR" ]]; then
  # https://stackoverflow.com/a/39160850/1836776
  SCRIPT_DIR=$(cmd //C cd)
else
  SCRIPT_DIR="$(dirname "$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")")"
fi

case $1 in
  --global)
    # Requires Git 2.9 or later.
    coreHooksPath=`git config --global core.hooksPath`
    if [[ -z "$coreHooksPath" ]]; then coreHooksPath="(not set)"; fi
    echo "Current Git core.hooksPath is: $coreHooksPath"

    git config --global core.hooksPath $SCRIPT_DIR/resources/git-hooks
    echo "Git is now configured to use $SCRIPT_DIR/resources/git-hooks for all repositories"

    ;;
  --local)
    if [[ -n "$WINDIR" ]]; then
      # https://stackoverflow.com/a/39160850/1836776
      WinPWD=$(cmd //C cd)
      cmd //C "mklink $WinPWD\\.git\\hooks\\commit-msg $WinPWD\\resources\\git-hooks\\commit-msg"
      cmd //C "mklink $WinPWD\\.git\\hooks\\prepare-commit-msg $WinPWD\\resources\\git-hooks\\prepare-commit-msg"
    else
      HOOKSDIR=$(git rev-parse --git-path hooks)
      ln -sf "$SCRIPT_DIR/resources/git-hooks/commit-msg" "$HOOKSDIR/commit-msg"
      ln -sf "$SCRIPT_DIR/resources/git-hooks/prepare-commit-msg" "$HOOKSDIR/prepare-commit-msg"
{'fraction_non_alphanumeric': 0.16494478090488066, 'fraction_numerical': 0.02565016031350196, 'mean_word_length': 3.2225563909774437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6390853', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1003, 'n_words': 235}