fix: replace corrupted bytes and respect remote default branch

Replace broken control characters and U+FFFD replacement characters in
log function labels with ASCII equivalents ([ok], [!], [x]).

Drop the hardcoded "main" default for git_ref so arty deps no longer
fails with "pathspec 'main' did not match" on repos whose default branch
is not named main — git clone already checks out the remote default branch.
A ref: value in arty.yml is still honoured when explicitly set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 22:15:18 +02:00
parent 64d955094c
commit 8b4fa0dcb1
+25 -20
View File
@@ -47,15 +47,15 @@ log_info() {
} }
log_success() { log_success() {
echo -e "${GREEN}[]${NC} $1" >&2 echo -e "${GREEN}[ok]${NC} $1" >&2
} }
log_warn() { log_warn() {
echo -e "${YELLOW}[]${NC} $1" >&2 echo -e "${YELLOW}[!]${NC} $1" >&2
} }
log_error() { log_error() {
echo -e "${RED}[]${NC} $1" >&2 echo -e "${RED}[x]${NC} $1" >&2
} }
log_debug() { log_debug() {
@@ -65,7 +65,7 @@ log_debug() {
} }
log_step() { log_step() {
echo -e "${CYAN}[]${NC} $1" >&2 echo -e "${CYAN}[!]${NC} $1" >&2
} }
# ============================================================================ # ============================================================================
@@ -403,7 +403,7 @@ is_installed() {
install_lib() { install_lib() {
local repo_url="$1" local repo_url="$1"
local lib_name="${2:-$(get_lib_name "$repo_url")}" local lib_name="${2:-$(get_lib_name "$repo_url")}"
local git_ref="${3:-main}" local git_ref="${3:-}"
local custom_into="${4:-}" local custom_into="${4:-}"
local config_file="${5:-$ARTY_CONFIG_FILE}" local config_file="${5:-$ARTY_CONFIG_FILE}"
@@ -453,9 +453,15 @@ install_lib() {
fi fi
# Try to update # Try to update
(cd "$lib_dir" && git fetch -q && git checkout -q "$git_ref" && git pull -q) || { if [[ -n "$git_ref" ]]; then
log_warn "Failed to update library (continuing with existing version)" (cd "$lib_dir" && git fetch -q && git checkout -q "$git_ref" && git pull -q) || {
} log_warn "Failed to update library (continuing with existing version)"
}
else
(cd "$lib_dir" && git fetch -q && git pull -q) || {
log_warn "Failed to update library (continuing with existing version)"
}
fi
return 0 return 0
fi fi
@@ -469,11 +475,11 @@ install_lib() {
log_info "Installing library: $lib_name" log_info "Installing library: $lib_name"
log_info "Repository: $repo_url" log_info "Repository: $repo_url"
log_info "Git ref: $git_ref" log_info "Git ref: ${git_ref:-<default>}"
log_info "Location: $lib_dir" log_info "Location: $lib_dir"
if [[ "$ARTY_DRY_RUN" == "1" ]]; then if [[ "$ARTY_DRY_RUN" == "1" ]]; then
log_info "[DRY RUN] Would clone repository and checkout $git_ref" log_info "[DRY RUN] Would clone repository${git_ref:+ and checkout $git_ref}"
unmark_installing "$lib_id_with_path" unmark_installing "$lib_id_with_path"
return 0 return 0
fi fi
@@ -485,10 +491,12 @@ install_lib() {
return 1 return 1
} }
# Checkout the specified ref # Checkout the specified ref (skip if none given; clone already checked out the default branch)
(cd "$lib_dir" && git checkout -q "$git_ref") || { if [[ -n "$git_ref" ]]; then
log_warn "Failed to checkout ref '$git_ref', using default branch" (cd "$lib_dir" && git checkout -q "$git_ref") || {
} log_warn "Failed to checkout ref '$git_ref', using default branch"
}
fi
# Run setup hook if exists # Run setup hook if exists
if [[ -f "$lib_dir/setup.sh" ]]; then if [[ -f "$lib_dir/setup.sh" ]]; then
@@ -626,9 +634,6 @@ install_references() {
continue continue
fi fi
# Use default ref if not specified
[[ -z "$git_ref" ]] && git_ref="main"
# Get library name # Get library name
local lib_name=$(get_lib_name "$url") local lib_name=$(get_lib_name "$url")
@@ -775,12 +780,12 @@ build_reference_tree() {
# Add dirty indicator # Add dirty indicator
if [[ "$is_dirty" == "1" ]]; then if [[ "$is_dirty" == "1" ]]; then
printf " ${YELLOW}${NC}" printf " ${YELLOW}*${NC}"
fi fi
# Add location info # Add location info
if [[ -n "$into" ]]; then if [[ -n "$into" ]]; then
printf " ${MAGENTA} %s${NC}" "$into" printf " ${MAGENTA}-> %s${NC}" "$into"
fi fi
echo echo
@@ -1748,7 +1753,7 @@ PROJECT DISCOVERY:
 tools/  tools/
 deep/  deep/
 nested/  nested/
 arty.yml  Too deep (>2 levels) arty.yml Too deep (>2 levels)
ERROR HANDLING: ERROR HANDLING:
- Individual project failures don't stop the batch - Individual project failures don't stop the batch