Skip to content

Commit 4dd2b22

Browse files
committed
Checkout latest vscode tag by default instead of main
- when tag is not provided, is it possible to set the cloned repo at last tag ending with *-vscode?
1 parent 4f0227a commit 4dd2b22

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

‎install.ps1‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,20 @@ foreach ($i in $indices) {
490490
$updated = $false
491491
if (Test-Path (Join-Path $repoDir ".git")) {
492492
$updated = Invoke-Step "$msg_step_cloning..." {
493-
git -C $repoDir fetch origin --quiet *>$null
493+
git -C $repoDir fetch origin --tags --quiet *>$null
494494
if ($LASTEXITCODE -ne 0) { throw "Failed to fetch" }
495495
if ($tagName) {
496496
git -C $repoDir checkout $tagName --quiet *>$null
497497
if ($LASTEXITCODE -ne 0) { throw "Failed to checkout" }
498498
} else {
499-
git -C $repoDir reset --hard origin/main --quiet *>$null
500-
if ($LASTEXITCODE -ne 0) { throw "Failed to reset" }
499+
$latestTag = git -C $repoDir tag -l '*-vscode' --sort=-creatordate | Select-Object -First 1
500+
if ($latestTag) {
501+
git -C $repoDir checkout $latestTag --quiet *>$null
502+
if ($LASTEXITCODE -ne 0) { throw "Failed to checkout latest tag" }
503+
} else {
504+
git -C $repoDir reset --hard origin/main --quiet *>$null
505+
if ($LASTEXITCODE -ne 0) { throw "Failed to reset" }
506+
}
501507
}
502508
git -C $repoDir clean -fd --quiet *>$null
503509
if ($LASTEXITCODE -ne 0) { throw "Failed to clean" }
@@ -514,6 +520,12 @@ foreach ($i in $indices) {
514520
if ($tagName) {
515521
git -C $repoDir checkout $tagName --quiet *>$null
516522
if ($LASTEXITCODE -ne 0) { throw "Failed to checkout" }
523+
} else {
524+
$latestTag = git -C $repoDir tag -l '*-vscode' --sort=-creatordate | Select-Object -First 1
525+
if ($latestTag) {
526+
git -C $repoDir checkout $latestTag --quiet *>$null
527+
if ($LASTEXITCODE -ne 0) { throw "Failed to checkout latest tag" }
528+
}
517529
}
518530
} $msg_step_cloning
519531
}
@@ -561,3 +573,4 @@ foreach ($i in $indices) {
561573
}
562574

563575
Pause
576+

‎install.sh‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,16 @@ mkdir -p -m 700 "$CWC_DIR"
498498
chmod 700 "$CWC_DIR" 2>/dev/null || true
499499

500500
update_repo() {
501-
git -C "$REPO_DIR" fetch origin --quiet && \
501+
git -C "$REPO_DIR" fetch origin --tags --quiet && \
502502
if [ -n "$TAG_NAME" ]; then
503503
git -C "$REPO_DIR" checkout "$TAG_NAME" --quiet
504504
else
505-
git -C "$REPO_DIR" reset --hard origin/main --quiet
505+
LATEST_TAG=$(git -C "$REPO_DIR" tag -l '*-vscode' --sort=-creatordate | head -n 1)
506+
if [ -n "$LATEST_TAG" ]; then
507+
git -C "$REPO_DIR" checkout "$LATEST_TAG" --quiet
508+
else
509+
git -C "$REPO_DIR" reset --hard origin/main --quiet
510+
fi
506511
fi && \
507512
git -C "$REPO_DIR" clean -fd --quiet
508513
}
@@ -511,6 +516,11 @@ clone_repo() {
511516
git clone -c core.longpaths=true --quiet https://github.com/CodeWebChat/CWC.git "$REPO_DIR" && \
512517
if [ -n "$TAG_NAME" ]; then
513518
git -C "$REPO_DIR" checkout "$TAG_NAME" --quiet
519+
else
520+
LATEST_TAG=$(git -C "$REPO_DIR" tag -l '*-vscode' --sort=-creatordate | head -n 1)
521+
if [ -n "$LATEST_TAG" ]; then
522+
git -C "$REPO_DIR" checkout "$LATEST_TAG" --quiet
523+
fi
514524
fi
515525
}
516526

@@ -572,3 +582,4 @@ for i in "${indices[@]}"; do
572582
done
573583

574584
cd "$ORIGINAL_DIR" || cd /
585+

0 commit comments

Comments
 (0)