@jc_stack/ez-library 0.1.0-beta.12 → 0.1.0-beta.13

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0-beta.13
4
+
5
+ - Respect Git ignore rules during sync: ignored caches remain local without blocking valid files. Preserve merge-conflict and overwrite protections.
6
+
3
7
  ## 0.1.0-beta.12
4
8
 
5
9
  - Prepare a new release with npm publishing-settings verification included. Package trust and registry delivery are verified separately from local release checks.
@@ -74,8 +74,11 @@ key through the GitHub plugin and deleting that repository key explicitly.
74
74
  This backend mirrors a repository branch, not an arbitrary subdirectory of an
75
75
  unrelated repository. Git tracks empty files but not empty directories. Native
76
76
  Git attributes/normalization apply. Hidden originals receive the same safety and
77
- size checks as visible files. Ignored Library files block a claim
78
- of full synchronization rather than silently disappearing. Symlinks/submodules,
77
+ size checks as visible files. Git-ignored untracked files remain local and do
78
+ not block synchronization or count toward Git upload size limits. Tracked files
79
+ continue to sync even when an ignore pattern matches them. Incoming tracked
80
+ files cannot overwrite ignored local files; resolve that collision before syncing.
81
+ Symlinks/submodules,
79
82
  Git LFS content and ordinary files at or above 100 MiB are unsupported. Hybrid
80
83
  automatic routing is not supplied. Repository rules may reject direct pushes;
81
84
  that rejection remains a pending sync error rather than being bypassed.
package/ez-plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "id": "library",
4
- "version": "0.1.0-beta.12",
4
+ "version": "0.1.0-beta.13",
5
5
  "description": "Dockerized agent library files, QMD retrieval and explicit persistence settings",
