diff --git a/sync-project.sh b/sync-project.sh index c7cf7e6..b56d7f7 100755 --- a/sync-project.sh +++ b/sync-project.sh @@ -19,6 +19,7 @@ GREEN='\033[0;32m' RED='\033[0;31m' BLUE='\033[0;34m' +YELLOW='\033[0;33m' NC='\033[0m' # No Color # Get current script real directory (follow symlinks) @@ -26,6 +27,18 @@ SCRIPT_PATH="$(realpath "$0")" SCRIPT_DIR="$(dirname "$SCRIPT_PATH")" ARCHIVE_NAME="leo.tar.gz" +# Function to add entry to .gitignore if not already present +add_to_gitignore() { + local entry="$1" + cat .gitignore | grep "$entry" > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "$entry" >> .gitignore + echo -e "${BLUE}Added $entry to .gitignore${NC}" + else + echo -e "${YELLOW}$entry already is inside of .gitignore file${NC}" + fi +} + echo -e "${BLUE}=== Project Sync Configuration ===${NC}" echo "" @@ -162,8 +175,7 @@ for script in "${scripts[@]}"; do echo "${script} created successfully" # Add script to .gitignore - echo "${script}" >> .gitignore - echo -e "${BLUE}Added ${script} to .gitignore${NC}" + add_to_gitignore "${script}" done # Upload lazygit to server @@ -174,5 +186,4 @@ sshpass -p "${SSH_PASSWORD}" scp "${SCRIPT_DIR}/lazygit" ${SERVER_HOST}:${SERVER echo -e "${GREEN}lazygit uploaded successfully${NC}" # Add lazygit to .gitignore -echo "lazygit" >> .gitignore -echo -e "${BLUE}Added lazygit to .gitignore${NC}" +add_to_gitignore "lazygit"