feat(worktree): add ability to pass options to prune(...) API method (#71)

This commit is contained in:
Aleksey Kulikov 2022-06-18 11:54:46 +03:00 committed by GitHub
parent 2daadaa9a4
commit 5f829dd1ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 5 deletions

View file

@ -562,4 +562,14 @@ void main() {
final actual = {for (final e in GitIndexAddOption.values) e: e.value};
expect(actual, expected);
});
test('GitWorktree returns correct values', () {
const expected = {
GitWorktree.pruneValid: 1,
GitWorktree.pruneLocked: 2,
GitWorktree.pruneWorkingTree: 4,
};
final actual = {for (final e in GitWorktree.values) e: e.value};
expect(actual, expected);
});
}

View file

@ -151,6 +151,22 @@ void main() {
expect(repo.worktrees, <String>[]);
});
test('prunes worktree with provided flags', () {
expect(repo.worktrees, <String>[]);
final worktree = Worktree.create(
repo: repo,
name: worktreeName,
path: worktreeDir.path,
);
expect(repo.worktrees, [worktreeName]);
expect(worktree.isPrunable, false);
expect(worktree.isValid, true);
worktree.prune({GitWorktree.pruneValid});
expect(repo.worktrees, <String>[]);
});
test('throws when trying get list of worktrees and error occurs', () {
expect(
() => Worktree.list(Repository(nullptr)),