shadow-git 0.1.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +5 -1
- package/.temp/.sgit/index +0 -0
- package/.temp/.sgit/info/exclude +16 -7
- package/.temp/.sgit/objects/03/7f4e37a02573e40ab78b35dd4b442cc6110bae +0 -0
- package/.temp/.sgit/objects/2f/f0fd85dec20039eef6ff63ead905778a88843f +0 -0
- package/.temp/.sgit/objects/c3/2432f724b666f647fe21a1ce16535cd7693f74 +0 -0
- package/.temp/.sgit/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- package/.temp/.sgit/objects/ee/9dd32cca3b134623d184eb4de5805704c493e3 +0 -0
- package/.temp/.sgit.json +6 -2
- package/.temp/README.md +0 -3
- package/.temp/rec1/rec2/test +0 -0
- package/.temp/temp/shouldnt-track +0 -0
- package/.temp/test/1 +0 -0
- package/CLAUDE.md +10 -2
- package/README.md +16 -29
- package/dist/cli.js +810 -119
- package/package.json +1 -1
- package/src/cli.ts +50 -19
- package/src/commands/debug/gitignores.ts +28 -0
- package/src/commands/debug/index.ts +32 -0
- package/src/commands/track/add.ts +11 -0
- package/src/commands/track/clone.ts +213 -0
- package/src/commands/track/completion.ts +50 -15
- package/src/commands/track/destroy.ts +97 -19
- package/src/commands/track/ignore.ts +55 -0
- package/src/commands/track/index.ts +23 -1
- package/src/commands/track/init.ts +5 -2
- package/src/commands/track/sync.ts +1 -1
- package/src/commands/track/unignore.ts +50 -0
- package/src/commands/track/verify.ts +93 -20
- package/src/core/errors.ts +23 -2
- package/src/core/exclude.ts +40 -43
- package/src/core/gitignore.ts +242 -0
- package/src/core/hooks.ts +19 -0
- package/src/core/manifest.ts +33 -1
- package/src/core/paths.ts +21 -3
- package/src/core/repository.ts +17 -2
- package/tests/commands/track/add.test.ts +31 -1
- package/tests/commands/track/clone.test.ts +315 -0
- package/tests/commands/track/completion.test.ts +1 -1
- package/tests/commands/track/destroy.test.ts +68 -2
- package/tests/commands/track/ignore.test.ts +109 -0
- package/tests/commands/track/init.test.ts +27 -4
- package/tests/commands/track/remove.test.ts +1 -1
- package/tests/commands/track/sync.test.ts +3 -3
- package/tests/commands/track/unignore.test.ts +72 -0
- package/tests/commands/track/verify.test.ts +132 -1
- package/tests/core/exclude.test.ts +107 -19
- package/tests/core/gitignore.test.ts +561 -0
- package/tests/core/hooks.test.ts +34 -0
- package/tests/core/paths.test.ts +24 -0
- package/tests/core/repository.test.ts +39 -5
- package/tests/helpers/guard-child.mjs +125 -0
- package/tests/helpers.ts +37 -0
|
@@ -33,7 +33,11 @@
|
|
|
33
33
|
"Bash(complete -p)",
|
|
34
34
|
"Bash(pkg-config --variable=completionsdir bash-completion)",
|
|
35
35
|
"Bash(dpkg -l bash-completion)",
|
|
36
|
-
"Bash(git diff:*)"
|
|
36
|
+
"Bash(git diff:*)",
|
|
37
|
+
"Bash(git --git-dir=.sgit --work-tree=. diff --cached --name-only)",
|
|
38
|
+
"Bash(git --git-dir=.sgit --work-tree=. reset HEAD temp/shouldnt-track)",
|
|
39
|
+
"Bash(git --git-dir=.sgit --work-tree=. add .)",
|
|
40
|
+
"Bash(git stash:*)"
|
|
37
41
|
]
|
|
38
42
|
}
|
|
39
43
|
}
|
package/.temp/.sgit/index
CHANGED
|
Binary file
|
package/.temp/.sgit/info/exclude
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# sgit-managed
|
|
2
2
|
*
|
|
3
|
-
|
|
4
|
-
# .sgit.json (always tracked)
|
|
5
3
|
!.sgit.json
|
|
6
|
-
|
|
7
|
-
# temp.md
|
|
8
4
|
!temp.md
|
|
9
|
-
|
|
10
|
-
# README.md
|
|
11
5
|
!README.md
|
|
6
|
+
!temp/
|
|
7
|
+
temp/*
|
|
8
|
+
!temp/should-track
|
|
9
|
+
!temp2/
|
|
10
|
+
!temp2/**
|
|
11
|
+
!test/
|
|
12
|
+
test/*
|
|
13
|
+
!test/1
|
|
14
|
+
!rec1/
|
|
15
|
+
rec1/*
|
|
16
|
+
!rec1/rec2/
|
|
17
|
+
rec1/rec2/*
|
|
18
|
+
!rec1/rec2/test
|
|
19
|
+
.gitignore-sgit.bat
|
|
20
|
+
# end: sgit-managed
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/.temp/.sgit.json
CHANGED
package/.temp/README.md
CHANGED
|
File without changes
|
|
File without changes
|
package/.temp/test/1
ADDED
|
File without changes
|
package/CLAUDE.md
CHANGED
|
@@ -12,6 +12,8 @@ npm run dev # Build in watch mode
|
|
|
12
12
|
|
|
13
13
|
After building, the global `sgit` command uses `dist/cli.js`. Rebuild after source changes to test CLI manually.
|
|
14
14
|
|
|
15
|
+
Always run `npm run lint` after making changes to verify the code type-checks.
|
|
16
|
+
|
|
15
17
|
## Architecture
|
|
16
18
|
|
|
17
19
|
```
|
|
@@ -19,6 +21,9 @@ src/
|
|
|
19
21
|
cli.ts # Entry point, routes to track commands or git passthrough
|
|
20
22
|
commands/
|
|
21
23
|
forward.ts # Forwards non-track commands to shadow git
|
|
24
|
+
debug/
|
|
25
|
+
index.ts # Commander registration for hidden debug subcommands
|
|
26
|
+
gitignores.ts # Disable .gitignore files for 10s then re-enable
|
|
22
27
|
track/
|
|
23
28
|
index.ts # Commander registration for all track subcommands
|
|
24
29
|
init.ts # Initialize .sgit/ repo
|
|
@@ -37,6 +42,7 @@ src/
|
|
|
37
42
|
exclude.ts # Generate .git/info/exclude and .sgit/info/exclude
|
|
38
43
|
hooks.ts # Install/uninstall pre-commit hooks
|
|
39
44
|
errors.ts # Custom error classes (SgitError hierarchy)
|
|
45
|
+
gitignore.ts # Disable/enable .gitignore files during sgit operations
|
|
40
46
|
utils/
|
|
41
47
|
logger.ts # Color-coded stdout/stderr logging
|
|
42
48
|
process.ts # Child process execution
|
|
@@ -45,7 +51,9 @@ src/
|
|
|
45
51
|
## Key Conventions
|
|
46
52
|
|
|
47
53
|
- All paths in `.sgit.json` use forward slashes, relative to repo root
|
|
48
|
-
- Directories are stored with trailing `/` (e.g., `docs/.internal/`)
|
|
49
|
-
-
|
|
54
|
+
- Directories are stored with trailing `/` (e.g., `docs/.internal/`) and track all contents recursively
|
|
55
|
+
- Exclude files use block markers: `# sgit-managed` and `# end: sgit-managed` — everything between is replaced on sync
|
|
50
56
|
- Shadow repo exclude uses a deny-all + allow-list pattern (`*` then `!path`)
|
|
51
57
|
- Error classes extend `SgitError`; the CLI catches these and prints the message
|
|
58
|
+
- Hidden `debug` commands (`sgit debug <cmd>`) are registered with `{ hidden: true }` so they don't appear in `sgit --help`. They are only visible via `sgit debug --help`. Debug commands manage their own gitignore guard (the CLI-level guard is skipped for them). No tests are written for debug commands.
|
|
59
|
+
- **HARD RULE — gitignore revert guarantee:** `.gitignore` files inside sgit-tracked directories are temporarily renamed to `.gitignore-sgit.bat` during sgit command execution (via `setupGitignoreGuard` in `src/core/gitignore.ts`). **The rename MUST always be reverted** when the command ends — whether it succeeds, fails, is cancelled (Ctrl+C), or receives SIGTERM. The guard uses `try/finally`, signal handlers, and `process.on('exit')` to ensure this. Any new code that executes sgit operations must use the guard or equivalent cleanup guarantees. Pre-commit hooks verify no `.gitignore-sgit.bat` files exist at commit time.
|
package/README.md
CHANGED
|
@@ -8,56 +8,43 @@ Shadow-git (`sgit`) creates a `.sgit/` repository alongside your `.git/` directo
|
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install -g .
|
|
11
|
-
# or
|
|
12
|
-
npm link
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
Optionally, install shell completions (bash, zsh, or fish):
|
|
16
14
|
|
|
17
15
|
```bash
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# Start tracking a file
|
|
22
|
-
sgit track add notes/todo.md
|
|
23
|
-
|
|
24
|
-
# Move a main-git-tracked file to shadow tracking
|
|
25
|
-
sgit track add --adopt config.local.json
|
|
16
|
+
sgit track completion install
|
|
17
|
+
```
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
sgit track list
|
|
19
|
+
## Quick Start
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
sgit
|
|
32
|
-
sgit
|
|
33
|
-
sgit
|
|
21
|
+
```bash
|
|
22
|
+
sgit track init # Initialize shadow repo
|
|
23
|
+
sgit track add notes/todo.md # Start tracking a file
|
|
24
|
+
sgit track add --adopt config.local # Move a main-git file to shadow tracking
|
|
25
|
+
sgit track list # List tracked paths
|
|
26
|
+
sgit status # Git status in shadow repo
|
|
27
|
+
sgit commit -m "update notes" # Commit to shadow repo
|
|
34
28
|
```
|
|
35
29
|
|
|
36
30
|
## Commands
|
|
37
31
|
|
|
38
|
-
### Track Management
|
|
39
|
-
|
|
40
32
|
| Command | Description |
|
|
41
33
|
|---|---|
|
|
42
34
|
| `sgit track init` | Initialize shadow repository |
|
|
35
|
+
| `sgit track clone <url>` | Clone a shadow repository from a remote URL |
|
|
43
36
|
| `sgit track add <paths...>` | Start shadow-tracking paths |
|
|
44
37
|
| `sgit track add --adopt <paths...>` | Move main-git-tracked files to shadow tracking |
|
|
45
38
|
| `sgit track remove <paths...>` | Stop shadow-tracking paths |
|
|
46
39
|
| `sgit track list` | List all shadow-tracked paths |
|
|
47
40
|
| `sgit track sync` | Regenerate exclude files from manifest |
|
|
48
41
|
| `sgit track verify` | Validate staged files against manifest |
|
|
42
|
+
| `sgit track ignore <paths...>` | Ignore paths within tracked directories |
|
|
43
|
+
| `sgit track unignore <paths...>` | Stop ignoring paths within tracked directories |
|
|
49
44
|
| `sgit track destroy` | Remove shadow repository entirely |
|
|
45
|
+
| `sgit track completion [install]` | Print or install shell completion scripts |
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Any command not listed above is forwarded directly to git using the shadow repository:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
sgit status # git status in shadow repo
|
|
57
|
-
sgit diff # git diff in shadow repo
|
|
58
|
-
sgit commit -m "msg" # commit to shadow repo
|
|
59
|
-
sgit log # log of shadow repo
|
|
60
|
-
```
|
|
47
|
+
Any non-track command is forwarded to git using the shadow repository (e.g. `sgit status`, `sgit log`, `sgit diff`).
|
|
61
48
|
|
|
62
49
|
## How It Works
|
|
63
50
|
|