Add --skip-notice argument and change the way to check the git repo

This commit is contained in:
Bishoy Ehab
2025-06-08 07:58:04 +03:00
parent d96abe7a4d
commit 506fb857aa
+23 -11
View File
@@ -13,7 +13,7 @@ set -uo pipefail
# === Configuration === # === Configuration ===
FORCE_CHECK=false FORCE_CHECK=false
CHECK_PACKAGES=false CHECK_PACKAGES=false
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" REPO_DIR="$(cd "$(dirname $0)" &>/dev/null && pwd)"
ARCH_PACKAGES_DIR="${REPO_DIR}/arch-packages" ARCH_PACKAGES_DIR="${REPO_DIR}/arch-packages"
UPDATE_IGNORE_FILE="${REPO_DIR}/.updateignore" UPDATE_IGNORE_FILE="${REPO_DIR}/.updateignore"
HOME_UPDATE_IGNORE_FILE="${HOME}/.updateignore" HOME_UPDATE_IGNORE_FILE="${HOME}/.updateignore"
@@ -489,13 +489,7 @@ has_new_commits() {
# Main script starts here # Main script starts here
log_header "Dotfiles Update Script" log_header "Dotfiles Update Script"
log_warning "THIS SCRIPT IS NOT FULLY TESTED AND MAY CAUSE ISSUES!" check=true
safe_read "BY CONTINUE YOU WILL USE IT AT YOUR OWN RISK (y/N): " response "N"
if [[ ! "$response" =~ ^[Yy]$ ]]; then
log_error "Update aborted by user"
exit 1
fi
# Parse command line arguments # Parse command line arguments
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
@@ -530,6 +524,11 @@ while [[ $# -gt 0 ]]; do
echo " - Interactive selection of packages to build" echo " - Interactive selection of packages to build"
exit 0 exit 0
;; ;;
--skip-notice)
log_warning "Skipping notice about script being untested"
check=false
shift
;;
*) *)
log_error "Unknown option: $1" log_error "Unknown option: $1"
echo "Use --help for usage information" echo "Use --help for usage information"
@@ -538,13 +537,26 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Check if we're in a git repository if [[ "$check" == true ]]; then
if [[ ! -d "${REPO_DIR}/.git" ]]; then log_warning "THIS SCRIPT IS NOT FULLY TESTED AND MAY CAUSE ISSUES!"
die "Not in a git repository. Please run this script from your dotfiles repository." safe_read "BY CONTINUE YOU WILL USE IT AT YOUR OWN RISK (y/N): " response "N"
if [[ ! "$response" =~ ^[Yy]$ ]]; then
log_error "Update aborted by user"
exit 1
fi
fi fi
# Check if we're in a git repository
cd "$REPO_DIR" || die "Failed to change to repository directory" cd "$REPO_DIR" || die "Failed to change to repository directory"
if git rev-parse --is-inside-work-tree &>/dev/null; then
log_info "Running in git repository: $(git rev-parse --show-toplevel)"
else
log_error "Not in a git repository. Please run this script from your dotfiles repository."
exit 1
fi
# Step 1: Pull latest commits # Step 1: Pull latest commits
log_header "Pulling Latest Changes" log_header "Pulling Latest Changes"