[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,93 +2,142 @@
|
||||
id: wiki-2026-0508-submodules
|
||||
title: Submodules
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-A6EDEA]
|
||||
aliases: [Git Submodules, git submodule]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
tags: [auto-reinforced]
|
||||
verification_status: applied
|
||||
tags: [git, submodules, monorepo, vendoring]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
github_commit: "[P-Reinforce] Continuous Worker - Submodules"
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: bash
|
||||
framework: git
|
||||
---
|
||||
|
||||
# [[Submodules|Submodules]]
|
||||
# Submodules
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> 서브모듈(Submodules)은 부모 애플리케이션 내에 존재하더라도 자체적인 컨텍스트를 가지기 때문에 [[Husky|Husky]], lint-staged, [[ESLint|ESLint]]와 같은 코드 품질 도구들과 기본적으로 원활하게 연동되지 않습니다. 따라서 이러한 도구들이 정상적으로 작동하여 코딩 표준을 강제할 수 있도록, 서브모듈 루트 내에 개별적인 패키지 설치 및 부모 설정을 확장(extend)하는 구성 작업이 필수적으로 요구됩니다 [1, 2].
|
||||
## 매 한 줄
|
||||
> **"매 repo-in-repo with pinned commit"**. Git submodule 매 외부 repository 의 specific commit 의 reference 의 host repo 안 의 nest. 매 2026 perspective: monorepo / package manager (pnpm workspaces, npm workspaces) 의 대부분 의 use case 의 replace, 매 vendoring binary asset, plugin SDK, firmware blob 의 niche 의 survive.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **도구 실행 컨텍스트의 분리:** Husky와 lint-staged는 서브모듈 자체의 컨텍스트 내에서 실행됩니다. 이 때문에 서브모듈을 사용할 경우, 해당 서브모듈에도 Husky와 lint-staged를 설치하고 서브모듈의 `package.json`에 Husky 훅(hooks)을 명시적으로 추가해야 합니다 [1].
|
||||
- **`package.json`이 없는 서브모듈의 처리:** 서브모듈에 `package.json`이 없는 경우라도 서브모듈 내에 Husky를 초기화(init)해 주어야 합니다. 이 작업은 부모 앱의 `prepare` 스크립트에 추가하는 방식으로 간단히 처리할 수 있습니다 [2].
|
||||
- **ESLint 및 TypeScript 설정 상속:**
|
||||
- ESLint가 서브모듈에서 작동하려면 서브모듈의 루트에도 구성 파일(config)이 있어야 합니다. 이 경우 새로운 설정 파일을 생성하되 부모 앱의 설정을 확장(extend)하도록 작성하면 됩니다 [2].
|
||||
- 마찬가지로 Husky와 lint-staged가 스크립트를 실행하기 위해 `tsconfig.json`을 필요로 하므로, 서브모듈 루트에 `tsconfig.json`을 추가하고 부모 앱의 설정을 상속받아 구성해야 합니다 [2].
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
|
||||
- **정책 변화:** Programming & Language 분야의 자동 자산화 수행.
|
||||
### 매 동작 model
|
||||
- 매 host repo 의 `.gitmodules` file 의 url + path 의 list.
|
||||
- 매 host repo 의 tree object 의 submodule path 의 gitlink (commit SHA) 의 store — 매 file 의 X.
|
||||
- 매 `git clone` 의 default 의 submodule 의 fetch X — 매 `--recursive` 또는 `git submodule update --init`.
|
||||
- 매 detached HEAD state 의 submodule 의 default — 매 branch tracking 의 explicit opt-in.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** [[Husky|Husky]], lint-staged, [[ESLint|ESLint]], TypeScript
|
||||
- **Projects/Contexts:** 팀 코딩 표준 강제 (Enforcing coding standards)
|
||||
- **Contradictions/Notes:** 서브모듈은 부모 디렉터리에 도구들이 설치 및 설정되어 있더라도 이를 자동으로 공유하지 않습니다. 따라서 부모 애플리케이션의 린트 및 포맷팅 자동화를 서브모듈에도 동일하게 적용하려면 각각 독립적인 훅과 확장 설정이 강제됩니다 [1, 2].
|
||||
### 매 typical pitfall
|
||||
- 매 host commit 의 update X 의 submodule pointer 의 stale.
|
||||
- 매 force-push 의 submodule remote 의 host 의 SHA 의 missing — fetch fail.
|
||||
- 매 nested submodule 의 `--recurse-submodules` 의 forget 의 partial checkout.
|
||||
- 매 CI 의 shallow clone 의 submodule 의 not 의 init.
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-19*
|
||||
### 매 응용
|
||||
1. Vendoring third-party C/C++ library (FFmpeg, OpenSSL).
|
||||
2. Sharing firmware blob 의 multiple device repo.
|
||||
3. Plugin / theme SDK 의 host application 의 embed.
|
||||
4. Documentation site 의 example code 의 separate repo 의 pin.
|
||||
|
||||
---
|
||||
## 💻 패턴
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
### Add submodule
|
||||
```bash
|
||||
git submodule add https://github.com/org/lib.git vendor/lib
|
||||
git commit -m "Add vendor/lib submodule"
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Clone with submodules
|
||||
```bash
|
||||
git clone --recurse-submodules https://github.com/org/host.git
|
||||
# 또는 매 already-cloned repo
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Update submodule to latest
|
||||
```bash
|
||||
cd vendor/lib
|
||||
git fetch && git checkout v2.5.0
|
||||
cd ../..
|
||||
git add vendor/lib
|
||||
git commit -m "Bump vendor/lib to v2.5.0"
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Pull host + sync submodule pointers
|
||||
```bash
|
||||
git pull --recurse-submodules
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### Track branch (not detached)
|
||||
```bash
|
||||
git submodule add -b main https://github.com/org/lib.git vendor/lib
|
||||
git config -f .gitmodules submodule.vendor/lib.update merge
|
||||
git submodule update --remote --merge
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### Remove submodule (2026 way)
|
||||
```bash
|
||||
git submodule deinit -f vendor/lib
|
||||
git rm -f vendor/lib
|
||||
rm -rf .git/modules/vendor/lib
|
||||
git commit -m "Remove vendor/lib submodule"
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### Foreach run command across all
|
||||
```bash
|
||||
git submodule foreach --recursive 'git status'
|
||||
git submodule foreach 'git checkout main && git pull'
|
||||
```
|
||||
|
||||
### CI shallow + submodule
|
||||
```yaml
|
||||
# GitHub Actions 매 example
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| JS/TS shared lib | pnpm workspace 또는 npm workspace |
|
||||
| Polyglot monorepo 의 source share | git subtree (history merged) |
|
||||
| Binary asset 의 pin (firmware, large model) | submodule |
|
||||
| Third-party C/C++ vendoring | submodule 또는 vcpkg/Conan |
|
||||
| Plugin SDK 의 host 의 embed | submodule (pinned SHA) |
|
||||
| Multi-language CI 의 partial checkout | sparse-checkout + submodule |
|
||||
|
||||
**기본값**: 매 JS/TS 의 monorepo 의 workspaces 의 use, 매 submodule 의 binary / cross-ecosystem vendoring 의 reserve.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Git]] · [[Version Control]]
|
||||
- 변형: [[Git Subtree]] · [[Monorepo]] · [[pnpm workspaces]]
|
||||
- 응용: [[Vendoring]] · [[Plugin SDK]]
|
||||
- Adjacent: [[Sparse Checkout]] · [[Git LFS]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 binary asset 또는 cross-language vendor lib 의 pin 의 specific upstream commit 의 reproducibility 의 require.
|
||||
**언제 X**: 매 JS/TS 의 shared package — 매 workspace 의 strictly superior. 매 frequently-edited shared code — 매 subtree 또는 monorepo 의 prefer.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Submodule 의 active dev**: 매 submodule 안 의 daily edit 의 host pointer 의 forever-out-of-date — 매 monorepo 의 promote.
|
||||
- **Force-push 의 upstream**: 매 host repo 의 referenced SHA 의 lose — 매 fetch fail forever.
|
||||
- **`git submodule update` 의 forget**: 매 host pull 후 의 stale submodule 의 confusing diff.
|
||||
- **Nested submodule 의 5+ level**: 매 cognitive overhead 의 explode — 매 flatten 의 prefer.
|
||||
- **Submodule 의 source-of-truth treat**: 매 fork 의 publish 의 X 의 host-only patch 의 lose.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Git docs `git-submodule(1)`, Pro Git Book Ch. 7.11).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — submodule lifecycle, CI, anti-patterns |
|
||||
|
||||
Reference in New Issue
Block a user