<commit_before>#! /usr/bin/env bash
# git setup

set -euo pipefail

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
dotfiles_dir="$(dirname "$dir")"
dotfiles_old="${dotfiles_dir}_old"

gitconfig="$dotfiles_dir/links/gitconfig"

source "$dotfiles_dir/dotfiles-support"

# config function
# Args: 1:section 2:key
# Usage: config user name
# -- Prompts for user name and then does git config --global user.name $input
config() {
  read -p "Enter git $1 $2 > " u_in
  git config --global "$1.$2" "$u_in"
  echo "git $1 $2 = $u_in"
}

# Usage: config_user_info
# -- Configures user information for someone other than <NAME>
config_user_info() {
  local name
  name="$(git config --global --get user.name)"
  local email
  email="$(git config --global --get user.email)"

  if [[ -z "$name" ]]; then
    display_message "No previous user name"
    config user name
  else
    display_message "Previous user name: $name"
    read -n 1 -p "Is [name = $name] ok [Y/n] ? " nameok && echo
    if ! input_matches_yY "$nameok"; then
      config user name
    fi
  fi

  if [[ -z "$email" ]]; then
    display_message "No previous user email"
    config user email
  else
    display_message "Previous user email: $email"
    read -n 1 -p "Is [email = $email] ok [Y/n] ? " emailok && echo
    if ! input_matches_yY "$emailok"; then
      config user email
    fi
  fi
}

backup_gitconfig() {
  if [[ -e ~/.gitconfig ]]; then
    display_message "Backing up gitconfig..."
    mv -f ~/.gitconfig "$dotfiles_old/gitconfig"
    display_message "...done backing up gitconfig"
  fi
}

symlink_gitconfig() {
  display_message "Symlinking gitconfig..."
  ln -s "$gitconfig" ~/.gitconfig
  display_message "...done with gitconfig"
}

copy_gitconfig() {
  display_message "Copying gitconfig..."
  cp "$gitconfig" ~/.gitconfig
  display_message "...done with gitconfig"
}

reconfigure_name_email() {
  display_message "Configure user name and email..."
  config_user_info
  display_message "...done with user info"
}
<commit_msg>Fix issue with linking gitconfig<commit_after>#! /usr/bin/env bash
# git setup

set -euo pipefail

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
dotfiles_dir="$(dirname "$dir")"
dotfiles_old="${dotfiles_dir}_old"

gitconfig="$dotfiles_dir/links/gitconfig"

source "$dotfiles_dir/dotfiles-support"

# config function
# Args: 1:section 2:key
# Usage: config user name
# -- Prompts for user name and then does git config --global user.name $input
config() {
  read -p "Enter git $1 $2 > " u_in
  git config --global "$1.$2" "$u_in"
  echo "git $1 $2 = $u_in"
}

# Usage: config_user_info
# -- Configures user information for someone other than <NAME>
config_user_info() {
  local name
  name="$(git config --global --get user.name)"
  local email
  email="$(git config --global --get user.email)"

  if [[ -z "$name" ]]; then
    display_message "No previous user name"
    config user name
  else
    display_message "Previous user name: $name"
    read -n 1 -p "Is [name = $name] ok [Y/n] ? " nameok && echo
    if ! input_matches_yY "$nameok"; then
      config user name
    fi
  fi

  if [[ -z "$email" ]]; then
    display_message "No previous user email"
    config user email
  else
    display_message "Previous user email: $email"
    read -n 1 -p "Is [email = $email] ok [Y/n] ? " emailok && echo
    if ! input_matches_yY "$emailok"; then
      config user email
    fi
  fi
}

backup_gitconfig() {
  if [[ -e ~/.gitconfig ]]; then
    display_message "Backing up gitconfig..."
    mv -f ~/.gitconfig "$dotfiles_old/gitconfig"
    display_message "...done backing up gitconfig"
  fi
}

symlink_gitconfig() {
  display_message "Symlinking gitconfig..."
  ln -Fivs "$gitconfig" ~/.gitconfig
  display_message "...done with gitconfig"
}

copy_gitconfig() {
  display_message "Copying gitconfig..."
  cp "$gitconfig" ~/.gitconfig
  display_message "...done with gitconfig"
}

reconfigure_name_email() {
  display_message "Configure user name and email..."
  config_user_info
  display_message "...done with user info"
}

{'fraction_non_alphanumeric': 0.13982213438735178, 'fraction_numerical': 0.005434782608695652, 'mean_word_length': 3.3490870032223414, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '2179967', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1343, 'n_words': 432}