H0mire
2024-05-04 16:31:28 +02:00
parent e505ec6c07
commit 3b4c53ed22
+17 -13
View File
@@ -35,7 +35,7 @@ if ! git fetch; then
fi fi
# Check if there are any changes # Check if there are any changes
if [[ $(git rev-list HEAD...origin/$current_branch --count) -eq 0 ]]; then if [[ $(git rev-list HEAD...origin/$current_branch --count) -eq 0 && 1 != 1 ]]; then
echo "Repository is already up-to-date. Do not run git pull before this script. Exiting." echo "Repository is already up-to-date. Do not run git pull before this script. Exiting."
exit 0 exit 0
fi fi
@@ -134,7 +134,7 @@ else
fi fi
# Then update the repository # Then update the repository
if git pull; then if ! git pull; then
echo "Git pull successful." echo "Git pull successful."
else else
# If the pull failed, clone the repository to a temporary folder and copy the files from there # If the pull failed, clone the repository to a temporary folder and copy the files from there
@@ -149,14 +149,18 @@ else
mkdir -p ./cache mkdir -p ./cache
temp_folder=$(mktemp -d -p ./cache) temp_folder=$(mktemp -d -p ./cache)
git clone https://github.com/end-4/dots-hyprland/ "$temp_folder" git clone https://github.com/end-4/dots-hyprland/ --depth=1 "$temp_folder"
# Replace the existing dotfiles with the new ones # Replace the existing dotfiles with the new ones
for folder in "${folders[@]}"; do for folder in "${folders[@]}"; do
# Find all files (including those in subdirectories) and copy them # Find all files (including those in subdirectories) and copy them
find "$temp_folder/$folder" -type f -print0 | while IFS= read -r -d '' file; do find "$temp_folder/$folder" -type f -print0 | while IFS= read -r -d '' file; do
if [[ -f "$file" ]] && ! file_in_excludes "$file"; then file="${file/$temp_folder<\//}"
if [[ -f "$temp_folder/$file" && ! $(file_in_excludes "$file") && ! " ${modified_files[@]} " =~ " ${file} " ]]; then
# Construct the destination path # Construct the destination path
# Remove the temporary folder path
destination="$HOME/$file" destination="$HOME/$file"
echo "$destination"
# Create the destination folder if it doesn't exist # Create the destination folder if it doesn't exist
mkdir -p "$(dirname "$destination")" mkdir -p "$(dirname "$destination")"
# Copy the file # Copy the file
@@ -166,6 +170,7 @@ else
done done
echo "New dotfiles have been copied. Cleaning up temporary folder." echo "New dotfiles have been copied. Cleaning up temporary folder."
rm -rf "$temp_folder" rm -rf "$temp_folder"
exit 0
fi fi
@@ -178,15 +183,14 @@ for folder in "${folders[@]}"; do
mkdir -p "$HOME/$file" mkdir -p "$HOME/$file"
fi fi
# Check if the file is a regular file and not in the exclude_folders # Check if the file is a regular file and not in the exclude_folders
if [[ -f "$file" ]] && ! file_in_excludes "$file"; then if [[ -f "$file" && ! $(file_in_excludes "$file") && ! " ${modified_files[@]} " =~ " ${file} " ]]; then
if [[ ! " ${modified_files[@]} " =~ " ${file} " ]]; then # Construct the destination path
# Construct the destination path destination="$HOME/$file"
destination="$HOME/$file" echo "$destination"
# Copy the file # Copy the file
# Create the destination folder if it doesn't exist # Create the destination folder if it doesn't exist
mkdir -p "$(dirname "$destination")" mkdir -p "$(dirname "$destination")"
cp -f "$base/$file" "$destination" cp -f "$base/$file" "$destination"
fi
fi fi
done done
done done