Skip to content

Commit 2e69b0d

Browse files
Fix installer to work with main branch (L&L compatibility)
- Fetch dev from feature remote as diff base (available even when user clones main) - Make Localizable.xcstrings checkout conditional (main uses .strings, dev uses .xcstrings) - L&L patches target main, so Option B must use main not dev Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2b26878 commit 2e69b0d

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

Scripts/install_features.sh

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ setup_source_remote() {
304304
git fetch "$FEATURE_REMOTE" "$FEATURE_LOOP_BRANCH" --depth=1
305305
success "Fetched ${FEATURE_LOOP_BRANCH} from ${FEATURE_REPO}"
306306

307+
# Also fetch dev — our feature branch was based on dev, so we need it as the diff base
308+
# even when the user cloned main (which is the L&L-compatible path)
309+
git fetch "$FEATURE_REMOTE" dev --depth=1
310+
success "Fetched dev ref for diff base"
311+
307312
popd > /dev/null
308313
}
309314

@@ -328,12 +333,18 @@ install_new_files() {
328333

329334
# Localizable.xcstrings: direct checkout instead of 3-way merge
330335
# (71K-line JSON file — too large for reliable diff/apply)
331-
if git checkout "${FEATURE_REMOTE}/${FEATURE_LOOP_BRANCH}" -- "Loop/Localizable.xcstrings" 2>/dev/null; then
332-
((installed++))
333-
success "Replaced Localizable.xcstrings (direct checkout)"
336+
# Only replace if the user already has it (dev branch uses xcstrings;
337+
# main branch uses old-style .strings files and doesn't have xcstrings)
338+
if [[ -f "Loop/Localizable.xcstrings" ]]; then
339+
if git checkout "${FEATURE_REMOTE}/${FEATURE_LOOP_BRANCH}" -- "Loop/Localizable.xcstrings" 2>/dev/null; then
340+
((installed++))
341+
success "Replaced Localizable.xcstrings (direct checkout)"
342+
else
343+
warn "Failed to checkout Localizable.xcstrings"
344+
((failed++))
345+
fi
334346
else
335-
warn "Failed to checkout Localizable.xcstrings"
336-
((failed++))
347+
info "Skipping Localizable.xcstrings (not present on this branch — features use NSLocalizedString fallback)"
337348
fi
338349

339350
popd > /dev/null
@@ -351,13 +362,18 @@ patch_modified_files() {
351362

352363
pushd Loop > /dev/null
353364

354-
# We need to find the merge base. The dev branch tracks upstream Loop.
355-
# We generate a diff from the dev branch tip to our feature branch for each file,
356-
# then apply it with --3way so git can handle any L&L modifications.
365+
# We need the dev branch as the diff base. feat/AllFeatures was branched from dev,
366+
# so `git diff dev..feat/AllFeatures` isolates ONLY our feature changes.
367+
# We fetched dev from our remote in Phase 3, so it's always available —
368+
# even when the user cloned main (the L&L-compatible path).
357369
local dev_ref
358-
dev_ref=$(git rev-parse dev 2>/dev/null || git rev-parse origin/dev 2>/dev/null || git rev-parse upstream/dev 2>/dev/null)
370+
dev_ref=$(git rev-parse "${FEATURE_REMOTE}/dev" 2>/dev/null)
371+
if [[ -z "$dev_ref" ]]; then
372+
# Fallback to local dev branches
373+
dev_ref=$(git rev-parse dev 2>/dev/null || git rev-parse origin/dev 2>/dev/null || git rev-parse upstream/dev 2>/dev/null)
374+
fi
359375
if [[ -z "$dev_ref" ]]; then
360-
die "Cannot find dev branch reference. Make sure 'dev' branch exists."
376+
die "Cannot find dev branch reference. The feature remote fetch may have failed."
361377
fi
362378

363379
local patched=0

0 commit comments

Comments
 (0)