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

pygit2: implement status #118

Merged
merged 3 commits into from
Jul 28, 2022
Merged

pygit2: implement status #118

merged 3 commits into from
Jul 28, 2022

Conversation

dtrifiro
Copy link
Contributor

@dtrifiro dtrifiro commented Jul 19, 2022

  • bump pygit2 to 1.10.0
  • force dulwich.status to return posix-style paths for untracked files

@dtrifiro

This comment was marked as outdated.

@dtrifiro dtrifiro marked this pull request as draft July 20, 2022 20:22
@skshetry
Copy link
Member

pygit2 v1.10.0 is now released.

tests/test_git.py Outdated Show resolved Hide resolved
for consistency with staged/unstaged paths.

See jelmer/dulwich#995
@dtrifiro dtrifiro force-pushed the main branch 2 times, most recently from e6d56da to ccca0f7 Compare July 26, 2022 16:54
@dtrifiro dtrifiro marked this pull request as ready for review July 26, 2022 17:02
# This can be removed after next pygit2 release:
# see https://github.com/libgit2/pygit2/pull/1087
GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES = 1 << 18

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some housekeeping

tests/test_git.py Outdated Show resolved Hide resolved
@dtrifiro
Copy link
Contributor Author

While fixing this, I noticed something weird: since reset is not implemented for dulwich, in `estst:

scmrepo/tests/test_git.py

Lines 659 to 681 in f35b124

@pytest.mark.skip_git_backend("pygit2")
def test_add(tmp_dir: TmpDir, scm: Git, git: Git):
tmp_dir.gen({"foo": "foo", "bar": "bar", "dir": {"baz": "baz"}})
git.add(["foo", "dir"])
staged, unstaged, untracked = scm.status()
assert set(staged["add"]) == {"foo", "dir/baz"}
assert len(unstaged) == 0
assert len(untracked) == 1
scm.commit("commit")
tmp_dir.gen({"foo": "bar", "dir": {"baz": "bar"}})
git.add([], update=True)
staged, unstaged, _ = scm.status()
assert set(staged["modify"]) == {"foo", "dir/baz"}
assert len(unstaged) == 0
assert len(untracked) == 1
scm.reset()
git.add(["dir"], update=True)
staged, unstaged, _ = scm.status()
assert set(staged["modify"]) == {"dir/baz"}
assert len(unstaged) == 1
assert len(untracked) == 1

The reset call switches backend from dulwich to pygit2, and since this PR adds pygit2.status, the scm.status call uses dulwich while the second call uses pygit2. I guess this is one of these issues that only come up when switching backends.

@skshetry
Copy link
Member

@dtrifiro, in the future, please don't create a PR from your default branch. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants