You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that we initially clone into the default branch (e.g. master or main usually) when we clone a directory, but then we may checkout another branch (via a porcelain.reset()). However this checkout/reset is buggy and/or unintuitive in that it doesn't clean up files that exist in master but do not exist in the branch you checked out.
See pcs/repo.py for the part of the code where we use porcelain.
frompathlibimportPathfromdulwichimportporcelainfromdulwich.objectspecimportparse_commitlocal_repo_path=Path("dulwich_bug")
assertnotlocal_repo_path.exists(), "Delete ./dulwich_bug dir"local_repo_path.mkdir(parents=True)
github_url="https://github.com/agentos-project/agentos.git"porcelain.clone(source=github_url, target=str(local_repo_path), checkout=True)
repo=porcelain.open_repo(local_repo_path)
to_checkout="07bc71358b4360092b58d78f9eee6dc939e90b10"treeish=parse_commit(repo, to_checkout).sha().hexdigest()
porcelain.reset(repo=repo, mode="hard", treeish=treeish)
# The hash we checkout does not have a pcs/ folder so no files should exist.# Confirm here: https://github.com/agentos-project/agentos/tree/07bc71358b4360092b58d78f9eee6dc939e90b10# The problem is that we initially clone into master (which does have a pcs/# folder), then we reset to a commit that doesn't have the pcs/ folder# BUT dulwich doesn't do what you'd expect and clean up the non-existent dirtest_path=local_repo_path/"pcs"/"component.py"assertnottest_path.exists(), f"The path {test_path} should not exist!"
The text was updated successfully, but these errors were encountered:
nickjalbert
changed the title
Our dulwich code unexpectedly leaves undesired files in the repo directory
Our dulwich code can leave undesired files in the repo directory
Mar 25, 2022
The problem is that we initially clone into the default branch (e.g. master or main usually) when we clone a directory, but then we may checkout another branch (via a
porcelain.reset()
). However this checkout/reset is buggy and/or unintuitive in that it doesn't clean up files that exist in master but do not exist in the branch you checked out.See
pcs/repo.py
for the part of the code where we use porcelain.This bug was mentioned in #342.
Here is a script to reproduce the problem:
The text was updated successfully, but these errors were encountered: