-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave
More file actions
executable file
·48 lines (35 loc) · 1.03 KB
/
Copy pathsave
File metadata and controls
executable file
·48 lines (35 loc) · 1.03 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
#!/usr/bin/bash
# Idea -> Could be either copying the entire folder into repo or extracting all the data to the folder
declare -A SRC=(
["piscine"]="/mnt/nfs/homes/pjaguin/Desktop/Piscine/Piscine"
)
declare -A DEST=(
["piscine"]="/mnt/nfs/homes/pjaguin/Desktop/Perso/42"
)
usage() {
echo "Copy paste a project from 42 repo to your private repository without the .git"
echo "Usage: $0 [project_name]"
echo "Available projects:"
for project in ${!DEST[@]}; do
echo " - $project"
done
exit 1
}
if [ $# -ne 1 ]; then
usage
fi
project_name=$1
echo $project_name
copy_project() {
local project_path=${SRC[$project_name]}
local repo_path=${DEST[$project_name]}
if [ -z "$project_path" ]; then
echo "Unknown project: $project_name"
exit 1
fi
cd "$project_path" || exit
rsync -av --exclude=".*" "$project_path" "$repo_path" #exclude hidden files
cd "$repo_path" || exit
git add . && git commit -m "`date +'%Y-%m-%d %H:%M:%S'` autosave $project_name " && git push
}
copy_project