@fluado/enmetu 0.2.0 → 0.3.0

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.
Files changed (46) hide show
  1. package/README.md +53 -5
  2. package/dist/adapters/git/gitFacade.d.ts +8 -0
  3. package/dist/adapters/git/gitFacade.js +34 -1
  4. package/dist/adapters/git/gitProcessAdapter.js +1 -48
  5. package/dist/adapters/host/hostMessageWriterAdapter.d.ts +23 -0
  6. package/dist/adapters/host/hostMessageWriterAdapter.js +76 -0
  7. package/dist/adapters/process/processGroup.d.ts +18 -0
  8. package/dist/adapters/process/processGroup.js +52 -0
  9. package/dist/adapters/process/shellMessageCommandAdapter.d.ts +24 -0
  10. package/dist/adapters/process/shellMessageCommandAdapter.js +102 -0
  11. package/dist/adapters/watch/watcherFor.d.ts +22 -0
  12. package/dist/adapters/watch/watcherFor.js +29 -0
  13. package/dist/cli/commands/hookCommand.d.ts +2 -1
  14. package/dist/cli/commands/hookCommand.js +14 -8
  15. package/dist/cli/commands/runCommand.d.ts +10 -3
  16. package/dist/cli/commands/runCommand.js +45 -9
  17. package/dist/cli.js +2 -0
  18. package/dist/commit/commitLocalChangesController.d.ts +22 -1
  19. package/dist/commit/commitLocalChangesController.js +113 -4
  20. package/dist/contracts/ICommitMessageCommand.d.ts +32 -0
  21. package/dist/contracts/ICommitMessageCommand.js +1 -0
  22. package/dist/contracts/IGitConfigReader.d.ts +4 -1
  23. package/dist/contracts/IGitReader.d.ts +5 -0
  24. package/dist/contracts/IHostMessageWriter.d.ts +28 -0
  25. package/dist/contracts/IHostMessageWriter.js +1 -0
  26. package/dist/contracts/config.d.ts +34 -1
  27. package/dist/contracts/errors.d.ts +5 -1
  28. package/dist/contracts/errors.js +5 -1
  29. package/dist/contracts/library.d.ts +30 -0
  30. package/dist/contracts/logCodes.d.ts +1 -1
  31. package/dist/contracts/runtime.d.ts +4 -0
  32. package/dist/core/commit/commitMessage.d.ts +27 -0
  33. package/dist/core/commit/commitMessage.js +61 -0
  34. package/dist/core/config/parseConfig.d.ts +7 -4
  35. package/dist/core/config/parseConfig.js +172 -26
  36. package/dist/core/git/porcelain.d.ts +7 -0
  37. package/dist/core/git/porcelain.js +24 -0
  38. package/dist/enmetuInstances.d.ts +7 -4
  39. package/dist/enmetuInstances.js +52 -13
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js +2 -0
  42. package/dist/library/enmetuLibrary.d.ts +2 -1
  43. package/dist/library/enmetuLibrary.js +5 -2
  44. package/dist/quarantine/pathQuarantine.d.ts +10 -0
  45. package/dist/quarantine/pathQuarantine.js +44 -2
  46. package/package.json +1 -1
@@ -70,7 +70,13 @@ export class PathQuarantine {
70
70
  // --- Step 5: a file written since step 3 is stored again (Decision 114) ---
71
71
  await this.storeAgainIfWritten(entries, []);
72
72
  // --- Step 6: the held paths now match the index, so the rebase may run ---
73
- await this.writer.restoreFromIndex(paths);
73
+ try {
74
+ await this.writer.restoreFromIndex(paths);
75
+ }
76
+ catch (error) {
77
+ await this.forgetUnheld(0);
78
+ throw error;
79
+ }
74
80
  return { kind: 'held', count: entries.length };
75
81
  }
76
82
  async extend(paths) {
@@ -102,9 +108,45 @@ export class PathQuarantine {
102
108
  // --- Step 6: a file written since step 4 is stored again (Decision 114) ---
103
109
  await this.storeAgainIfWritten(entries, earlier);
104
110
  // --- Step 7: the captured paths now match the index ---
105
- await this.writer.restoreFromIndex(paths);
111
+ try {
112
+ await this.writer.restoreFromIndex(paths);
113
+ }
114
+ catch (error) {
115
+ await this.forgetUnheld(earlier.length);
116
+ throw error;
117
+ }
106
118
  return { kind: 'held', count: entries.length };
107
119
  }
120
+ /**
121
+ * git refused the checkout (a person's merge left a held path unmerged,
122
+ * design 14.20): an entry whose file still holds the bytes stored for it was
123
+ * never set aside, and restoring it later would write those bytes over the
124
+ * person's newer work, conflict markers included. Such entries leave the
125
+ * memento (the memento goes when none is left); an entry whose file changed
126
+ * stays, so no write goes unrecorded. Entries before `from` (an earlier
127
+ * hold that extend added to) stay as they are.
128
+ */
129
+ async forgetUnheld(from) {
130
+ const text = await this.fs.readText(this.mementoPath());
131
+ const memento = text === null ? null : parseQuarantineMemento(text);
132
+ if (memento === null) {
133
+ return;
134
+ }
135
+ const kept = memento.entries.slice(0, from);
136
+ for (const entry of memento.entries.slice(from)) {
137
+ const target = join(this.paths.root, entry.path);
138
+ const seen = await this.observe(entry.path, target);
139
+ if (seen !== (entry.blobId ?? OBSERVED_ABSENT)) {
140
+ kept.push(entry);
141
+ }
142
+ }
143
+ if (kept.length === 0) {
144
+ await this.fs.remove(this.mementoPath());
145
+ }
146
+ else {
147
+ await this.writeMemento({ version: 1, entries: kept });
148
+ }
149
+ }
108
150
  /**
109
151
  * git's checkout writes the index's version over a file whatever the file
110
152
  * holds, so a write that landed after storeEntries read it would be gone
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluado/enmetu",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Keeps one git working tree committed and in sync with its upstream.",
5
5
  "license": "MIT",
6
6
  "author": "fluado UG (haftungsbeschränkt)",