forked from agnoster/git-dropbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-dropbox.sh
More file actions
executable file
·53 lines (43 loc) · 1.31 KB
/
git-dropbox.sh
File metadata and controls
executable file
·53 lines (43 loc) · 1.31 KB
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
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
FOLDER=`git config dropbox.folder`
if [ ! "$FOLDER" -o ! -d "$FOLDER" ]; then
FOLDER=""
# Running for the first time
if [ -d "$HOME/Dropbox" ]; then
DEFAULT="$HOME/Dropbox/git"
fi
echo "# git-dropbox: initial setup"
while [ ! "$FOLDER" ]; do
read -p "Where should git repositories be saved? [$DEFAULT] " -e FOLDER
if [ ! "$FOLDER" ]; then
FOLDER="$DEFAULT"
echo "Choosing default: $FOLDER"
fi
done
mkdir -p $FOLDER
if [ ! "$FOLDER" ]; then
echo "$FOLDER does not exist. Check that you have permissions to create it."
exit 1
fi
git config --global dropbox.folder "$FOLDER"
echo "Set $FOLDER as the location for your dropbox git clones"
fi
PROJECT_DIR=`git rev-parse --show-toplevel 2>/dev/null`
if [ ! "$PROJECT_DIR" ]; then
echo "Run 'git dropbox' in a git repository to mirror it to $FOLDER/[repo-name].git/"
exit
fi
DROPBOX_REPO=`git config --local dropbox.repo 2>/dev/null`
if [ ! "$DROPBOX_REPO" ]; then
PROJECT_NAME=`basename "$PROJECT_DIR"`
DROPBOX_REPO="$FOLDER/$PROJECT_NAME.git"
fi
if [ ! -d "$DROPBOX_REPO" ]; then
mkdir -p $DROPBOX_REPO
(cd $DROPBOX_REPO; git init --bare)
fi
if [ ! -d "$DROPBOX_REPO" ]; then
echo "Could not create $DROPBOX_REPO. Check that you have permissions to create it."
exit 1
fi
git push "$DROPBOX_REPO" --mirror