feat(repository)!: add more aliases for api methods

BREAKING CHANGE: Make repository entry point for most operations
This commit is contained in:
Aleksey Kulikov 2021-10-11 20:06:36 +03:00
parent 9205a3ad82
commit 3a0fa75929
51 changed files with 1380 additions and 1062 deletions

View file

@ -8,9 +8,9 @@ void main() {
late Directory tmpDir;
const oldBlob = '';
const newBlob = 'Feature edit\n';
late Oid oldBlobID;
late Oid newBlobID;
const path = 'feature_file';
const oldBlobSha = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391';
const newBlobSha = '9c78c21d6680a7ffebc76f7ac68cacc11d8f48bc';
const blobPatch = """
diff --git a/feature_file b/feature_file
index e69de29..9c78c21 100644
@ -38,14 +38,16 @@ index e69de29..0000000
+++ /dev/null
""";
setUp(() async {
tmpDir = await setupRepo(Directory('test/assets/testrepo/'));
setUp(() {
tmpDir = setupRepo(Directory('test/assets/testrepo/'));
repo = Repository.open(tmpDir.path);
oldBlobID = repo['e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'];
newBlobID = repo['9c78c21d6680a7ffebc76f7ac68cacc11d8f48bc'];
});
tearDown(() async {
tearDown(() {
repo.free();
await tmpDir.delete(recursive: true);
tmpDir.deleteSync(recursive: true);
});
group('Patch', () {
@ -90,8 +92,8 @@ index e69de29..0000000
});
test('successfully creates from blobs', () {
final a = repo[oldBlobSha] as Blob;
final b = repo[newBlobSha] as Blob;
final a = repo.lookupBlob(oldBlobID);
final b = repo.lookupBlob(newBlobID);
final patch = Patch.createFrom(
a: a,
b: b,
@ -105,7 +107,7 @@ index e69de29..0000000
});
test('successfully creates from one blob (add)', () {
final b = repo[newBlobSha] as Blob;
final b = repo.lookupBlob(newBlobID);
final patch = Patch.createFrom(
a: null,
b: b,
@ -119,7 +121,7 @@ index e69de29..0000000
});
test('successfully creates from one blob (delete)', () {
final a = repo[oldBlobSha] as Blob;
final a = repo.lookupBlob(oldBlobID);
final patch = Patch.createFrom(
a: a,
b: null,
@ -133,7 +135,7 @@ index e69de29..0000000
});
test('successfully creates from blob and buffer', () {
final a = repo[oldBlobSha] as Blob;
final a = repo.lookupBlob(oldBlobID);
final patch = Patch.createFrom(
a: a,
b: newBlob,
@ -147,7 +149,9 @@ index e69de29..0000000
});
test('throws when argument is not Blob or String', () {
final commit = repo['fc38877b2552ab554752d9a77e1f48f738cca79b'] as Commit;
final commit = repo.lookupCommit(
repo['fc38877b2552ab554752d9a77e1f48f738cca79b'],
);
expect(
() => Patch.createFrom(
a: commit,