Skip to content

Instantly share code, notes, and snippets.

@osipxd
Created June 11, 2020 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osipxd/5bc64f84d031f6da7e3b47dda0629e07 to your computer and use it in GitHub Desktop.
Save osipxd/5bc64f84d031f6da7e3b47dda0629e07 to your computer and use it in GitHub Desktop.
Simple scrimp to track/untrack .idea folder
#!/usr/bin/env bash
#
# Скрипт для работы со стандартным конфигом в папке .idea
#
# Использование:
# ./idea_configs <команда>
#
# Возможные команды:
# u, untrack - Git не будет учитывать изменения в папке .idea
# t, track - Git будет учитывать изменения в папке .idea
# r, reset - Убирает локальные изменения из конфигов в .idea
#
set -euo pipefail
RED="\033[31m"
BGREEN="\033[1;32m" # Bold Green
RESET="\033[32m"
command=${1:?Не указана команда. Доступные команды: untrack, track, reset}
function apply_git_command_to_all() {
git ls-files .idea/ | while read -r file; do apply_git_command "$@" "$file"; done
# shellcheck disable=SC2059
printf -- "${BGREEN}Done.$RESET\n"
}
function apply_git_command() {
local file=${*: -1}
printf -- "File %s\n" "$file"
git "$@"
}
case $command in
u | untrack) apply_git_command_to_all update-index --assume-unchanged ;;
t | track) apply_git_command_to_all update-index --no-assume-unchanged ;;
r | reset) apply_git_command_to_all checkout origin/develop -f ;;
*) printf -- "${RED}Неизвестная команда %s. Доступные команды: untrack, track, reset$RESET\n" "$command" ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment