diff --git a/src/i18n/locales/ca/common.json b/src/i18n/locales/ca/common.json index 6f99ad56bbd7..45a58f22db87 100644 --- a/src/i18n/locales/ca/common.json +++ b/src/i18n/locales/ca/common.json @@ -33,7 +33,7 @@ "checkpoint_timeout": "S'ha esgotat el temps en intentar restaurar el punt de control.", "checkpoint_failed": "Ha fallat la restauració del punt de control.", "git_not_installed": "Git és necessari per a la funció de punts de control. Si us plau, instal·la Git per activar els punts de control.", - "nested_git_repos_warning": "Els punts de control estan deshabilitats perquè s'han detectat repositoris git niats a l'espai de treball. Per utilitzar punts de control, si us plau elimina o reubica els repositoris git niats.", + "nested_git_repos_warning": "Els punts de control estan deshabilitats perquè s'ha detectat un repositori git niat a: {{path}}. Per utilitzar punts de control, si us plau elimina o reubica aquest repositori git niat.", "no_workspace": "Si us plau, obre primer una carpeta de projecte", "update_support_prompt": "Ha fallat l'actualització del missatge de suport", "reset_support_prompt": "Ha fallat el restabliment del missatge de suport", diff --git a/src/i18n/locales/de/common.json b/src/i18n/locales/de/common.json index 2a47afe49448..dc833874df41 100644 --- a/src/i18n/locales/de/common.json +++ b/src/i18n/locales/de/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Zeitüberschreitung beim Versuch, den Checkpoint wiederherzustellen.", "checkpoint_failed": "Fehler beim Wiederherstellen des Checkpoints.", "git_not_installed": "Git ist für die Checkpoint-Funktion erforderlich. Bitte installiere Git, um Checkpoints zu aktivieren.", - "nested_git_repos_warning": "Checkpoints sind deaktiviert, da verschachtelte Git-Repositories im Arbeitsbereich erkannt wurden. Um Checkpoints zu verwenden, entferne oder verschiebe bitte die verschachtelten Git-Repositories.", + "nested_git_repos_warning": "Checkpoints sind deaktiviert, da ein verschachteltes Git-Repository erkannt wurde unter: {{path}}. Um Checkpoints zu verwenden, entferne oder verschiebe bitte dieses verschachtelte Git-Repository.", "no_workspace": "Bitte öffne zuerst einen Projektordner", "update_support_prompt": "Fehler beim Aktualisieren der Support-Nachricht", "reset_support_prompt": "Fehler beim Zurücksetzen der Support-Nachricht", diff --git a/src/i18n/locales/en/common.json b/src/i18n/locales/en/common.json index 18fe93944233..f24dd147e2e6 100644 --- a/src/i18n/locales/en/common.json +++ b/src/i18n/locales/en/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Timed out when attempting to restore checkpoint.", "checkpoint_failed": "Failed to restore checkpoint.", "git_not_installed": "Git is required for the checkpoints feature. Please install Git to enable checkpoints.", - "nested_git_repos_warning": "Checkpoints are disabled because nested git repositories were detected in the workspace. To use checkpoints, please remove or relocate nested git repositories.", + "nested_git_repos_warning": "Checkpoints are disabled because a nested git repository was detected at: {{path}}. To use checkpoints, please remove or relocate this nested git repository.", "no_workspace": "Please open a project folder first", "update_support_prompt": "Failed to update support prompt", "reset_support_prompt": "Failed to reset support prompt", diff --git a/src/i18n/locales/es/common.json b/src/i18n/locales/es/common.json index 87c3ea99adc1..8aeb279048b5 100644 --- a/src/i18n/locales/es/common.json +++ b/src/i18n/locales/es/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Se agotó el tiempo al intentar restaurar el punto de control.", "checkpoint_failed": "Error al restaurar el punto de control.", "git_not_installed": "Git es necesario para la función de puntos de control. Por favor, instala Git para activar los puntos de control.", - "nested_git_repos_warning": "Los puntos de control están deshabilitados porque se detectaron repositorios git anidados en el espacio de trabajo. Para usar puntos de control, por favor elimina o reubica los repositorios git anidados.", + "nested_git_repos_warning": "Los puntos de control están deshabilitados porque se detectó un repositorio git anidado en: {{path}}. Para usar puntos de control, por favor elimina o reubica este repositorio git anidado.", "no_workspace": "Por favor, abre primero una carpeta de proyecto", "update_support_prompt": "Error al actualizar el mensaje de soporte", "reset_support_prompt": "Error al restablecer el mensaje de soporte", diff --git a/src/i18n/locales/fr/common.json b/src/i18n/locales/fr/common.json index 248a6d4f26b0..465abe78b86f 100644 --- a/src/i18n/locales/fr/common.json +++ b/src/i18n/locales/fr/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Expiration du délai lors de la tentative de rétablissement du checkpoint.", "checkpoint_failed": "Échec du rétablissement du checkpoint.", "git_not_installed": "Git est requis pour la fonctionnalité des points de contrôle. Veuillez installer Git pour activer les points de contrôle.", - "nested_git_repos_warning": "Les points de contrôle sont désactivés car des dépôts git imbriqués ont été détectés dans l'espace de travail. Pour utiliser les points de contrôle, veuillez supprimer ou déplacer les dépôts git imbriqués.", + "nested_git_repos_warning": "Les points de contrôle sont désactivés car un dépôt git imbriqué a été détecté à : {{path}}. Pour utiliser les points de contrôle, veuillez supprimer ou déplacer ce dépôt git imbriqué.", "no_workspace": "Veuillez d'abord ouvrir un espace de travail", "update_support_prompt": "Erreur lors de la mise à jour du prompt de support", "reset_support_prompt": "Erreur lors de la réinitialisation du prompt de support", diff --git a/src/i18n/locales/hi/common.json b/src/i18n/locales/hi/common.json index 54be7b4f5f45..d9c9d59d884c 100644 --- a/src/i18n/locales/hi/common.json +++ b/src/i18n/locales/hi/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "चेकपॉइंट को पुनर्स्थापित करने का प्रयास करते समय टाइमआउट हो गया।", "checkpoint_failed": "चेकपॉइंट पुनर्स्थापित करने में विफल।", "git_not_installed": "चेकपॉइंट सुविधा के लिए Git आवश्यक है। कृपया चेकपॉइंट সক্ষম करने के लिए Git इंस्टॉल करें।", - "nested_git_repos_warning": "चेकपॉइंट अक्षम हैं क्योंकि वर्कस्पेस में नेस्टेड git रिपॉजिटरी का पता चला है। चेकपॉइंट का उपयोग करने के लिए, कृपया नेस्टेड git रिपॉजिटरी को हटाएं या स्थानांतरित करें।", + "nested_git_repos_warning": "चेकपॉइंट अक्षम हैं क्योंकि {{path}} पर नेस्टेड git रिपॉजिटरी का पता चला है। चेकपॉइंट का उपयोग करने के लिए, कृपया इस नेस्टेड git रिपॉजिटरी को हटाएं या स्थानांतरित करें।", "no_workspace": "कृपया पहले प्रोजेक्ट फ़ोल्डर खोलें", "update_support_prompt": "सपोर्ट प्रॉम्प्ट अपडेट करने में विफल", "reset_support_prompt": "सपोर्ट प्रॉम्प्ट रीसेट करने में विफल", diff --git a/src/i18n/locales/id/common.json b/src/i18n/locales/id/common.json index d99dfce1ef4a..5918278c64e9 100644 --- a/src/i18n/locales/id/common.json +++ b/src/i18n/locales/id/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Timeout saat mencoba memulihkan checkpoint.", "checkpoint_failed": "Gagal memulihkan checkpoint.", "git_not_installed": "Git diperlukan untuk fitur checkpoint. Silakan instal Git untuk mengaktifkan checkpoint.", - "nested_git_repos_warning": "Checkpoint dinonaktifkan karena repositori git bersarang terdeteksi di workspace. Untuk menggunakan checkpoint, silakan hapus atau pindahkan repositori git bersarang.", + "nested_git_repos_warning": "Checkpoint dinonaktifkan karena repositori git bersarang terdeteksi di: {{path}}. Untuk menggunakan checkpoint, silakan hapus atau pindahkan repositori git bersarang ini.", "no_workspace": "Silakan buka folder proyek terlebih dahulu", "update_support_prompt": "Gagal memperbarui support prompt", "reset_support_prompt": "Gagal mereset support prompt", diff --git a/src/i18n/locales/it/common.json b/src/i18n/locales/it/common.json index 403577236984..738593740a22 100644 --- a/src/i18n/locales/it/common.json +++ b/src/i18n/locales/it/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Timeout durante il tentativo di ripristinare il checkpoint.", "checkpoint_failed": "Impossibile ripristinare il checkpoint.", "git_not_installed": "Git è richiesto per la funzione di checkpoint. Per favore, installa Git per abilitare i checkpoint.", - "nested_git_repos_warning": "I checkpoint sono disabilitati perché sono stati rilevati repository git annidati nell'area di lavoro. Per utilizzare i checkpoint, rimuovi o sposta i repository git annidati.", + "nested_git_repos_warning": "I checkpoint sono disabilitati perché è stato rilevato un repository git annidato in: {{path}}. Per utilizzare i checkpoint, rimuovi o sposta questo repository git annidato.", "no_workspace": "Per favore, apri prima una cartella di progetto", "update_support_prompt": "Errore durante l'aggiornamento del messaggio di supporto", "reset_support_prompt": "Errore durante il ripristino del messaggio di supporto", diff --git a/src/i18n/locales/ja/common.json b/src/i18n/locales/ja/common.json index f6a9b4b71e69..6bf2ff9a0642 100644 --- a/src/i18n/locales/ja/common.json +++ b/src/i18n/locales/ja/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "チェックポイントの復元を試みる際にタイムアウトしました。", "checkpoint_failed": "チェックポイントの復元に失敗しました。", "git_not_installed": "チェックポイント機能にはGitが必要です。チェックポイントを有効にするにはGitをインストールしてください。", - "nested_git_repos_warning": "ワークスペースでネストされたgitリポジトリが検出されたため、チェックポイントが無効になっています。チェックポイントを使用するには、ネストされたgitリポジトリを削除または移動してください。", + "nested_git_repos_warning": "{{path}} でネストされたgitリポジトリが検出されたため、チェックポイントが無効になっています。チェックポイントを使用するには、このネストされたgitリポジトリを削除または移動してください。", "no_workspace": "まずプロジェクトフォルダを開いてください", "update_support_prompt": "サポートメッセージの更新に失敗しました", "reset_support_prompt": "サポートメッセージのリセットに失敗しました", diff --git a/src/i18n/locales/ko/common.json b/src/i18n/locales/ko/common.json index c424be1d31fa..acca439a5549 100644 --- a/src/i18n/locales/ko/common.json +++ b/src/i18n/locales/ko/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "체크포인트 복원을 시도하는 중 시간 초과되었습니다.", "checkpoint_failed": "체크포인트 복원에 실패했습니다.", "git_not_installed": "체크포인트 기능을 사용하려면 Git이 필요합니다. 체크포인트를 활성화하려면 Git을 설치하세요.", - "nested_git_repos_warning": "워크스페이스에서 중첩된 git 저장소가 감지되어 체크포인트가 비활성화되었습니다. 체크포인트를 사용하려면 중첩된 git 저장소를 제거하거나 이동해주세요.", + "nested_git_repos_warning": "{{path}}에서 중첩된 git 저장소가 감지되어 체크포인트가 비활성화되었습니다. 체크포인트를 사용하려면 이 중첩된 git 저장소를 제거하거나 이동해주세요.", "no_workspace": "먼저 프로젝트 폴더를 열어주세요", "update_support_prompt": "지원 프롬프트 업데이트에 실패했습니다", "reset_support_prompt": "지원 프롬프트 재설정에 실패했습니다", diff --git a/src/i18n/locales/nl/common.json b/src/i18n/locales/nl/common.json index c27f2d7a4918..7ae3b60b1bb6 100644 --- a/src/i18n/locales/nl/common.json +++ b/src/i18n/locales/nl/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Time-out bij het herstellen van checkpoint.", "checkpoint_failed": "Herstellen van checkpoint mislukt.", "git_not_installed": "Git is vereist voor de checkpoint-functie. Installeer Git om checkpoints in te schakelen.", - "nested_git_repos_warning": "Checkpoints zijn uitgeschakeld omdat geneste git-repositories zijn gedetecteerd in de werkruimte. Om checkpoints te gebruiken, verwijder of verplaats de geneste git-repositories.", + "nested_git_repos_warning": "Checkpoints zijn uitgeschakeld omdat een geneste git-repository is gedetecteerd op: {{path}}. Om checkpoints te gebruiken, verwijder of verplaats deze geneste git-repository.", "no_workspace": "Open eerst een projectmap", "update_support_prompt": "Bijwerken van ondersteuningsprompt mislukt", "reset_support_prompt": "Resetten van ondersteuningsprompt mislukt", diff --git a/src/i18n/locales/pl/common.json b/src/i18n/locales/pl/common.json index 43c3325c7517..29a6120fce45 100644 --- a/src/i18n/locales/pl/common.json +++ b/src/i18n/locales/pl/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Upłynął limit czasu podczas próby przywrócenia punktu kontrolnego.", "checkpoint_failed": "Nie udało się przywrócić punktu kontrolnego.", "git_not_installed": "Funkcja punktów kontrolnych wymaga oprogramowania Git. Zainstaluj Git, aby włączyć punkty kontrolne.", - "nested_git_repos_warning": "Punkty kontrolne są wyłączone, ponieważ wykryto zagnieżdżone repozytoria git w obszarze roboczym. Aby używać punktów kontrolnych, usuń lub przenieś zagnieżdżone repozytoria git.", + "nested_git_repos_warning": "Punkty kontrolne są wyłączone, ponieważ wykryto zagnieżdżone repozytorium git w: {{path}}. Aby używać punktów kontrolnych, usuń lub przenieś to zagnieżdżone repozytorium git.", "no_workspace": "Najpierw otwórz folder projektu", "update_support_prompt": "Nie udało się zaktualizować komunikatu wsparcia", "reset_support_prompt": "Nie udało się zresetować komunikatu wsparcia", diff --git a/src/i18n/locales/pt-BR/common.json b/src/i18n/locales/pt-BR/common.json index af49066966c4..bb78c9733f8f 100644 --- a/src/i18n/locales/pt-BR/common.json +++ b/src/i18n/locales/pt-BR/common.json @@ -33,7 +33,7 @@ "checkpoint_timeout": "Tempo esgotado ao tentar restaurar o ponto de verificação.", "checkpoint_failed": "Falha ao restaurar o ponto de verificação.", "git_not_installed": "O Git é necessário para o recurso de checkpoints. Por favor, instale o Git para habilitar os checkpoints.", - "nested_git_repos_warning": "Os checkpoints estão desabilitados porque repositórios git aninhados foram detectados no espaço de trabalho. Para usar checkpoints, por favor remova ou realoque os repositórios git aninhados.", + "nested_git_repos_warning": "Os checkpoints estão desabilitados porque um repositório git aninhado foi detectado em: {{path}}. Para usar checkpoints, por favor remova ou realoque este repositório git aninhado.", "no_workspace": "Por favor, abra primeiro uma pasta de projeto", "update_support_prompt": "Falha ao atualizar o prompt de suporte", "reset_support_prompt": "Falha ao redefinir o prompt de suporte", diff --git a/src/i18n/locales/ru/common.json b/src/i18n/locales/ru/common.json index 5d001140dce6..e21d1c21288b 100644 --- a/src/i18n/locales/ru/common.json +++ b/src/i18n/locales/ru/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Превышено время ожидания при попытке восстановления контрольной точки.", "checkpoint_failed": "Не удалось восстановить контрольную точку.", "git_not_installed": "Для функции контрольных точек требуется Git. Пожалуйста, установите Git, чтобы включить контрольные точки.", - "nested_git_repos_warning": "Контрольные точки отключены, поскольку в рабочем пространстве обнаружены вложенные git-репозитории. Чтобы использовать контрольные точки, пожалуйста, удалите или переместите вложенные git-репозитории.", + "nested_git_repos_warning": "Контрольные точки отключены, поскольку обнаружен вложенный git-репозиторий в: {{path}}. Чтобы использовать контрольные точки, пожалуйста, удалите или переместите этот вложенный git-репозиторий.", "no_workspace": "Пожалуйста, сначала откройте папку проекта", "update_support_prompt": "Не удалось обновить промпт поддержки", "reset_support_prompt": "Не удалось сбросить промпт поддержки", diff --git a/src/i18n/locales/tr/common.json b/src/i18n/locales/tr/common.json index cd24e0ea8bfd..ca7762d77c82 100644 --- a/src/i18n/locales/tr/common.json +++ b/src/i18n/locales/tr/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Kontrol noktasını geri yüklemeye çalışırken zaman aşımına uğradı.", "checkpoint_failed": "Kontrol noktası geri yüklenemedi.", "git_not_installed": "Kontrol noktaları özelliği için Git gereklidir. Kontrol noktalarını etkinleştirmek için lütfen Git'i yükleyin.", - "nested_git_repos_warning": "Çalışma alanında iç içe git depoları tespit edildiği için kontrol noktaları devre dışı bırakıldı. Kontrol noktalarını kullanmak için lütfen iç içe git depolarını kaldırın veya taşıyın.", + "nested_git_repos_warning": "{{path}} konumunda iç içe git deposu tespit edildiği için kontrol noktaları devre dışı bırakıldı. Kontrol noktalarını kullanmak için lütfen bu iç içe git deposunu kaldırın veya taşıyın.", "no_workspace": "Lütfen önce bir proje klasörü açın", "update_support_prompt": "Destek istemi güncellenemedi", "reset_support_prompt": "Destek istemi sıfırlanamadı", diff --git a/src/i18n/locales/vi/common.json b/src/i18n/locales/vi/common.json index ca866114aebf..4b88d380a86b 100644 --- a/src/i18n/locales/vi/common.json +++ b/src/i18n/locales/vi/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "Đã hết thời gian khi cố gắng khôi phục điểm kiểm tra.", "checkpoint_failed": "Không thể khôi phục điểm kiểm tra.", "git_not_installed": "Yêu cầu Git cho tính năng điểm kiểm tra. Vui lòng cài đặt Git để bật điểm kiểm tra.", - "nested_git_repos_warning": "Điểm kiểm tra bị vô hiệu hóa vì phát hiện các kho git lồng nhau trong không gian làm việc. Để sử dụng điểm kiểm tra, vui lòng xóa hoặc di chuyển các kho git lồng nhau.", + "nested_git_repos_warning": "Điểm kiểm tra bị vô hiệu hóa vì phát hiện kho git lồng nhau tại: {{path}}. Để sử dụng điểm kiểm tra, vui lòng xóa hoặc di chuyển kho git lồng nhau này.", "no_workspace": "Vui lòng mở thư mục dự án trước", "update_support_prompt": "Không thể cập nhật lời nhắc hỗ trợ", "reset_support_prompt": "Không thể đặt lại lời nhắc hỗ trợ", diff --git a/src/i18n/locales/zh-CN/common.json b/src/i18n/locales/zh-CN/common.json index c58a8362a634..c9b03a2dddbf 100644 --- a/src/i18n/locales/zh-CN/common.json +++ b/src/i18n/locales/zh-CN/common.json @@ -34,7 +34,7 @@ "checkpoint_timeout": "尝试恢复检查点时超时。", "checkpoint_failed": "恢复检查点失败。", "git_not_installed": "存档点功能需要 Git。请安装 Git 以启用存档点。", - "nested_git_repos_warning": "存档点已禁用,因为在工作区中检测到嵌套的 git 仓库。要使用存档点,请移除或重新定位嵌套的 git 仓库。", + "nested_git_repos_warning": "存档点已禁用,因为在 {{path}} 检测到嵌套的 git 仓库。要使用存档点,请移除或重新定位此嵌套的 git 仓库。", "no_workspace": "请先打开项目文件夹", "update_support_prompt": "更新支持消息失败", "reset_support_prompt": "重置支持消息失败", diff --git a/src/i18n/locales/zh-TW/common.json b/src/i18n/locales/zh-TW/common.json index 5a9415310470..1ad6acbf9ec8 100644 --- a/src/i18n/locales/zh-TW/common.json +++ b/src/i18n/locales/zh-TW/common.json @@ -29,7 +29,7 @@ "checkpoint_timeout": "嘗試恢復檢查點時超時。", "checkpoint_failed": "恢復檢查點失敗。", "git_not_installed": "存檔點功能需要 Git。請安裝 Git 以啟用存檔點。", - "nested_git_repos_warning": "存檔點已停用,因為在工作區中偵測到巢狀的 git 儲存庫。要使用存檔點,請移除或重新配置巢狀的 git 儲存庫。", + "nested_git_repos_warning": "存檔點已停用,因為在 {{path}} 偵測到巢狀的 git 儲存庫。要使用存檔點,請移除或重新配置此巢狀的 git 儲存庫。", "no_workspace": "請先開啟專案資料夾", "update_support_prompt": "更新支援訊息失敗", "reset_support_prompt": "重設支援訊息失敗", diff --git a/src/services/checkpoints/ShadowCheckpointService.ts b/src/services/checkpoints/ShadowCheckpointService.ts index ba0694edbeec..e68a7cfea103 100644 --- a/src/services/checkpoints/ShadowCheckpointService.ts +++ b/src/services/checkpoints/ShadowCheckpointService.ts @@ -70,14 +70,16 @@ export abstract class ShadowCheckpointService extends EventEmitter { throw new Error("Shadow git repo already initialized") } - const hasNestedGitRepos = await this.hasNestedGitRepositories() + const nestedGitPath = await this.getNestedGitRepository() - if (hasNestedGitRepos) { - // Show user-friendly notification - vscode.window.showWarningMessage(t("common:errors.nested_git_repos_warning"), "OK") + if (nestedGitPath) { + // Show persistent error message with the offending path + const relativePath = path.relative(this.workspaceDir, nestedGitPath) + const message = t("common:errors.nested_git_repos_warning", { path: relativePath }) + vscode.window.showErrorMessage(message) throw new Error( - "Checkpoints are disabled because nested git repositories were detected in the workspace. " + + `Checkpoints are disabled because a nested git repository was detected at: ${relativePath}. ` + "Please remove or relocate nested git repositories to use the checkpoints feature.", ) } @@ -158,34 +160,54 @@ export abstract class ShadowCheckpointService extends EventEmitter { } } - private async hasNestedGitRepositories(): Promise { + private async getNestedGitRepository(): Promise { try { - // Find all .git directories that are not at the root level. + // Find all .git/HEAD files that are not at the root level. const args = ["--files", "--hidden", "--follow", "-g", "**/.git/HEAD", this.workspaceDir] const gitPaths = await executeRipgrep({ args, workspacePath: this.workspaceDir }) // Filter to only include nested git directories (not the root .git). - const nestedGitPaths = gitPaths.filter( - ({ type, path }) => - type === "folder" && path.includes(".git") && !path.startsWith(".git") && path !== ".git", - ) + // Since we're searching for HEAD files, we expect type to be "file" + const nestedGitPaths = gitPaths.filter(({ type, path: filePath }) => { + // Check if it's a file and is a nested .git/HEAD (not at root) + if (type !== "file") return false + + // Ensure it's a .git/HEAD file and not the root one + const normalizedPath = filePath.replace(/\\/g, "/") + return ( + normalizedPath.includes(".git/HEAD") && + !normalizedPath.startsWith(".git/") && + normalizedPath !== ".git/HEAD" + ) + }) if (nestedGitPaths.length > 0) { + // Get the first nested git repository path + // Remove .git/HEAD from the path to get the repository directory + const headPath = nestedGitPaths[0].path + + // Use path module to properly extract the repository directory + // The HEAD file is at .git/HEAD, so we need to go up two directories + const gitDir = path.dirname(headPath) // removes HEAD, gives us .git + const repoDir = path.dirname(gitDir) // removes .git, gives us the repo directory + + const absolutePath = path.join(this.workspaceDir, repoDir) + this.log( - `[${this.constructor.name}#hasNestedGitRepositories] found ${nestedGitPaths.length} nested git repositories: ${nestedGitPaths.map((p) => p.path).join(", ")}`, + `[${this.constructor.name}#getNestedGitRepository] found ${nestedGitPaths.length} nested git repositories, first at: ${repoDir}`, ) - return true + return absolutePath } - return false + return null } catch (error) { this.log( - `[${this.constructor.name}#hasNestedGitRepositories] failed to check for nested git repos: ${error instanceof Error ? error.message : String(error)}`, + `[${this.constructor.name}#getNestedGitRepository] failed to check for nested git repos: ${error instanceof Error ? error.message : String(error)}`, ) // If we can't check, assume there are no nested repos to avoid blocking the feature. - return false + return null } } diff --git a/src/services/checkpoints/__tests__/ShadowCheckpointService.spec.ts b/src/services/checkpoints/__tests__/ShadowCheckpointService.spec.ts index 4bf2529d5961..622a90f39abb 100644 --- a/src/services/checkpoints/__tests__/ShadowCheckpointService.spec.ts +++ b/src/services/checkpoints/__tests__/ShadowCheckpointService.spec.ts @@ -421,11 +421,13 @@ describe.each([[RepoPerTaskCheckpointService, "RepoPerTaskCheckpointService"]])( const searchPattern = args[4] if (searchPattern.includes(".git/HEAD")) { + // Return the HEAD file path, not the .git directory + const headFilePath = path.join(path.relative(workspaceDir, nestedGitDir), "HEAD") return Promise.resolve([ { - path: path.relative(workspaceDir, nestedGitDir), - type: "folder", - label: ".git", + path: headFilePath, + type: "file", // HEAD is a file, not a folder + label: "HEAD", }, ]) } else { @@ -436,8 +438,9 @@ describe.each([[RepoPerTaskCheckpointService, "RepoPerTaskCheckpointService"]])( const service = new klass(taskId, shadowDir, workspaceDir, () => {}) // Verify that initialization throws an error when nested git repos are detected - await expect(service.initShadowGit()).rejects.toThrow( - "Checkpoints are disabled because nested git repositories were detected in the workspace", + // The error message now includes the specific path of the nested repository + await expect(service.initShadowGit()).rejects.toThrowError( + /Checkpoints are disabled because a nested git repository was detected at:/, ) // Clean up.