-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsync-client.sh
More file actions
executable file
·42 lines (32 loc) · 1.02 KB
/
sync-client.sh
File metadata and controls
executable file
·42 lines (32 loc) · 1.02 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
#!/usr/bin/env bash
# This script syncs the client repo with the latest master version on server
set -x
set -e # Exit with nonzero when a command fails.
set -u # Exit with nonzero when referencing an unbound variable
SERVER_REPO=$1
CLIENT_REPO=$2
CLIENT_FOLDER=$3
MSG=$4
AUTHOR_NAME=$5
AUTHOR_EMAIL=$6
# resets local copy of server repo to latest master
cd local-repos/${SERVER_REPO}
git fetch
git checkout master
git reset --hard origin/master
# resets local copy of client repo to latest master
cd ../${CLIENT_REPO}
git fetch
git checkout master
git reset --hard origin/master
# Removes everything in the top level except .git folder
find . -mindepth 1 -maxdepth 1 | grep -v .git | xargs rm -rf
# copies over the client folder from server to client
cp -R ../${SERVER_REPO}/${CLIENT_FOLDER}/* .
git add --all
# attribute the commit to the original author on the server repo
git commit -m "${MSG}" --author "${AUTHOR_NAME} <${AUTHOR_EMAIL}>"
git push origin master
# clean up and go back to top level
git reset --hard HEAD
cd ../..