mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(worktree): add ability to create worktree from provided reference
This commit is contained in:
parent
a00078ba76
commit
db21f2e890
6 changed files with 80 additions and 5 deletions
|
@ -52,6 +52,40 @@ void main() {
|
|||
worktree.free();
|
||||
});
|
||||
|
||||
test(
|
||||
'successfully creates worktree at provided path from provided reference',
|
||||
() {
|
||||
const worktreeName = 'worktree';
|
||||
final head = repo.revParseSingle('HEAD');
|
||||
final worktreeRef = repo.branches.create(name: 'v1', target: head);
|
||||
final worktreeBranch = repo.branches['v1'];
|
||||
expect(Worktree.list(repo), []);
|
||||
|
||||
final worktree = Worktree.create(
|
||||
repo: repo,
|
||||
name: worktreeName,
|
||||
path: worktreeDir,
|
||||
ref: worktreeRef,
|
||||
);
|
||||
|
||||
expect(Worktree.list(repo), [worktreeName]);
|
||||
expect(repo.branches.list(), contains('v1'));
|
||||
expect(repo.branches.list(), isNot(contains(worktreeName)));
|
||||
expect(worktreeBranch.isCheckedOut, true);
|
||||
|
||||
Directory(worktreeDir).deleteSync(recursive: true);
|
||||
worktree.prune();
|
||||
|
||||
expect(Worktree.list(repo), []);
|
||||
expect(worktreeBranch.isCheckedOut, false);
|
||||
expect(repo.branches.list(), contains('v1'));
|
||||
|
||||
worktreeBranch.free();
|
||||
worktreeRef.free();
|
||||
head.free();
|
||||
worktree.free();
|
||||
});
|
||||
|
||||
test('successfully prunes worktree', () {
|
||||
const worktreeName = 'worktree';
|
||||
expect(Worktree.list(repo), []);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue