-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.bash
More file actions
executable file
·53 lines (46 loc) · 2.03 KB
/
setup.bash
File metadata and controls
executable file
·53 lines (46 loc) · 2.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
49
50
51
52
53
#!/bin/sh
# Licensed under GPLv2. See LICENSE file. Copyright Carologistics.
if [ -z "${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}" ]; then
echo "CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR is not set. Abort"
exit 1
fi
# Function to copy file with check
copy_file() {
source_file="$1"
destination_file="$2"
force="$3"
if [ ! -e "$destination_file" ] || [ "$force" = "true" ]; then
cp $source_file $destination_file
echo "Copied $source_file to $destination_file"
else
echo "Warning: $destination_file already exists, skipping $source_file"
fi
}
# Parse command line arguments
force_copy=false
while getopts "f" opt; do
case $opt in
f) force_copy=true ;;
*) echo "Invalid option: -$OPTARG" >&2; exit 1 ;;
esac
done
# Shift to the next argument after parsing options
shift $((OPTIND - 1))
if [ -d .git ]; then
copy_file "${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}/.cmake-format" "./.cmake-format" "$force_copy"
copy_file "${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}/.cmakelint.py" "./.cmakelint.py" "$force_copy"
copy_file "${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}/.gitlint" "./.gitlint" "$force_copy"
copy_file "${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}/.gitignore" "./.gitignore" "$force_copy"
copy_file "${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}/.config.yaml" "./.config.yaml" "$force_copy"
copy_file "${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}/.pre-commit-config.yaml" "./.pre-commit-config.yaml" "$force_copy"
copy_file "${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}/.LICENSE" "./.LICENSE" "$force_copy"
copy_file "${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}/LICENSE" "./LICENSE" "$force_copy"
if [ "$force" = "true" ]; then
cp ${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}/git-hooks/* ./.git/hooks/ # -n flag prevents overwriting existing files
else
cp -n ${CAROLOGISTICS_PRE_COMMIT_SETTINGS_DIR}/git-hooks/* ./.git/hooks/ # -n flag prevents overwriting existing files
fi
else
echo "Current directory is not the root directory of a Git repository. Abort."
fi
exit 0