mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
feat(checkout)!: add ability to checkout commit (#35)
This commit is contained in:
parent
6fe24dcb65
commit
f7dde69de3
7 changed files with 115 additions and 38 deletions
|
@ -337,7 +337,7 @@ index e69de29..c217c63 100644
|
|||
);
|
||||
|
||||
final diff2 = Diff.parse(patchText);
|
||||
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
||||
repo.checkout(target: 'HEAD', strategy: {GitCheckout.force});
|
||||
expect(
|
||||
repo.applies(diff: diff2, location: GitApplyLocation.both),
|
||||
true,
|
||||
|
@ -357,7 +357,7 @@ index e69de29..c217c63 100644
|
|||
|
||||
final diff2 = Diff.parse(patchText);
|
||||
final hunk = diff2.patches.first.hunks.first;
|
||||
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
||||
repo.checkout(target: 'HEAD', strategy: {GitCheckout.force});
|
||||
expect(
|
||||
repo.applies(
|
||||
diff: diff2,
|
||||
|
@ -375,7 +375,7 @@ index e69de29..c217c63 100644
|
|||
final diff = Diff.parse(patchText);
|
||||
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
||||
|
||||
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
||||
repo.checkout(target: 'HEAD', strategy: {GitCheckout.force});
|
||||
expect(file.readAsStringSync(), '');
|
||||
|
||||
repo.apply(diff: diff);
|
||||
|
@ -405,7 +405,7 @@ index e69de29..c217c63 100644
|
|||
final hunk = diff.patches.first.hunks.first;
|
||||
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
||||
|
||||
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
||||
repo.checkout(target: 'HEAD', strategy: {GitCheckout.force});
|
||||
expect(file.readAsStringSync(), '');
|
||||
|
||||
repo.apply(diff: diff, hunkIndex: hunk.index);
|
||||
|
@ -417,7 +417,7 @@ index e69de29..c217c63 100644
|
|||
test('applies diff to tree', () {
|
||||
final diff = Diff.parse(patchText);
|
||||
|
||||
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
||||
repo.checkout(target: 'HEAD', strategy: {GitCheckout.force});
|
||||
final head = repo.head;
|
||||
final commit = repo.lookupCommit(head.target);
|
||||
final tree = commit.tree;
|
||||
|
@ -444,7 +444,7 @@ index e69de29..c217c63 100644
|
|||
final diff = Diff.parse(patchText);
|
||||
final hunk = diff.patches.first.hunks.first;
|
||||
|
||||
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
||||
repo.checkout(target: 'HEAD', strategy: {GitCheckout.force});
|
||||
final head = repo.head;
|
||||
final commit = repo.lookupCommit(head.target);
|
||||
final tree = commit.tree;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue