Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files added to the index don't influence getStatus #177

Open
sebastianrath opened this issue May 18, 2021 · 0 comments
Open

Files added to the index don't influence getStatus #177

sebastianrath opened this issue May 18, 2021 · 0 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@sebastianrath
Copy link
Contributor

sebastianrath commented May 18, 2021

After files got added to an index, getStatus doesn't regard them as it still returns them as "new".

Idea 1: Optionally pass an Index to getStatus to filter out these files

While WIP

test.only('test1', async (t) => {
  const repoPath = getRandomPath();
  const subdir = join(repoPath, 'subdir1', 'subdir2');

  const fileSample = 10;

  let repo: Repository;
  await Repository.initExt(repoPath)
    .then((repoResult: Repository) => {
      repo = repoResult;

      const addedFiles: string[] = [];
      const index = repo.ensureMainIndex();

      fse.ensureDirSync(subdir);
      t.log("Write 'subdir1/subdir2/foo' with 9 bytes");
      for (let i = 0; i < fileSample; ++i) {
        const relPath = join(subdir, `foo${i}`);
        addedFiles.push(relPath);
        fse.writeFileSync(relPath, i.toString());
      }

      index.addFiles(addedFiles);

      return index.writeFiles();
    }).then(() => {
      t.log('getStatus on all elements, including directories');
      return repo.getStatus(FILTER.ALL);
    }).then((statuses: StatusEntry[]) => {
      t.is(statuses.length, 0); // <-- the files were already written to the index, this should be 0
    });
});
@sebastianrath sebastianrath added the invalid This doesn't seem right label May 18, 2021
@sebastianrath sebastianrath self-assigned this May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant