-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-nas-delete
executable file
·42 lines (35 loc) · 973 Bytes
/
git-nas-delete
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# Load parameters
. git-nas-param
# This script assumes that you are in the git project folder that you want to delete
# Test if a git repo exists (with the repo-name file)
TEST_GIT=$(ls ./.git | grep repo-name)
if [[ $TEST_GIT = "repo-name" ]] || [[ $# = 1 ]]
then
if [[ $# = 0 ]]
then
echo "All local and distant files will be deleted (except local source files)"
else
echo "All distant files will be deleted"
fi
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
# do dangerous stuff
# Get repo name
if [[ $# = 0 ]]
then
REPO_NAME=$(cat .git/repo-name)
# Delete local files
rm -rf .git
else
REPO_NAME=$1
fi
# Delete remote files
ssh -p $PORT $USER@$ADDRESS rm -rf $REPOS_PATH$REPO_NAME
fi
else
echo "ERROR: The .git/repo-name file does not exist or you did not specified the repo name"
echo "git-nas-delete <repo name> if not in a local repository"
fi