6
6
  "commands": {
7
7
  "library": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jc_stack/ez-library",
3
- "version": "0.1.0-beta.12",
3
+ "version": "0.1.0-beta.13",
4
4
  "publishConfig": { "access": "public", "tag": "latest" },
5
5
  "description": "Dockerized agent library files, QMD retrieval and explicit persistence settings",
6
6
  "type": "module",
package/src/git-sync.mjs CHANGED
@@ -114,12 +114,11 @@ export async function gitTransfer(root, config) {
114
114
  const conflict = succeeded(await git(root, config, ['ls-files', '--unmerged']), 'Inspect merge state');
115
115
  if (conflict) fail('CONFLICT', 'Git merge unresolved; use native git status/show/add to resolve both retained versions before syncing');
116
116
  const files = await inventory(path.join(root, 'files'), '', { includeHidden: true });
117
- if (files.some(f => f.bytes >= 100 * 1024 * 1024)) fail('TOO_LARGE', 'GitHub ordinary files must be below 100 MiB; select another storage mode for larger media');
117
+ const ignored = new Set(succeeded(await git(root, config, ['ls-files', '--others', '--ignored', '--exclude-standard', '-z']), 'Inspect ignored files').split('\0').filter(Boolean));
118
+ if (files.some(f => !ignored.has(f.path) && f.bytes >= 100 * 1024 * 1024)) fail('TOO_LARGE', 'GitHub ordinary files must be below 100 MiB; select another storage mode for larger media');
118
119
  succeeded(await git(root, config, ['add', '--all', '--', '.']), 'Stage Library changes');
119
120
  const stagedTree = succeeded(await git(root, config, ['write-tree']), 'Read staged tree').trim();
120
121
  await tree(root, config, stagedTree);
121
- const ignored = succeeded(await git(root, config, ['ls-files', '--others', '--ignored', '--exclude-standard', '-z']), 'Inspect ignored files').split('\0').filter(Boolean);
122
- if (ignored.some(name => files.some(file => file.path === name))) fail('CONFLICT', 'Library files are excluded by repository ignore rules; reconcile the rules before claiming synchronization');
123
122
  const diff = await git(root, config, ['diff', '--cached', '--quiet']);
124
123
  if (![0, 1].includes(diff.code)) succeeded(diff, 'Inspect staged changes');
125
124
  const merging = await git(root, config, ['rev-parse', '--verify', 'MERGE_HEAD']);
@@ -127,7 +126,7 @@ export async function gitTransfer(root, config) {
127
126
  succeeded(await git(root, config, ['fetch', '--no-tags', 'origin', 'refs/heads/' + config.branch]), 'Fetch remote changes');
128
127
  await tree(root, config, 'FETCH_HEAD');
129
128
  const head = succeeded(await git(root, config, ['rev-parse', 'HEAD']), 'Read local commit').trim();
130
- const merge = await git(root, config, ['merge', '--no-edit', '--no-gpg-sign', 'FETCH_HEAD']);
129
+ const merge = await git(root, config, ['merge', '--no-overwrite-ignore', '--no-edit', '--no-gpg-sign', 'FETCH_HEAD']);
131
130
  if (merge.code !== 0) {
132
131
  if (succeeded(await git(root, config, ['ls-files', '--unmerged']), 'Inspect conflicts')) fail('CONFLICT', 'Both revisions retained in Git merge stages. Resolve the merge before sync/indexing resumes');
133
132
  succeeded(merge, 'Merge remote changes');
@@ -76,19 +76,37 @@ test('missing remote retains local commits for retry, and symlink changes cannot
76
76
  await assert.rejects(fs.lstat(path.join(root, 'files/unsafe')), { code: 'ENOENT' });
77
77
  });
78
78
 
79
- test('adoption preserves mismatching local files and ignore rules cannot hide unsynced originals', async t => {
79
+ test('adoption preserves mismatching local files and validates repository names', async t => {
80
80
  const first = await setup(t);
81
81
  await put(first.root, 'note0.md', Readable.from(['Keep local']), { expected: 'new', key: 'local' });
82
82
  await assert.rejects(gitAdopt(first.root, first.remote), { code: 'CONFLICT' });
83
83
  assert.equal(await fs.readFile(path.join(first.root, 'files/note0.md'), 'utf8'), 'Keep local');
84
- const second = await setup(t);
85
- await fs.writeFile(path.join(second.external, '.gitignore'), '*.pdf\n'); second.publish();
86
- const { config } = await gitAdopt(second.root, second.remote);
87
- await put(second.root, 'original.pdf', Readable.from(['PDF fixture']), { expected: 'new', key: 'pdf' });
88
- await assert.rejects(cycle(second.root, config), { code: 'CONFLICT' });
89
84
  for (const invalid of ['https://token@github.com/owner/repo', 'owner/../repo', '-option', 'owner/.git']) assert.throws(() => repositoryURL(invalid), { code: 'INVALID' });
90
85
  });
91
86
 
87
+ test('Git ignore rules leave caches local while tracked and eligible files sync', async t => {
88
+ const { root, remote, outside } = await setup(t);
89
+ const { config } = await gitAdopt(root, remote);
90
+ await fs.writeFile(path.join(root, 'files/.gitignore'), '__pycache__/\n*.bin\nnote0.md\n!keep.bin\n');
91
+ await fs.mkdir(path.join(root, 'files/__pycache__'));
92
+ await fs.writeFile(path.join(root, 'files/__pycache__/module.pyc'), 'cache');
93
+ const large = await fs.open(path.join(root, 'files/cache.bin'), 'w');
94
+ await large.truncate(100 * 1024 * 1024); await large.close();
95
+ await fs.writeFile(path.join(root, 'files/note0.md'), 'Tracked change\n');
96
+ await fs.writeFile(path.join(root, 'files/research.md'), 'Research\n');
97
+ await fs.writeFile(path.join(root, 'files/keep.bin'), 'Explicitly included\n');
98
+ const result = await cycle(root, config);
99
+ assert.equal(result.remoteVerified, true);
100
+ assert.equal(outside(['--git-dir', remote, 'show', 'main:note0.md']), 'Tracked change\n');
101
+ assert.equal(outside(['--git-dir', remote, 'show', 'main:research.md']), 'Research\n');
102
+ assert.equal(outside(['--git-dir', remote, 'show', 'main:keep.bin']), 'Explicitly included\n');
103
+ const names = outside(['--git-dir', remote, 'ls-tree', '-r', '--name-only', 'main']);
104
+ assert.doesNotMatch(names, /cache.bin|module.pyc/);
105
+ assert.equal(await fs.readFile(path.join(root, 'files/__pycache__/module.pyc'), 'utf8'), 'cache');
106
+ assert.equal((await fs.stat(path.join(root, 'files/cache.bin'))).size, 100 * 1024 * 1024);
107
+ assert.equal((await cycle(root, config)).commit, result.commit);
108
+ });
109
+
92
110
  test('changed Hybrid policy or bound remote stops Git before any upload', async t => {
93
111
  const { root, remote, outside } = await setup(t);
94
112
  const { config } = await gitAdopt(root, remote);
@@ -102,6 +120,18 @@ test('changed Hybrid policy or bound remote stops Git before any upload', async
102
120
  await assert.rejects(cycle(root, config), { code: 'CONFLICT' });
103
121
  });
104
122
 
123
+ test('an incoming tracked file cannot overwrite an ignored local original', async t => {
124
+ const { root, remote, external, outside, publish } = await setup(t);
125
+ await fs.writeFile(path.join(external, '.gitignore'), '*.cache\n'); publish();
126
+ const { config } = await gitAdopt(root, remote);
127
+ await fs.writeFile(path.join(root, 'files/local.cache'), 'Retain local bytes\n');
128
+ await fs.writeFile(path.join(external, 'local.cache'), 'Incoming bytes\n');
129
+ outside(['-C', external, 'add', '-f', '--', 'local.cache']); publish();
130
+ await assert.rejects(cycle(root, config));
131
+ assert.equal(await fs.readFile(path.join(root, 'files/local.cache'), 'utf8'), 'Retain local bytes\n');
132
+ assert.equal(outside(['--git-dir', remote, 'show', 'main:local.cache']), 'Incoming bytes\n');
133
+ });
134
+
105
135
  test('hidden originals obey Git safety and size checks before any push', async t => {
106
136
  const { root, remote, outside } = await setup(t);
107
137
  const { config } = await gitAdopt(root, remote);