Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ДЗ для Git репозитория #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,34 @@
присылайте пулл реквесты с решением для SVN или с более элегантным подходом.

См. также: [пост про домашние задания](http://clubs.ya.ru/4611686018427468886/replies.xml?item_no=450).

#!/usr/bin/env bash

usage() {
cat << EOF
Использование: script.sh pathToGitRep pathToTrashDir
Скрипт находит все файлы, не входящие в git репозиторий и переносит их в выбранную папку с сохранением структуры каталогов

EOF
}

if [[ "$1" = "" || "$2" = "" ]]
then
usage
exit 1
fi

repopath=$(readlink -e "$1")/ #Вычисляем абсолютный путь до папки с репом
trashpath=$(readlink -e "$2")/ #Вычисляем абсолютный путь до папки с трешэм

cd "$repopath"
untrackedList=$(git ls-files -o --exclude-standard)

cd "$trashpath"
IFS=$'\n'
for line in $untrackedList; do
mkdir -p $(dirname "$line") && mv "$repopath$line" "$trashpath$(dirname $line)"/
done

echo "Успешно"