Created
June 11, 2020 12:07
-
-
Save osipxd/5bc64f84d031f6da7e3b47dda0629e07 to your computer and use it in GitHub Desktop.
Simple scrimp to track/untrack .idea folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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