@@ -15,44 +15,63 @@ if [ -f "$REPO_ROOT/ci/env.sh" ]; then
1515 . " $REPO_ROOT /ci/env.sh"
1616fi
1717
18- # Temporary workspace vars
18+ # Temporary workspace vars (default)
1919TEMP_ROOT=" $REPO_ROOT /build_temp"
2020TEMP_VSCODIUM=" $TEMP_ROOT /vscodium"
2121TEMP_VSCODE=" $TEMP_VSCODIUM /vscode"
2222
23- echo " 🔧 Codesphere Brand Patch Generator "
24- echo " ==================================== "
25- echo " Working directory: $TEMP_ROOT "
23+ # Default to using temp dir
24+ USE_TEMP_DIR=true
25+ TARGET_VSCODE= " $TEMP_VSCODE "
2626
27- # Cleanup any previous run
28- rm -rf " $TEMP_ROOT "
29- mkdir -p " $TEMP_VSCODIUM "
30-
31- # 1. Copy VSCodium scripts to temp dir (so we can fix CRLF safely)
32- echo " 📦 Copying VSCodium scripts to temp workspace..."
33- cp -r " $VSCODIUM_SUBMODULE /" * " $TEMP_VSCODIUM /"
34-
35- # 2. Fix CRLF line endings in the temp scripts (crucial for Windows/WSL)
36- echo " 🔧 Fixing CRLF line endings in temp scripts..."
37- find " $TEMP_VSCODIUM " -name " *.sh" -type f -exec sed -i ' s/\r$//' {} +
27+ # Check arguments
28+ if [[ " $1 " == " --in-place" ]] || [[ " $CI_BUILD " == " yes" ]]; then
29+ echo " ⚙️ CI/In-Place mode detected."
30+ USE_TEMP_DIR=false
31+ TARGET_VSCODE=" $REPO_ROOT /vendor/vscodium/vscode"
32+ fi
3833
39- # 3. Fetch VS Code source using the temp scripts
40- echo " 📥 Fetching VS Code source (this may take time)..."
41- cd " $TEMP_VSCODIUM " || exit 1
42- # Force bash usage to ensuring expected behavior
43- bash ./get_repo.sh
34+ if [ " $USE_TEMP_DIR " = true ]; then
35+ echo " Working directory: $TEMP_ROOT "
4436
45- # 4. Verify fetch success
46- if [ ! -d " $TEMP_VSCODE /.git" ]; then
47- echo " ❌ Error: Failed to fetch vscode source in temp dir"
48- exit 1
37+ # Cleanup any previous run
38+ rm -rf " $TEMP_ROOT "
39+ mkdir -p " $TEMP_VSCODIUM "
40+
41+ # 1. Copy VSCodium scripts to temp dir (so we can fix CRLF safely)
42+ echo " 📦 Copying VSCodium scripts to temp workspace..."
43+ cp -r " $VSCODIUM_SUBMODULE /" * " $TEMP_VSCODIUM /"
44+
45+ # 2. Fix CRLF line endings in the temp scripts (crucial for Windows/WSL)
46+ echo " 🔧 Fixing CRLF line endings in temp scripts..."
47+ find " $TEMP_VSCODIUM " -name " *.sh" -type f -exec sed -i ' s/\r$//' {} +
48+
49+ # 3. Fetch VS Code source using the temp scripts
50+ echo " 📥 Fetching VS Code source (this may take time)..."
51+ cd " $TEMP_VSCODIUM " || exit 1
52+ # Force bash usage to ensuring expected behavior
53+ bash ./get_repo.sh
54+
55+ # 4. Verify fetch success
56+ if [ ! -d " $TEMP_VSCODE /.git" ]; then
57+ echo " ❌ Error: Failed to fetch vscode source in temp dir"
58+ exit 1
59+ fi
60+
61+ echo " ✅ Clean vscode checkout ready in temp dir"
62+ else
63+ echo " 📂 Using existing source at: $TARGET_VSCODE "
64+ if [ ! -d " $TARGET_VSCODE /.git" ]; then
65+ echo " ❌ Error: $TARGET_VSCODE is not a git repository"
66+ echo " Please ensure get_repo.sh has been run."
67+ exit 1
68+ fi
4969fi
5070
51- echo " ✅ Clean vscode checkout ready in temp dir"
5271echo " "
5372echo " 🎨 Applying Codesphere branding changes..."
5473
55- cd " $TEMP_VSCODE " || exit 1
74+ cd " $TARGET_VSCODE " || exit 1
5675
5776# Apply branding replacements (Regex logic from original enforce-branding.sh)
5877
@@ -107,9 +126,15 @@ if [ -s "$PATCH_OUTPUT" ]; then
107126 echo " Lines: $PATCH_LINES "
108127
109128 # Cleanup
110- echo " 🧹 Cleaning up temp workspace..."
111- cd " $REPO_ROOT "
112- rm -rf " $TEMP_ROOT "
129+ if [ " $USE_TEMP_DIR " = true ]; then
130+ echo " 🧹 Cleaning up temp workspace..."
131+ cd " $REPO_ROOT "
132+ rm -rf " $TEMP_ROOT "
133+ else
134+ echo " 🧹 Resetting source directory..."
135+ git reset --hard HEAD
136+ git clean -fd
137+ fi
113138 echo " ✨ Done."
114139else
115140 echo " ❌ No changes detected - patch file is empty"
0 commit comments