Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export function globalEntryIsValid(fullPath: string, search: string, ignoreBase?
}

const baseParts = fullPath.toUpperCase().split(path.sep);
const nameParts = search.split(path.sep);
const nameParts = search.split(path.posix.sep);

// Check the preceding parts of the path match
if (nameParts.length > 1) {
Expand All @@ -297,7 +297,7 @@ export function globalEntryIsValid(fullPath: string, search: string, ignoreBase?
const tempName = search.substring(0, search.length - 1);
const lastChar = tempName.charAt(tempName.length - 1);
const messedUpFullName = fullPath.lastIndexOf(lastChar) >= 0 ? fullPath.substring(0, fullPath.lastIndexOf(lastChar) + 1) : fullPath;
if (messedUpFullName.toUpperCase().endsWith(tempName)) return true;
if (messedUpFullName.replace(/\\/g, '/').toUpperCase().endsWith(tempName)) return true;
} else if (!baseName.includes('.')) {
// If the name does not include a dot, we check if the current part (without extension) matches
let currentPart = baseParts[baseParts.length - 1];
Expand Down
88 changes: 44 additions & 44 deletions cli/test/includeMismatchFix.test.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
import { beforeAll, describe, expect, test } from 'vitest';

import { Targets } from '../src/targets'
import path from 'path';
import { setupFixture } from './fixtures/projects';
import { ReadFileSystem } from '../src/readFileSystem';

// This issue was occuring when you had two files with the same name, but different extensions.

describe(`include_mismatch_fix tests`, () => {
const project = setupFixture(`include_mismatch_fix`);

const fs = new ReadFileSystem();
const targets = new Targets(project.cwd, fs);
targets.setSuggestions({renames: true, includes: true})

beforeAll(async () => {
project.setup();
await targets.loadProject();

expect(targets.getTargets().length).toBeGreaterThan(0);
targets.resolveBinder();
});

test(`Ensure rename is against correct file`, async () => {
const articlePf = targets.getTarget({systemName: `ARTICLE`, type: `FILE`});
expect(articlePf).toBeDefined();

const articlePfLogs = targets.logger.getLogsFor(articlePf.relativePath);
expect(articlePfLogs.length).toBe(1);
expect(articlePfLogs[0].message).toBe(`no object found for reference 'SAMREF'`);
expect(articlePfLogs[0].type).toBe(`warning`);

const articleIncludeLogs = targets.logger.getLogsFor(path.join(`QPROTOSRC`, `ARTICLE.RPGLE`));
expect(articleIncludeLogs.length).toBe(1);
expect(articleIncludeLogs[0].message).toBe(`Rename suggestion`);
expect(articleIncludeLogs[0].type).toBe(`rename`);
expect(articleIncludeLogs[0].change).toMatchObject({
rename: {
path: path.join(project.cwd, `QPROTOSRC`, `ARTICLE.RPGLE`),
newName: 'ARTICLE.rpgleinc'
}
})
});
import { beforeAll, describe, expect, test } from 'vitest';
import { Targets } from '../src/targets'
import path from 'path';
import { setupFixture } from './fixtures/projects';
import { ReadFileSystem } from '../src/readFileSystem';
// This issue was occuring when you had two files with the same name, but different extensions.
describe(`include_mismatch_fix tests`, () => {
const project = setupFixture(`include_mismatch_fix`);
const fs = new ReadFileSystem();
const targets = new Targets(project.cwd, fs);
targets.setSuggestions({renames: true, includes: true})
beforeAll(async () => {
project.setup();
await targets.loadProject();
expect(targets.getTargets().length).toBeGreaterThan(0);
targets.resolveBinder();
});
test(`Ensure rename is against correct file`, async () => {
const articlePf = targets.getTarget({systemName: `ARTICLE`, type: `FILE`});
expect(articlePf).toBeDefined();articlePf.relativePath
const articlePfLogs = targets.logger.getLogsFor(path.join(`QDDSSRC`, `ARTICLE.PF`));
expect(articlePfLogs.length).toBe(1);
expect(articlePfLogs[0].message).toBe(`no object found for reference 'SAMREF'`);
expect(articlePfLogs[0].type).toBe(`warning`);
const articleIncludeLogs = targets.logger.getLogsFor(path.join(`QPROTOSRC`, `ARTICLE.RPGLE`));
expect(articleIncludeLogs.length).toBe(1);
expect(articleIncludeLogs[0].message).toBe(`Rename suggestion`);
expect(articleIncludeLogs[0].type).toBe(`rename`);
expect(articleIncludeLogs[0].change).toMatchObject({
rename: {
path: path.join(project.cwd, `QPROTOSRC`, `ARTICLE.RPGLE`),
newName: 'ARTICLE.rpgleinc'
}
})
});
});