Skip to content

Commit b3ebc8c

Browse files
committed
Improve modification detection
1 parent 43e67b4 commit b3ebc8c

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/vt/lib/tests/push_test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,44 @@ Deno.test({
279279
});
280280
},
281281
});
282+
283+
Deno.test({
284+
name: "test push with no changes",
285+
permissions: {
286+
read: true,
287+
write: true,
288+
net: true,
289+
},
290+
async fn() {
291+
await doWithNewProject(async ({ project, branch }) => {
292+
await doWithTempDir(async (tempDir) => {
293+
// Create a file
294+
const vtFilePath = "test.txt";
295+
const localFilePath = join(tempDir, vtFilePath);
296+
await Deno.writeTextFile(localFilePath, "test content");
297+
298+
// Do the push
299+
const firstResult = await push({
300+
targetDir: tempDir,
301+
projectId: project.id,
302+
branchId: branch.id,
303+
});
304+
305+
// Verify that FileState reports the file was created. We have better
306+
// tests for ensuring this operation with more detail, this is just to
307+
// make sure it's idempotent.
308+
assertEquals(firstResult.created.length, 1);
309+
assertEquals(firstResult.size(), 1);
310+
311+
const secondResult = await push({
312+
targetDir: tempDir,
313+
projectId: project.id,
314+
branchId: branch.id,
315+
});
316+
// Should be no changes on the second push
317+
assertEquals(secondResult.not_modified.length, 1);
318+
assertEquals(secondResult.size(), 1);
319+
}, "vt_push_nochange_test_");
320+
});
321+
},
322+
});

src/vt/lib/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ export async function isFileModified(
209209
): Promise<boolean> {
210210
// First use the mtime as a heuristic to avoid unnecessary content checks
211211
if (projectMtime == localMtime) return false;
212-
if (projectMtime > localMtime) return true;
213212

214213
// If mtime indicates a possible change, check content
215214
const projectFileContent = await sdk.projects.files.getContent(

0 commit comments

Comments
 (0)