Hashes should be different (but are the same) when inputs differ by filename.
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 816
- Forks
- 88
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
a target should NOT have the same hash if input files list differs when files do not exist.
To Reproduce
Edit TargetHashser.test.ts by adding the following 2 tests:
it("creates different hashes when file path is different for non-existing file", async () => {
const monorepo1 = await setupFixture("monorepo-with-global-files");
const hasher = new TargetHasher({ root: monorepo1.root, environmentGlob: [] });
const target = createTarget(monorepo1.root, "package-a", "build");
target.inputs = ["file1.txt"];
const hash = await getHash(hasher, target);
const target2 = createTarget(monorepo1.root, "package-a", "build");
target2.inputs = ["file2.txt"];
const hash2 = await getHash(hasher, target2);
expect(hash).not.toEqual(hash2);
monorepo1.cleanup();
});
it("creates different hashes when file path is different but file content is the same", async () => {
const monorepo1 = await setupFixture("monorepo-with-global-files");
const hasher = new TargetHasher({ root: monorepo1.root, environmentGlob: [] });
const target = createTarget(monorepo1.root, "package-a", "build");
target.inputs = ["file1.txt"];
fs.writeFileSync(path.join(monorepo1.root, "packages", "package-a", "file1.txt"), "THIS IS CONTENT");
const hash = await getHash(hasher, target);
const target2 = createTarget(monorepo1.root, "package-a", "build");
target2.inputs = ["file1.txt"];
fs.writeFileSync(path.join(monorepo1.root, "packages", "package-a", "file2.txt"), "THIS IS CONTENT2");
const hash2 = await getHash(hasher, target2);
expect(hash).not.toEqual(hash2);
monorepo1.cleanup();
});
Run test
Expected behavior
Test to pass
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open TargetHashser.test.ts and add the two reproduction cases from the issue, then run the test. Trace the TargetHasher entry point used by those tests to determine why differing input paths produce the same hash. Done means the tests pass and hashes differ for the specified input-path cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100