Skip to content

Commit 902ac38

Browse files
committed
fix(install): improve package mirror URL replacement
- Add word boundaries to regex patterns for more precise URL replacement - Apply mirror replacement consistently in both install and upgrade scripts - Reference GitHub issue explaining the mirror replacement context - Standardize on single quotes for string literals
1 parent 10e3d89 commit 902ac38

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

template/.config/copier/mise/tasks/install.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ set -o pipefail
88
function replace-mirrors() {
99
local file="$1"
1010
if [[ -f $file ]]; then
11-
sd 'https://(\S+)/simple' 'https://pypi.org/simple' "$file"
12-
sd 'https://(\S+)/packages' 'https://files.pythonhosted.org/packages' "$file"
11+
# ref: <https://github.com/astral-sh/uv/issues/6349#issuecomment-3076752818>
12+
sd 'https://(\S+)/packages\b' 'https://files.pythonhosted.org/packages' "$file"
13+
sd 'https://(\S+)/simple\b' 'https://pypi.org/simple' "$file"
1314
fi
1415
}
1516

16-
if [[ -f "pixi.lock" ]]; then
17+
if [[ -f 'pixi.lock' ]]; then
1718
pixi install
1819
replace-mirrors 'pixi.lock'
1920
fi
2021

21-
if [[ -f "uv.lock" ]]; then
22+
if [[ -f 'uv.lock' ]]; then
2223
uv sync --all-extras --all-groups
2324
replace-mirrors 'uv.lock'
2425
fi

template/.config/copier/mise/tasks/upgrade.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@ set -o errexit
66
set -o nounset
77
set -o pipefail
88

9-
if [[ -f "pixi.lock" ]]; then
9+
function replace-mirrors() {
10+
local file="$1"
11+
if [[ -f $file ]]; then
12+
# ref: <https://github.com/astral-sh/uv/issues/6349#issuecomment-3076752818>
13+
sd 'https://(\S+)/packages\b' 'https://files.pythonhosted.org/packages' "$file"
14+
sd 'https://(\S+)/simple\b' 'https://pypi.org/simple' "$file"
15+
fi
16+
}
17+
18+
if [[ -f 'pixi.lock' ]]; then
1019
pixi upgrade
20+
replace-mirrors 'pixi.lock'
1121
fi
1222

13-
if [[ -f "uv.lock" ]]; then
23+
if [[ -f 'uv.lock' ]]; then
1424
uv sync --upgrade
25+
replace-mirrors 'uv.lock'
1526
fi

0 commit comments

Comments
 (0)