Bug fixes on git

This commit is contained in:
Richard Osborne
2026-02-18 21:03:36 +01:00
parent ade2afee85
commit 2990e47059
5 changed files with 75 additions and 7 deletions

View File

@@ -422,7 +422,34 @@ Found a solution not listed here? Add it!
**Root cause**: `scripts/test-editor.ts` runs a full webpack compile before Jest. Can appear hung but is just slow (30-90s).
**Rules**:
- Always put test files in `tests/models/` not `tests/services/` (transform config only covers models/ path)
- Never use `npx jest` directly - Babel cannot parse TypeScript `type` keyword without the full transform setup
- Use `npm run test:editor` from root — it will eventually complete
- Never use heredoc (`cat << EOF`) in terminal commands — use printf or write_to_file instead
---
## Pre-Existing Test Bundle Compilation Errors (Feb 2026)
**Symptom**: `npm run test:editor` fails with webpack compilation errors before any tests run:
```
ERROR: Can't resolve '@noodl-views/panels/componentspanel/ComponentsPanel'
ERROR: TS2339: Property 'pull' does not exist on type 'Git'
```
**Root cause**: Two pre-existing issues in the test bundle (unrelated to sprint work):
1. `tests/components/componentspanel.js` references `@noodl-views/panels/componentspanel/ComponentsPanel` — this component was moved/deleted in an earlier refactor. The test file still has the old import path.
2. `tests/git/git-remote*.spec.ts` and `tests/git/git-stash-merge.spec.ts` call `git.pull()` — this method was removed from the `Git` type in `packages/noodl-git/src/git.ts` during an earlier refactor.
**Impact**: The webpack test bundle refuses to compile, so NO tests run (not just the failing ones).
**Fix when prioritised**:
1. Delete or stub `tests/components/componentspanel.js` (or update the import to match the current component location)
2. Update the git test specs to use the current API (check what replaced `pull` in `packages/noodl-git/src/git.ts`)
**Workaround**: Tests can be verified structurally (code review + type checking) while this is unresolved. The issue is in pre-existing test infra, not in sprint-added code.

View File

@@ -1,7 +1,8 @@
export * from './componentconnections';
export * from './componentinstances';
export * from './componentports';
export * from './componentspanel';
// componentspanel test removed - tests legacy Backbone ComponentsPanelView which
// has been archived to ComponentsPanelNew/ComponentsPanel.ts.legacy (not webpack-resolvable)
export * from './conditionalports';
export * from './dynamicports';
export * from './expandedports';

View File

@@ -1,3 +1,4 @@
export * from './UBAConditions.test';
export * from './UBASchemaParser.test';
export * from './ElementConfigRegistry.test';
// NOTE: UBAConditions.test, UBASchemaParser.test, ElementConfigRegistry.test
// use @jest/globals and are Jest-only tests. They run via `npm run test:editor`.
// Do NOT re-add them here - the Electron Jasmine runner will crash on import.
export {};

View File

@@ -1 +1,4 @@
export * from './StyleAnalyzer.test';
// NOTE: StyleAnalyzer.test uses @jest/globals and is a Jest-only test.
// It runs via `npm run test:editor`.
// Do NOT re-add it here - the Electron Jasmine runner will crash on import.
export {};

View File

@@ -265,6 +265,15 @@ export class Git {
// this will also checkout the branch
await popStashEntryToBranch(this.baseDir, stash.name, stashBranchName);
// Commit the stash contents to the stash branch to clean the working tree.
// Without this, git refuses to merge when both branches have modifications to the
// same file (e.g. .gitignore added by appendGitIgnore in _setupRepository).
const stashBranchStatus = await this.status();
if (stashBranchStatus.length > 0) {
await addAll(this.baseDir);
await createCommit(this.baseDir, 'Stash contents');
}
// Merge our working branch into the stash branch
await this._merge({
theirsBranchName: previousBranch,
@@ -377,6 +386,35 @@ export class Git {
await cleanUntrackedFiles(this.baseDir);
}
/**
* Fetch remote changes and merge them into the current branch using Noodl's
* custom merge strategy (handles project.json conflicts).
*
* Equivalent to `git fetch` + `git merge origin/<currentBranch>`.
*/
async pull(options: PullOptions = {}): Promise<void> {
// 1. Fetch latest remote state
await this.fetch({ onProgress: options.onProgress });
// 2. Nothing to merge if remote has no commits yet
const remoteHeadId = await this.getRemoteHeadCommitId();
if (!remoteHeadId) {
return;
}
// 3. Merge origin/<currentBranch> into current branch
const currentBranch = await this.getCurrentBranchName();
const remoteName = await this.getRemoteName();
const remoteRef = `${remoteName}/${currentBranch}`;
await this._mergeToCurrentBranch({
theirsBranchName: remoteRef,
squash: false,
message: `Merge ${remoteRef} into ${currentBranch}`,
allowFastForward: true
});
}
/**
*
* @deprecated This is only used in old git panel
@@ -621,8 +659,6 @@ export class Git {
try {
await this.checkoutBranch(branchName);
} catch (err) {
throw err;
} finally {
if (needsStash) {
await this.stashPopChanges(currentBranchName);