-
-
Notifications
You must be signed in to change notification settings - Fork 404
status: add untracked_files and ignored kwargs #1151
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ | |
# along with this program; see the file COPYING. If not, write to | ||
# the Free Software Foundation, 51 Franklin Street, Fifth Floor, | ||
# Boston, MA 02110-1301, USA. | ||
import pygit2 | ||
import pytest | ||
|
||
|
||
def test_status(dirtyrepo): | ||
|
@@ -32,3 +34,49 @@ def test_status(dirtyrepo): | |
for filepath, status in git_status.items(): | ||
assert filepath in git_status | ||
assert status == git_status[filepath] | ||
|
||
|
||
def test_status_untracked_no(dirtyrepo): | ||
git_status = dirtyrepo.status(untracked_files="no") | ||
not any(status & pygit2.GIT_STATUS_WT_NEW for status in git_status.values()) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests don't actually cover all of the possible scenarios, such as having tracked subdirectories with ignored files, tracked subdirectories with untracked files, untracked subdirectories with ignored files, etc, etc. Might improve these tests soon. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're just passing the options to libgit2, the purpose of the test suite is not to test libgit2, which already has its own test suite. So better to keep the tests simple, it's good the way they are already. |
||
"untracked_files,expected", | ||
[ | ||
("no", set()), | ||
( | ||
"normal", | ||
{ | ||
"untracked_dir/", | ||
"staged_delete_file_modified", | ||
"subdir/new_file", | ||
"new_file", | ||
}, | ||
), | ||
( | ||
"all", | ||
{ | ||
"new_file", | ||
"subdir/new_file", | ||
"staged_delete_file_modified", | ||
"untracked_dir/untracked_file", | ||
}, | ||
), | ||
], | ||
) | ||
def test_status_untracked_normal(dirtyrepo, untracked_files, expected): | ||
git_status = dirtyrepo.status(untracked_files=untracked_files) | ||
assert { | ||
file for file, status in git_status.items() if status & pygit2.GIT_STATUS_WT_NEW | ||
} == expected | ||
|
||
|
||
@pytest.mark.parametrize("ignored,expected", [(True, {"ignored"}), (False, set())]) | ||
def test_status_ignored(dirtyrepo, ignored, expected): | ||
git_status = dirtyrepo.status(ignored=ignored) | ||
assert { | ||
file | ||
for file, status in git_status.items() | ||
if status & pygit2.GIT_STATUS_IGNORED | ||
} == expected |
Uh oh!
There was an error while loading. Please reload this page.