mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
refactor: compose paths using path package
This commit is contained in:
parent
f2e78daa42
commit
59cf7174f6
36 changed files with 225 additions and 201 deletions
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -12,7 +13,7 @@ void main() {
|
||||||
late Oid tip;
|
late Oid tip;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
tip = repo['821ed6e80627b8769d170a293862f9fc60825226'];
|
tip = repo['821ed6e80627b8769d170a293862f9fc60825226'];
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -13,7 +14,7 @@ void main() {
|
||||||
var hunks = <Map<String, Object>>[];
|
var hunks = <Map<String, Object>>[];
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/blame_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'blame_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
sig1 = Signature.create(
|
sig1 = Signature.create(
|
||||||
name: 'Aleksey Kulikov',
|
name: 'Aleksey Kulikov',
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -14,7 +15,7 @@ void main() {
|
||||||
const newBlobContent = 'New blob\n';
|
const newBlobContent = 'New blob\n';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/attributes_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'attributes_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -88,8 +89,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates new blob from file at provided path', () {
|
test('creates new blob from file at provided path', () {
|
||||||
final outsideFile =
|
final outsideFile = File(
|
||||||
File('${Directory.current.absolute.path}/test/blob_test.dart');
|
p.join(Directory.current.absolute.path, 'test', 'blob_test.dart'),
|
||||||
|
);
|
||||||
final oid = repo.createBlobFromDisk(outsideFile.path);
|
final oid = repo.createBlobFromDisk(outsideFile.path);
|
||||||
final newBlob = repo.lookupBlob(oid);
|
final newBlob = repo.lookupBlob(oid);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -13,7 +14,7 @@ void main() {
|
||||||
late Oid featureCommit;
|
late Oid featureCommit;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
lastCommit = repo['821ed6e80627b8769d170a293862f9fc60825226'];
|
lastCommit = repo['821ed6e80627b8769d170a293862f9fc60825226'];
|
||||||
featureCommit = repo['5aecfa0fb97eadaac050ccb99f03c3fb65460ad4'];
|
featureCommit = repo['5aecfa0fb97eadaac050ccb99f03c3fb65460ad4'];
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -10,7 +11,7 @@ void main() {
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ void main() {
|
||||||
test('checkouts head', () {
|
test('checkouts head', () {
|
||||||
repo.reset(oid: repo['821ed6e'], resetType: GitReset.hard);
|
repo.reset(oid: repo['821ed6e'], resetType: GitReset.hard);
|
||||||
expect(repo.status, isEmpty);
|
expect(repo.status, isEmpty);
|
||||||
File('${tmpDir.path}/feature_file').writeAsStringSync('edit');
|
File(p.join(tmpDir.path, 'feature_file')).writeAsStringSync('edit');
|
||||||
expect(repo.status, contains('feature_file'));
|
expect(repo.status, contains('feature_file'));
|
||||||
|
|
||||||
repo.checkout(
|
repo.checkout(
|
||||||
|
@ -47,7 +48,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checkouts index', () {
|
test('checkouts index', () {
|
||||||
File('${repo.workdir}feature_file').writeAsStringSync('edit');
|
File(p.join(repo.workdir, 'feature_file')).writeAsStringSync('edit');
|
||||||
expect(repo.status, contains('feature_file'));
|
expect(repo.status, contains('feature_file'));
|
||||||
|
|
||||||
repo.checkout(
|
repo.checkout(
|
||||||
|
@ -112,7 +113,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checkouts with alrenative directory', () {
|
test('checkouts with alrenative directory', () {
|
||||||
final altDir = Directory('${Directory.systemTemp.path}/alt_dir');
|
final altDir = Directory(p.join(Directory.systemTemp.path, 'alt_dir'));
|
||||||
// making sure there is no directory
|
// making sure there is no directory
|
||||||
if (altDir.existsSync()) {
|
if (altDir.existsSync()) {
|
||||||
altDir.deleteSync(recursive: true);
|
altDir.deleteSync(recursive: true);
|
||||||
|
@ -143,14 +144,15 @@ void main() {
|
||||||
test('performs dry run checkout', () {
|
test('performs dry run checkout', () {
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
expect(index.length, 4);
|
expect(index.length, 4);
|
||||||
expect(File('${repo.workdir}/another_feature_file').existsSync(), false);
|
final file = File(p.join(repo.workdir, 'another_feature_file'));
|
||||||
|
expect(file.existsSync(), false);
|
||||||
|
|
||||||
repo.checkout(
|
repo.checkout(
|
||||||
refName: 'refs/heads/feature',
|
refName: 'refs/heads/feature',
|
||||||
strategy: {GitCheckout.dryRun},
|
strategy: {GitCheckout.dryRun},
|
||||||
);
|
);
|
||||||
expect(index.length, 4);
|
expect(index.length, 4);
|
||||||
expect(File('${repo.workdir}/another_feature_file').existsSync(), false);
|
expect(file.existsSync(), false);
|
||||||
|
|
||||||
index.free();
|
index.free();
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -16,7 +17,7 @@ void main() {
|
||||||
const message = "Commit message.\n\nSome description.\n";
|
const message = "Commit message.\n\nSome description.\n";
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
author = Signature.create(
|
author = Signature.create(
|
||||||
name: 'Author Name',
|
name: 'Author Name',
|
||||||
|
@ -68,12 +69,13 @@ void main() {
|
||||||
repo['821ed6e80627b8769d170a293862f9fc60825226'],
|
repo['821ed6e80627b8769d170a293862f9fc60825226'],
|
||||||
);
|
);
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
|
final file = File(p.join(repo.workdir, 'dir', 'dir_file.txt'));
|
||||||
expect(index.find('dir/dir_file.txt'), true);
|
expect(index.find('dir/dir_file.txt'), true);
|
||||||
expect(File('${repo.workdir}dir/dir_file.txt').existsSync(), true);
|
expect(file.existsSync(), true);
|
||||||
|
|
||||||
repo.revert(commit);
|
repo.revert(commit);
|
||||||
expect(index.find('dir/dir_file.txt'), false);
|
expect(index.find('dir/dir_file.txt'), false);
|
||||||
expect(File('${repo.workdir}dir/dir_file.txt').existsSync(), false);
|
expect(file.existsSync(), false);
|
||||||
|
|
||||||
index.free();
|
index.free();
|
||||||
commit.free();
|
commit.free();
|
||||||
|
@ -91,12 +93,13 @@ void main() {
|
||||||
repo['821ed6e80627b8769d170a293862f9fc60825226'],
|
repo['821ed6e80627b8769d170a293862f9fc60825226'],
|
||||||
);
|
);
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
|
final file = File(p.join(repo.workdir, 'dir', 'dir_file.txt'));
|
||||||
expect(index.find('dir/dir_file.txt'), true);
|
expect(index.find('dir/dir_file.txt'), true);
|
||||||
expect(File('${repo.workdir}dir/dir_file.txt').existsSync(), true);
|
expect(file.existsSync(), true);
|
||||||
|
|
||||||
final revertIndex = repo.revertCommit(revertCommit: from, ourCommit: to);
|
final revertIndex = repo.revertCommit(revertCommit: from, ourCommit: to);
|
||||||
expect(revertIndex.find('dir/dir_file.txt'), false);
|
expect(revertIndex.find('dir/dir_file.txt'), false);
|
||||||
expect(File('${repo.workdir}dir/dir_file.txt').existsSync(), true);
|
expect(file.existsSync(), true);
|
||||||
|
|
||||||
revertIndex.free();
|
revertIndex.free();
|
||||||
index.free();
|
index.free();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
final tmpDir = Directory.systemTemp.path;
|
final filePath = p.join(Directory.systemTemp.path, 'test_config');
|
||||||
const configFileName = 'test_config';
|
|
||||||
const contents = '''
|
const contents = '''
|
||||||
[core]
|
[core]
|
||||||
\trepositoryformatversion = 0
|
\trepositoryformatversion = 0
|
||||||
|
@ -27,13 +27,13 @@ void main() {
|
||||||
late Config config;
|
late Config config;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
File('$tmpDir/$configFileName').writeAsStringSync(contents);
|
File(filePath).writeAsStringSync(contents);
|
||||||
config = Config.open('$tmpDir/$configFileName');
|
config = Config.open(filePath);
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
config.free();
|
config.free();
|
||||||
File('$tmpDir/$configFileName').deleteSync();
|
File(filePath).deleteSync();
|
||||||
});
|
});
|
||||||
|
|
||||||
group('Config', () {
|
group('Config', () {
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
final cloneDir = Directory('${Directory.systemTemp.path}/credentials_cloned');
|
final cloneDir = Directory(
|
||||||
|
p.join(Directory.systemTemp.path, 'credentials_cloned'),
|
||||||
|
);
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
if (cloneDir.existsSync()) {
|
if (cloneDir.existsSync()) {
|
||||||
|
@ -93,10 +96,10 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clones repository with provided keypair', () {
|
test('clones repository with provided keypair', () {
|
||||||
final keypair = const Keypair(
|
final keypair = Keypair(
|
||||||
username: 'git',
|
username: 'git',
|
||||||
pubKey: 'test/assets/keys/id_rsa.pub',
|
pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'),
|
||||||
privateKey: 'test/assets/keys/id_rsa',
|
privateKey: p.join('test', 'assets', 'keys', 'id_rsa'),
|
||||||
passPhrase: 'empty',
|
passPhrase: 'empty',
|
||||||
);
|
);
|
||||||
final callbacks = Callbacks(credentials: keypair);
|
final callbacks = Callbacks(credentials: keypair);
|
||||||
|
@ -142,9 +145,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when provided keypair is incorrect', () {
|
test('throws when provided keypair is incorrect', () {
|
||||||
final keypair = const Keypair(
|
final keypair = Keypair(
|
||||||
username: 'git',
|
username: 'git',
|
||||||
pubKey: 'test/assets/keys/id_rsa.pub',
|
pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'),
|
||||||
privateKey: 'incorrect',
|
privateKey: 'incorrect',
|
||||||
passPhrase: 'empty',
|
passPhrase: 'empty',
|
||||||
);
|
);
|
||||||
|
@ -179,8 +182,10 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clones repository with provided keypair from memory', () {
|
test('clones repository with provided keypair from memory', () {
|
||||||
final pubKey = File('test/assets/keys/id_rsa.pub').readAsStringSync();
|
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
||||||
final privateKey = File('test/assets/keys/id_rsa').readAsStringSync();
|
.readAsStringSync();
|
||||||
|
final privateKey =
|
||||||
|
File(p.join('test', 'assets', 'keys', 'id_rsa')).readAsStringSync();
|
||||||
final keypair = KeypairFromMemory(
|
final keypair = KeypairFromMemory(
|
||||||
username: 'git',
|
username: 'git',
|
||||||
pubKey: pubKey,
|
pubKey: pubKey,
|
||||||
|
@ -201,7 +206,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when provided keypair from memory is incorrect', () {
|
test('throws when provided keypair from memory is incorrect', () {
|
||||||
final pubKey = File('test/assets/keys/id_rsa.pub').readAsStringSync();
|
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
||||||
|
.readAsStringSync();
|
||||||
final keypair = KeypairFromMemory(
|
final keypair = KeypairFromMemory(
|
||||||
username: 'git',
|
username: 'git',
|
||||||
pubKey: pubKey,
|
pubKey: pubKey,
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -11,7 +12,7 @@ void main() {
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -92,7 +93,7 @@ index e69de29..c217c63 100644
|
||||||
""";
|
""";
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/dirty_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'dirty_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -318,7 +319,7 @@ index e69de29..c217c63 100644
|
||||||
|
|
||||||
test('applies diff to repository', () {
|
test('applies diff to repository', () {
|
||||||
final diff = Diff.parse(patchText);
|
final diff = Diff.parse(patchText);
|
||||||
final file = File('${tmpDir.path}/subdir/modified_file');
|
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
||||||
|
|
||||||
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
||||||
expect(file.readAsStringSync(), '');
|
expect(file.readAsStringSync(), '');
|
||||||
|
@ -348,7 +349,7 @@ index e69de29..c217c63 100644
|
||||||
test('applies hunk with provided index to repository', () {
|
test('applies hunk with provided index to repository', () {
|
||||||
final diff = Diff.parse(patchText);
|
final diff = Diff.parse(patchText);
|
||||||
final hunk = diff.patches.first.hunks.first;
|
final hunk = diff.patches.first.hunks.first;
|
||||||
final file = File('${tmpDir.path}/subdir/modified_file');
|
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
||||||
|
|
||||||
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
repo.checkout(refName: 'HEAD', strategy: {GitCheckout.force});
|
||||||
expect(file.readAsStringSync(), '');
|
expect(file.readAsStringSync(), '');
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -10,9 +11,10 @@ void main() {
|
||||||
late Repository repo;
|
late Repository repo;
|
||||||
late Index index;
|
late Index index;
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
final mergeRepoPath = p.join('test', 'assets', 'merge_repo');
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
index = repo.index;
|
index = repo.index;
|
||||||
});
|
});
|
||||||
|
@ -28,7 +30,7 @@ void main() {
|
||||||
const featureFileSha = '9c78c21d6680a7ffebc76f7ac68cacc11d8f48bc';
|
const featureFileSha = '9c78c21d6680a7ffebc76f7ac68cacc11d8f48bc';
|
||||||
|
|
||||||
test('returns full path to the index file on disk', () {
|
test('returns full path to the index file on disk', () {
|
||||||
expect(index.path, '${repo.path}index');
|
expect(index.path, p.join(repo.path, 'index'));
|
||||||
});
|
});
|
||||||
|
|
||||||
group('capabilities', () {
|
group('capabilities', () {
|
||||||
|
@ -143,7 +145,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws if index of bare repository', () {
|
test('throws if index of bare repository', () {
|
||||||
final bare = Repository.open('test/assets/empty_bare.git');
|
final bare = Repository.open(
|
||||||
|
p.join('test', 'assets', 'empty_bare.git'),
|
||||||
|
);
|
||||||
final bareIndex = bare.index;
|
final bareIndex = bare.index;
|
||||||
|
|
||||||
expect(() => bareIndex.add('config'), throwsA(isA<LibGit2Error>()));
|
expect(() => bareIndex.add('config'), throwsA(isA<LibGit2Error>()));
|
||||||
|
@ -197,7 +201,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to addAll in bare repository', () {
|
test('throws when trying to addAll in bare repository', () {
|
||||||
final bare = Repository.open('test/assets/empty_bare.git');
|
final bare = Repository.open(
|
||||||
|
p.join('test', 'assets', 'empty_bare.git'),
|
||||||
|
);
|
||||||
final bareIndex = bare.index;
|
final bareIndex = bare.index;
|
||||||
|
|
||||||
expect(() => bareIndex.addAll([]), throwsA(isA<LibGit2Error>()));
|
expect(() => bareIndex.addAll([]), throwsA(isA<LibGit2Error>()));
|
||||||
|
@ -210,8 +216,8 @@ void main() {
|
||||||
group('updateAll()', () {
|
group('updateAll()', () {
|
||||||
test('updates all entries to match working directory', () {
|
test('updates all entries to match working directory', () {
|
||||||
expect(repo.status, isEmpty);
|
expect(repo.status, isEmpty);
|
||||||
File('${repo.workdir}file').deleteSync();
|
File(p.join(repo.workdir, 'file')).deleteSync();
|
||||||
File('${repo.workdir}feature_file').deleteSync();
|
File(p.join(repo.workdir, 'feature_file')).deleteSync();
|
||||||
|
|
||||||
index.updateAll(['file', 'feature_file']);
|
index.updateAll(['file', 'feature_file']);
|
||||||
expect(repo.status, {
|
expect(repo.status, {
|
||||||
|
@ -221,7 +227,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to update all entries in bare repository', () {
|
test('throws when trying to update all entries in bare repository', () {
|
||||||
final bare = Repository.open('test/assets/empty_bare.git');
|
final bare = Repository.open(
|
||||||
|
p.join('test', 'assets', 'empty_bare.git'),
|
||||||
|
);
|
||||||
final bareIndex = bare.index;
|
final bareIndex = bare.index;
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
|
@ -237,7 +245,7 @@ void main() {
|
||||||
test('writes to disk', () {
|
test('writes to disk', () {
|
||||||
expect(index.length, 4);
|
expect(index.length, 4);
|
||||||
|
|
||||||
File('${tmpDir.path}/new_file').createSync();
|
File(p.join(tmpDir.path, 'new_file')).createSync();
|
||||||
|
|
||||||
index.add('new_file');
|
index.add('new_file');
|
||||||
index.write();
|
index.write();
|
||||||
|
@ -269,8 +277,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('removes all entries from a directory', () {
|
test('removes all entries from a directory', () {
|
||||||
Directory('${repo.workdir}subdir/').createSync();
|
final subdirPath = p.join(repo.workdir, 'subdir');
|
||||||
File('${repo.workdir}subdir/subfile').createSync();
|
Directory(subdirPath).createSync();
|
||||||
|
File(p.join(subdirPath, 'subfile')).createSync();
|
||||||
|
|
||||||
index.add('subdir/subfile');
|
index.add('subdir/subfile');
|
||||||
expect(index.length, 5);
|
expect(index.length, 5);
|
||||||
|
@ -306,7 +315,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to write tree while index have conflicts', () {
|
test('throws when trying to write tree while index have conflicts', () {
|
||||||
final tmpDir = setupRepo(Directory('test/assets/merge_repo/'));
|
final tmpDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final repo = Repository.open(tmpDir.path);
|
final repo = Repository.open(tmpDir.path);
|
||||||
|
|
||||||
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = repo.lookupBranch(name: 'conflict-branch');
|
||||||
|
@ -341,7 +350,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns conflicts with ancestor, our and their present', () {
|
test('returns conflicts with ancestor, our and their present', () {
|
||||||
final repoDir = setupRepo(Directory('test/assets/merge_repo/'));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(
|
final conflictBranch = conflictRepo.lookupBranch(
|
||||||
|
@ -371,7 +380,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns conflicts with our and their present and null ancestor', () {
|
test('returns conflicts with our and their present and null ancestor', () {
|
||||||
final repoDir = setupRepo(Directory('test/assets/merge_repo/'));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
||||||
|
@ -397,7 +406,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns conflicts with ancestor and their present and null our', () {
|
test('returns conflicts with ancestor and their present and null our', () {
|
||||||
final repoDir = setupRepo(Directory('test/assets/merge_repo/'));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(
|
final conflictBranch = conflictRepo.lookupBranch(
|
||||||
|
@ -427,7 +436,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns conflicts with ancestor and our present and null their', () {
|
test('returns conflicts with ancestor and our present and null their', () {
|
||||||
final repoDir = setupRepo(Directory('test/assets/merge_repo/'));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(name: 'their-conflict');
|
final conflictBranch = conflictRepo.lookupBranch(name: 'their-conflict');
|
||||||
|
@ -455,7 +464,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('removes conflict', () {
|
test('removes conflict', () {
|
||||||
final repoDir = setupRepo(Directory('test/assets/merge_repo/'));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
||||||
|
@ -493,7 +502,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('removes all conflicts', () {
|
test('removes all conflicts', () {
|
||||||
final repoDir = setupRepo(Directory('test/assets/merge_repo/'));
|
final repoDir = setupRepo(Directory(mergeRepoPath));
|
||||||
final conflictRepo = Repository.open(repoDir.path);
|
final conflictRepo = Repository.open(repoDir.path);
|
||||||
|
|
||||||
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
final conflictBranch = conflictRepo.lookupBranch(name: 'conflict-branch');
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -130,7 +131,7 @@ Santa Claus <santa.claus@northpole.xx> <me@company.xx>
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/mailmap_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'mailmap_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -13,7 +14,7 @@ void main() {
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/merge_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'merge_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -224,7 +225,7 @@ conflict branch edit
|
||||||
|
|
||||||
expect(index.conflicts, isEmpty);
|
expect(index.conflicts, isEmpty);
|
||||||
expect(
|
expect(
|
||||||
File('${repo.workdir}conflict_file').readAsStringSync(),
|
File(p.join(repo.workdir, 'conflict_file')).readAsStringSync(),
|
||||||
'master conflict edit\n',
|
'master conflict edit\n',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -23,7 +24,7 @@ void main() {
|
||||||
];
|
];
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to get list of notes and error occurs', () {
|
test('throws when trying to get list of notes and error occurs', () {
|
||||||
Directory('${repo.workdir}.git/refs/notes').deleteSync(recursive: true);
|
Directory(p.join(repo.path, 'refs', 'notes')).deleteSync(recursive: true);
|
||||||
expect(() => repo.notes, throwsA(isA<LibGit2Error>()));
|
expect(() => repo.notes, throwsA(isA<LibGit2Error>()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -14,7 +15,7 @@ void main() {
|
||||||
const blobContent = 'Feature edit\n';
|
const blobContent = 'Feature edit\n';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ void main() {
|
||||||
|
|
||||||
test('adds disk alternate', () {
|
test('adds disk alternate', () {
|
||||||
final odb = Odb.create();
|
final odb = Odb.create();
|
||||||
odb.addDiskAlternate('${repo.workdir}.git/objects/');
|
odb.addDiskAlternate(p.join(repo.path, 'objects'));
|
||||||
|
|
||||||
expect(odb.contains(repo[blobSha]), true);
|
expect(odb.contains(repo[blobSha]), true);
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ void main() {
|
||||||
|
|
||||||
test('throws when trying to get list of all objects and error occurs', () {
|
test('throws when trying to get list of all objects and error occurs', () {
|
||||||
final odb = repo.odb;
|
final odb = repo.odb;
|
||||||
Directory('${repo.workdir}.git/objects').deleteSync(recursive: true);
|
Directory(p.join(repo.path, 'objects')).deleteSync(recursive: true);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
() => odb.objects,
|
() => odb.objects,
|
||||||
|
@ -117,9 +118,9 @@ void main() {
|
||||||
odb.free();
|
odb.free();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to write to disk alternate odb', () {
|
test('throws when trying to write alternate odb to disk', () {
|
||||||
final odb = Odb.create();
|
final odb = Odb.create();
|
||||||
odb.addDiskAlternate('${repo.workdir}.git/objects/');
|
odb.addDiskAlternate(p.join(repo.path, 'objects'));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
() => odb.write(type: GitObject.blob, data: ''),
|
() => odb.write(type: GitObject.blob, data: ''),
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -14,7 +15,7 @@ void main() {
|
||||||
const lesserSha = '78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e7';
|
const lesserSha = '78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e7';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -9,10 +10,12 @@ import 'helpers/util.dart';
|
||||||
void main() {
|
void main() {
|
||||||
late Repository repo;
|
late Repository repo;
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
late String packDirPath;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
|
packDirPath = p.join(repo.path, 'objects', 'pack');
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
|
@ -148,7 +151,7 @@ void main() {
|
||||||
final odb = repo.odb;
|
final odb = repo.odb;
|
||||||
|
|
||||||
packbuilder.add(odb.objects[0]);
|
packbuilder.add(odb.objects[0]);
|
||||||
Directory('${repo.workdir}.git/objects/pack/').createSync();
|
Directory(packDirPath).createSync();
|
||||||
|
|
||||||
expect(packbuilder.hash.sha, '0' * 40);
|
expect(packbuilder.hash.sha, '0' * 40);
|
||||||
packbuilder.write(null);
|
packbuilder.write(null);
|
||||||
|
@ -160,7 +163,8 @@ void main() {
|
||||||
test('packs with default arguments', () {
|
test('packs with default arguments', () {
|
||||||
final odb = repo.odb;
|
final odb = repo.odb;
|
||||||
final objectsCount = odb.objects.length;
|
final objectsCount = odb.objects.length;
|
||||||
Directory('${repo.workdir}.git/objects/pack/').createSync();
|
Directory(packDirPath).createSync();
|
||||||
|
|
||||||
final writtenCount = repo.pack();
|
final writtenCount = repo.pack();
|
||||||
|
|
||||||
expect(writtenCount, objectsCount);
|
expect(writtenCount, objectsCount);
|
||||||
|
@ -171,23 +175,19 @@ void main() {
|
||||||
test('packs into provided path with threads set', () {
|
test('packs into provided path with threads set', () {
|
||||||
final odb = repo.odb;
|
final odb = repo.odb;
|
||||||
final objectsCount = odb.objects.length;
|
final objectsCount = odb.objects.length;
|
||||||
Directory('${repo.workdir}test-pack').createSync();
|
final testPackPath = p.join(repo.workdir, 'test-pack');
|
||||||
|
Directory(testPackPath).createSync();
|
||||||
|
|
||||||
|
final writtenCount = repo.pack(path: testPackPath, threads: 1);
|
||||||
|
|
||||||
final writtenCount = repo.pack(
|
|
||||||
path: '${repo.workdir}test-pack',
|
|
||||||
threads: 1,
|
|
||||||
);
|
|
||||||
expect(writtenCount, objectsCount);
|
expect(writtenCount, objectsCount);
|
||||||
expect(
|
expect(Directory(testPackPath).listSync().isNotEmpty, true);
|
||||||
Directory('${repo.workdir}test-pack').listSync().isNotEmpty,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
|
|
||||||
odb.free();
|
odb.free();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('packs with provided packDelegate', () {
|
test('packs with provided packDelegate', () {
|
||||||
Directory('${repo.workdir}.git/objects/pack/').createSync();
|
Directory(packDirPath).createSync();
|
||||||
void packDelegate(PackBuilder packBuilder) {
|
void packDelegate(PackBuilder packBuilder) {
|
||||||
final branches = repo.branchesLocal;
|
final branches = repo.branchesLocal;
|
||||||
for (final branch in branches) {
|
for (final branch in branches) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -42,7 +43,7 @@ index e69de29..0000000
|
||||||
""";
|
""";
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
oldBlobOid = repo['e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'];
|
oldBlobOid = repo['e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'];
|
||||||
newBlobOid = repo['9c78c21d6680a7ffebc76f7ac68cacc11d8f48bc'];
|
newBlobOid = repo['9c78c21d6680a7ffebc76f7ac68cacc11d8f48bc'];
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -15,7 +16,7 @@ void main() {
|
||||||
];
|
];
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/merge_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'merge_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -13,7 +14,7 @@ void main() {
|
||||||
const newCommit = 'c68ff54aabf660fcdd9a2838d401583fe31249e3';
|
const newCommit = 'c68ff54aabf660fcdd9a2838d401583fe31249e3';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -550,7 +551,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('compresses references', () {
|
test('compresses references', () {
|
||||||
final packedRefsFile = File('${tmpDir.path}/.git/packed-refs');
|
final packedRefsFile = File(p.join(tmpDir.path, '.git', 'packed-refs'));
|
||||||
expect(packedRefsFile.existsSync(), false);
|
expect(packedRefsFile.existsSync(), false);
|
||||||
final oldRefs = repo.references;
|
final oldRefs = repo.references;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -13,7 +14,7 @@ void main() {
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
head = repo.head;
|
head = repo.head;
|
||||||
reflog = RefLog(head);
|
reflog = RefLog(head);
|
||||||
|
@ -57,14 +58,11 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('renames existing reflog', () {
|
test('renames existing reflog', () {
|
||||||
expect(
|
final masterPath = p.join(repo.path, 'logs', 'refs', 'heads', 'master');
|
||||||
File('${repo.workdir}.git/logs/refs/heads/master').existsSync(),
|
final renamedPath = p.join(repo.path, 'logs', 'refs', 'heads', 'renamed');
|
||||||
true,
|
|
||||||
);
|
expect(File(masterPath).existsSync(), true);
|
||||||
expect(
|
expect(File(renamedPath).existsSync(), false);
|
||||||
File('${repo.workdir}.git/logs/refs/heads/renamed').existsSync(),
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
|
|
||||||
RefLog.rename(
|
RefLog.rename(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
|
@ -72,14 +70,8 @@ void main() {
|
||||||
newName: 'refs/heads/renamed',
|
newName: 'refs/heads/renamed',
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(File(masterPath).existsSync(), false);
|
||||||
File('${repo.workdir}.git/logs/refs/heads/master').existsSync(),
|
expect(File(renamedPath).existsSync(), true);
|
||||||
false,
|
|
||||||
);
|
|
||||||
expect(
|
|
||||||
File('${repo.workdir}.git/logs/refs/heads/renamed').existsSync(),
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to rename reflog and provided new name is invalid',
|
test('throws when trying to rename reflog and provided new name is invalid',
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -10,10 +11,10 @@ void main() {
|
||||||
late Repository clonedRepo;
|
late Repository clonedRepo;
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
late Remote remote;
|
late Remote remote;
|
||||||
final cloneDir = Directory('${Directory.systemTemp.path}/cloned');
|
final cloneDir = Directory(p.join(Directory.systemTemp.path, 'cloned'));
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
if (cloneDir.existsSync()) {
|
if (cloneDir.existsSync()) {
|
||||||
cloneDir.deleteSync(recursive: true);
|
cloneDir.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -12,7 +13,7 @@ void main() {
|
||||||
const remoteUrl = 'git://github.com/SkinnyMind/libgit2dart.git';
|
const remoteUrl = 'git://github.com/SkinnyMind/libgit2dart.git';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -518,14 +519,14 @@ Total 69 (delta 0), reused 1 (delta 0), pack-reused 68
|
||||||
|
|
||||||
test('pushes with update reference callback', () {
|
test('pushes with update reference callback', () {
|
||||||
final originDir =
|
final originDir =
|
||||||
Directory('${Directory.systemTemp.path}/origin_testrepo');
|
Directory(p.join(Directory.systemTemp.path, 'origin_testrepo'));
|
||||||
|
|
||||||
if (originDir.existsSync()) {
|
if (originDir.existsSync()) {
|
||||||
originDir.deleteSync(recursive: true);
|
originDir.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
originDir.createSync();
|
originDir.createSync();
|
||||||
copyRepo(
|
copyRepo(
|
||||||
from: Directory('test/assets/empty_bare.git/'),
|
from: Directory(p.join('test', 'assets', 'empty_bare.git')),
|
||||||
to: originDir,
|
to: originDir,
|
||||||
);
|
);
|
||||||
final originRepo = Repository.open(originDir.path);
|
final originRepo = Repository.open(originDir.path);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -10,10 +11,10 @@ import 'helpers/util.dart';
|
||||||
void main() {
|
void main() {
|
||||||
late Repository repo;
|
late Repository repo;
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
final cloneDir = Directory('${Directory.systemTemp.path}/cloned');
|
final cloneDir = Directory(p.join(Directory.systemTemp.path, 'cloned'));
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
if (cloneDir.existsSync()) {
|
if (cloneDir.existsSync()) {
|
||||||
cloneDir.delete(recursive: true);
|
cloneDir.delete(recursive: true);
|
||||||
|
@ -102,8 +103,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clones repository with provided repository callback', () {
|
test('clones repository with provided repository callback', () {
|
||||||
final callbackPath =
|
final callbackPath = Directory(
|
||||||
Directory('${Directory.systemTemp.path}/callbackRepo');
|
p.join(Directory.systemTemp.path, 'callbackRepo'),
|
||||||
|
);
|
||||||
if (callbackPath.existsSync()) {
|
if (callbackPath.existsSync()) {
|
||||||
callbackPath.deleteSync(recursive: true);
|
callbackPath.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +122,7 @@ void main() {
|
||||||
|
|
||||||
expect(clonedRepo.isEmpty, false);
|
expect(clonedRepo.isEmpty, false);
|
||||||
expect(clonedRepo.isBare, false);
|
expect(clonedRepo.isBare, false);
|
||||||
expect(clonedRepo.path, contains('/callbackRepo/.git/'));
|
expect(clonedRepo.path, contains(p.join('callbackRepo', '.git')));
|
||||||
|
|
||||||
clonedRepo.free();
|
clonedRepo.free();
|
||||||
callbackPath.deleteSync(recursive: true);
|
callbackPath.deleteSync(recursive: true);
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
late Repository repo;
|
late Repository repo;
|
||||||
|
final barePath = p.join('test', 'assets', 'empty_bare.git');
|
||||||
|
final standardPath = p.join('test', 'assets', 'empty_standard', '.gitdir');
|
||||||
|
|
||||||
group('Repository.open', () {
|
group('Repository.open', () {
|
||||||
test("throws when repository isn't found at provided path", () {
|
test("throws when repository isn't found at provided path", () {
|
||||||
|
@ -16,7 +19,7 @@ void main() {
|
||||||
|
|
||||||
group('empty bare', () {
|
group('empty bare', () {
|
||||||
setUp(() {
|
setUp(() {
|
||||||
repo = Repository.open('test/assets/empty_bare.git');
|
repo = Repository.open(barePath);
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
|
@ -32,11 +35,11 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns path to the repository', () {
|
test('returns path to the repository', () {
|
||||||
expect(repo.path, contains('/test/assets/empty_bare.git/'));
|
expect(repo.path, contains(barePath));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns path to root directory for the repository', () {
|
test('returns path to root directory for the repository', () {
|
||||||
expect(repo.commonDir, contains('/test/assets/empty_bare.git/'));
|
expect(repo.commonDir, contains(barePath));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns empty string as path of the working directory', () {
|
test('returns empty string as path of the working directory', () {
|
||||||
|
@ -46,7 +49,7 @@ void main() {
|
||||||
|
|
||||||
group('empty standard', () {
|
group('empty standard', () {
|
||||||
setUp(() {
|
setUp(() {
|
||||||
repo = Repository.open('test/assets/empty_standard/.gitdir/');
|
repo = Repository.open(standardPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
|
@ -58,14 +61,11 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns path to the repository', () {
|
test('returns path to the repository', () {
|
||||||
expect(repo.path, contains('/test/assets/empty_standard/.gitdir/'));
|
expect(repo.path, contains(standardPath));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("returns path to parent repo's .git folder for the repository", () {
|
test("returns path to parent repo's .git folder for the repository", () {
|
||||||
expect(
|
expect(repo.commonDir, contains(standardPath));
|
||||||
repo.commonDir,
|
|
||||||
contains('/test/assets/empty_standard/.gitdir/'),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('checks if it is empty', () {
|
test('checks if it is empty', () {
|
||||||
|
@ -103,7 +103,10 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns path to working directory', () {
|
test('returns path to working directory', () {
|
||||||
expect(repo.workdir, contains('/test/assets/empty_standard/'));
|
expect(
|
||||||
|
repo.workdir,
|
||||||
|
contains(p.join('test', 'assets', 'empty_standard')),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
late Repository repo;
|
late Repository repo;
|
||||||
final initDir = Directory('${Directory.systemTemp.path}/init_repo');
|
final initDir = Directory(p.join(Directory.systemTemp.path, 'init_repo'));
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
if (initDir.existsSync()) {
|
if (initDir.existsSync()) {
|
||||||
|
@ -23,14 +24,14 @@ void main() {
|
||||||
test('creates new bare repo at provided path', () {
|
test('creates new bare repo at provided path', () {
|
||||||
repo = Repository.init(path: initDir.path, bare: true);
|
repo = Repository.init(path: initDir.path, bare: true);
|
||||||
|
|
||||||
expect(repo.path, contains('init_repo/'));
|
expect(repo.path, contains('init_repo'));
|
||||||
expect(repo.isBare, true);
|
expect(repo.isBare, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates new standard repo at provided path', () {
|
test('creates new standard repo at provided path', () {
|
||||||
repo = Repository.init(path: initDir.path);
|
repo = Repository.init(path: initDir.path);
|
||||||
|
|
||||||
expect(repo.path, contains('init_repo/.git/'));
|
expect(repo.path, contains(p.join('init_repo', '.git')));
|
||||||
expect(repo.isBare, false);
|
expect(repo.isBare, false);
|
||||||
expect(repo.isEmpty, true);
|
expect(repo.isEmpty, true);
|
||||||
});
|
});
|
||||||
|
@ -43,11 +44,11 @@ void main() {
|
||||||
flags: {GitRepositoryInit.mkdir, GitRepositoryInit.mkpath},
|
flags: {GitRepositoryInit.mkdir, GitRepositoryInit.mkpath},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(repo.path, contains('init_repo/.git/'));
|
expect(repo.path, contains(p.join('init_repo', '.git')));
|
||||||
expect(repo.isBare, false);
|
expect(repo.isBare, false);
|
||||||
expect(repo.isEmpty, true);
|
expect(repo.isEmpty, true);
|
||||||
expect(
|
expect(
|
||||||
File('${repo.workdir}.git/description').readAsStringSync(),
|
File(p.join(repo.path, 'description')).readAsStringSync(),
|
||||||
'test repo',
|
'test repo',
|
||||||
);
|
);
|
||||||
expect(repo.lookupRemote('origin').url, 'test.url');
|
expect(repo.lookupRemote('origin').url, 'test.url');
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -13,7 +14,7 @@ void main() {
|
||||||
const featureCommit = '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4';
|
const featureCommit = '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ void main() {
|
||||||
|
|
||||||
group('.discover()', () {
|
group('.discover()', () {
|
||||||
test('discovers repository', () async {
|
test('discovers repository', () async {
|
||||||
final subDir = '${tmpDir.path}/subdir1/subdir2/';
|
final subDir = p.join(tmpDir.path, 'subdir1', 'subdir2');
|
||||||
await Directory(subDir).create(recursive: true);
|
await Directory(subDir).create(recursive: true);
|
||||||
expect(Repository.discover(startPath: subDir), repo.path);
|
expect(Repository.discover(startPath: subDir), repo.path);
|
||||||
});
|
});
|
||||||
|
@ -87,11 +88,13 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sets working directory', () {
|
test('sets working directory', () {
|
||||||
final tmpWorkDir = Directory('${Directory.systemTemp.path}/tmp_work_dir');
|
final tmpWorkDir = Directory(
|
||||||
|
p.join(Directory.systemTemp.path, 'tmp_work_dir'),
|
||||||
|
);
|
||||||
tmpWorkDir.createSync();
|
tmpWorkDir.createSync();
|
||||||
|
|
||||||
repo.setWorkdir(path: tmpWorkDir.path);
|
repo.setWorkdir(path: tmpWorkDir.path);
|
||||||
expect(repo.workdir, contains('/tmp_work_dir/'));
|
expect(repo.workdir, contains('tmp_work_dir'));
|
||||||
|
|
||||||
tmpWorkDir.deleteSync();
|
tmpWorkDir.deleteSync();
|
||||||
});
|
});
|
||||||
|
@ -104,14 +107,14 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to get head and error occurs', () {
|
test('throws when trying to get head and error occurs', () {
|
||||||
File('${repo.workdir}.git/HEAD').deleteSync();
|
File(p.join(repo.path, 'HEAD')).deleteSync();
|
||||||
expect(() => repo.head, throwsA(isA<LibGit2Error>()));
|
expect(() => repo.head, throwsA(isA<LibGit2Error>()));
|
||||||
expect(() => repo.isHeadDetached, throwsA(isA<LibGit2Error>()));
|
expect(() => repo.isHeadDetached, throwsA(isA<LibGit2Error>()));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to check if branch is unborn and error occurs',
|
test('throws when trying to check if branch is unborn and error occurs',
|
||||||
() {
|
() {
|
||||||
File('${repo.workdir}.git/HEAD').deleteSync();
|
File(p.join(repo.path, 'HEAD')).deleteSync();
|
||||||
expect(() => repo.isBranchUnborn, throwsA(isA<LibGit2Error>()));
|
expect(() => repo.isBranchUnborn, throwsA(isA<LibGit2Error>()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -181,8 +184,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates new blob from file at provided path', () {
|
test('creates new blob from file at provided path', () {
|
||||||
final outsideFile =
|
final outsideFile = File(
|
||||||
File('${Directory.current.absolute.path}/test/blob_test.dart');
|
p.join(Directory.current.absolute.path, 'test', 'blob_test.dart'),
|
||||||
|
);
|
||||||
final oid = repo.createBlobFromDisk(outsideFile.path);
|
final oid = repo.createBlobFromDisk(outsideFile.path);
|
||||||
final newBlob = repo.lookupBlob(oid);
|
final newBlob = repo.lookupBlob(oid);
|
||||||
|
|
||||||
|
@ -226,7 +230,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns status of a repository', () {
|
test('returns status of a repository', () {
|
||||||
File('${tmpDir.path}/new_file.txt').createSync();
|
File(p.join(tmpDir.path, 'new_file.txt')).createSync();
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
index.remove('file');
|
index.remove('file');
|
||||||
index.add('new_file.txt');
|
index.add('new_file.txt');
|
||||||
|
@ -242,7 +246,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to get status of bare repository', () {
|
test('throws when trying to get status of bare repository', () {
|
||||||
final bare = Repository.open('test/assets/empty_bare.git');
|
final bare = Repository.open(p.join('test', 'assets', 'empty_bare.git'));
|
||||||
|
|
||||||
expect(() => bare.status, throwsA(isA<LibGit2Error>()));
|
expect(() => bare.status, throwsA(isA<LibGit2Error>()));
|
||||||
|
|
||||||
|
@ -297,14 +301,14 @@ void main() {
|
||||||
config.free();
|
config.free();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns attribute value', () async {
|
test('returns attribute value', () {
|
||||||
expect(repo.getAttribute(path: 'invalid', name: 'not-there'), null);
|
expect(repo.getAttribute(path: 'invalid', name: 'not-there'), null);
|
||||||
|
|
||||||
final attrFile = await File('${repo.workdir}.gitattributes').create();
|
File(p.join(repo.workdir, '.gitattributes'))
|
||||||
await attrFile.writeAsString('*.dart text\n*.jpg -text\n*.sh eol=lf\n');
|
.writeAsStringSync('*.dart text\n*.jpg -text\n*.sh eol=lf\n');
|
||||||
|
|
||||||
await File('${repo.workdir}file.dart').create();
|
File(p.join(repo.workdir, 'file.dart')).createSync();
|
||||||
await File('${repo.workdir}file.sh').create();
|
File(p.join(repo.workdir, 'file.sh')).createSync();
|
||||||
|
|
||||||
expect(repo.getAttribute(path: 'file.dart', name: 'not-there'), null);
|
expect(repo.getAttribute(path: 'file.dart', name: 'not-there'), null);
|
||||||
expect(repo.getAttribute(path: 'file.dart', name: 'text'), true);
|
expect(repo.getAttribute(path: 'file.dart', name: 'text'), true);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -12,8 +13,8 @@ void main() {
|
||||||
const sha = '6cbc22e509d72758ab4c8d9f287ea846b90c448b';
|
const sha = '6cbc22e509d72758ab4c8d9f287ea846b90c448b';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
file = File('${tmpDir.path}/feature_file');
|
file = File(p.join(tmpDir.path, 'feature_file'));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -12,7 +13,7 @@ void main() {
|
||||||
const parentSHA = '78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8';
|
const parentSHA = '78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -18,7 +19,7 @@ void main() {
|
||||||
];
|
];
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -10,10 +11,12 @@ void main() {
|
||||||
late Repository repo;
|
late Repository repo;
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
late Signature stasher;
|
late Signature stasher;
|
||||||
|
late String filePath;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
|
filePath = p.join(repo.workdir, 'file');
|
||||||
stasher = Signature.create(
|
stasher = Signature.create(
|
||||||
name: 'Stasher',
|
name: 'Stasher',
|
||||||
email: 'stasher@email.com',
|
email: 'stasher@email.com',
|
||||||
|
@ -28,10 +31,7 @@ void main() {
|
||||||
|
|
||||||
group('Stash', () {
|
group('Stash', () {
|
||||||
test('saves changes to stash', () {
|
test('saves changes to stash', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
|
|
||||||
repo.createStash(stasher: stasher);
|
repo.createStash(stasher: stasher);
|
||||||
expect(repo.status.isEmpty, true);
|
expect(repo.status.isEmpty, true);
|
||||||
|
@ -45,7 +45,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('saves changes to stash including ignored', () {
|
test('saves changes to stash including ignored', () {
|
||||||
final swpPath = File('${tmpDir.path}/some.swp');
|
final swpPath = File(p.join(repo.workdir, 'some.swp'));
|
||||||
swpPath.writeAsStringSync('ignored');
|
swpPath.writeAsStringSync('ignored');
|
||||||
|
|
||||||
repo.createStash(
|
repo.createStash(
|
||||||
|
@ -60,10 +60,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('leaves changes added to index intact', () {
|
test('leaves changes added to index intact', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
index.add('file');
|
index.add('file');
|
||||||
|
|
||||||
|
@ -75,10 +72,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('applies changes from stash', () {
|
test('applies changes from stash', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
|
|
||||||
repo.createStash(stasher: stasher);
|
repo.createStash(stasher: stasher);
|
||||||
expect(repo.status.isEmpty, true);
|
expect(repo.status.isEmpty, true);
|
||||||
|
@ -88,10 +82,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('applies changes from stash with paths provided', () {
|
test('applies changes from stash with paths provided', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
|
|
||||||
repo.createStash(stasher: stasher);
|
repo.createStash(stasher: stasher);
|
||||||
expect(repo.status.isEmpty, true);
|
expect(repo.status.isEmpty, true);
|
||||||
|
@ -101,7 +92,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('applies changes from stash including index changes', () {
|
test('applies changes from stash including index changes', () {
|
||||||
File('${tmpDir.path}/stash.this').writeAsStringSync('stash');
|
File(p.join(repo.workdir, 'stash.this')).writeAsStringSync('stash');
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
index.add('stash.this');
|
index.add('stash.this');
|
||||||
expect(index.find('stash.this'), true);
|
expect(index.find('stash.this'), true);
|
||||||
|
@ -118,10 +109,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to apply with wrong index', () {
|
test('throws when trying to apply with wrong index', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
|
|
||||||
repo.createStash(stasher: stasher);
|
repo.createStash(stasher: stasher);
|
||||||
|
|
||||||
|
@ -129,22 +117,17 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('drops stash', () {
|
test('drops stash', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
|
|
||||||
repo.createStash(stasher: stasher);
|
repo.createStash(stasher: stasher);
|
||||||
final stash = repo.stashes.first;
|
final stash = repo.stashes.first;
|
||||||
repo.dropStash(index: stash.index);
|
repo.dropStash(index: stash.index);
|
||||||
|
|
||||||
expect(() => repo.applyStash(), throwsA(isA<LibGit2Error>()));
|
expect(() => repo.applyStash(), throwsA(isA<LibGit2Error>()));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to drop with wrong index', () {
|
test('throws when trying to drop with wrong index', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
|
|
||||||
repo.createStash(stasher: stasher);
|
repo.createStash(stasher: stasher);
|
||||||
|
|
||||||
|
@ -152,31 +135,27 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('pops from stash', () {
|
test('pops from stash', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
|
|
||||||
repo.createStash(stasher: stasher);
|
repo.createStash(stasher: stasher);
|
||||||
repo.popStash();
|
repo.popStash();
|
||||||
|
|
||||||
expect(repo.status, contains('file'));
|
expect(repo.status, contains('file'));
|
||||||
expect(() => repo.applyStash(), throwsA(isA<LibGit2Error>()));
|
expect(() => repo.applyStash(), throwsA(isA<LibGit2Error>()));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('pops from stash with provided path', () {
|
test('pops from stash with provided path', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
|
|
||||||
repo.createStash(stasher: stasher);
|
repo.createStash(stasher: stasher);
|
||||||
repo.popStash(paths: ['file']);
|
repo.popStash(paths: ['file']);
|
||||||
|
|
||||||
expect(repo.status, contains('file'));
|
expect(repo.status, contains('file'));
|
||||||
expect(() => repo.applyStash(), throwsA(isA<LibGit2Error>()));
|
expect(() => repo.applyStash(), throwsA(isA<LibGit2Error>()));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('pops from stash including index changes', () {
|
test('pops from stash including index changes', () {
|
||||||
File('${tmpDir.path}/stash.this').writeAsStringSync('stash');
|
File(p.join(repo.workdir, 'stash.this')).writeAsStringSync('stash');
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
index.add('stash.this');
|
index.add('stash.this');
|
||||||
expect(index.find('stash.this'), true);
|
expect(index.find('stash.this'), true);
|
||||||
|
@ -193,10 +172,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to pop with wrong index', () {
|
test('throws when trying to pop with wrong index', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
|
|
||||||
repo.createStash(stasher: stasher);
|
repo.createStash(stasher: stasher);
|
||||||
|
|
||||||
|
@ -204,10 +180,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns list of stashes', () {
|
test('returns list of stashes', () {
|
||||||
File('${tmpDir.path}/file').writeAsStringSync(
|
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||||
'edit',
|
|
||||||
mode: FileMode.append,
|
|
||||||
);
|
|
||||||
|
|
||||||
repo.createStash(stasher: stasher, message: 'WIP');
|
repo.createStash(stasher: stasher, message: 'WIP');
|
||||||
|
|
||||||
|
@ -219,8 +192,10 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns string representation of Stash object', () {
|
test('returns string representation of Stash object', () {
|
||||||
File('${tmpDir.path}/stash.this').writeAsStringSync('stash');
|
File(p.join(repo.workdir, 'stash.this')).writeAsStringSync('stash');
|
||||||
|
|
||||||
repo.createStash(stasher: stasher, flags: {GitStash.includeUntracked});
|
repo.createStash(stasher: stasher, flags: {GitStash.includeUntracked});
|
||||||
|
|
||||||
expect(repo.stashes[0].toString(), contains('Stash{'));
|
expect(repo.stashes[0].toString(), contains('Stash{'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -14,7 +15,7 @@ void main() {
|
||||||
const submoduleHeadSha = '49322bb17d3acc9146f98c97d078513228bbf3c0';
|
const submoduleHeadSha = '49322bb17d3acc9146f98c97d078513228bbf3c0';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/submodule_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'submodule_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -58,7 +59,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('inits and updates', () {
|
test('inits and updates', () {
|
||||||
final submoduleFilePath = '${repo.workdir}$testSubmodule/master.txt';
|
final submoduleFilePath =
|
||||||
|
p.join(repo.workdir, testSubmodule, 'master.txt');
|
||||||
expect(File(submoduleFilePath).existsSync(), false);
|
expect(File(submoduleFilePath).existsSync(), false);
|
||||||
|
|
||||||
repo.initSubmodule(submodule: testSubmodule);
|
repo.initSubmodule(submodule: testSubmodule);
|
||||||
|
@ -68,7 +70,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('updates with provided init flag', () {
|
test('updates with provided init flag', () {
|
||||||
final submoduleFilePath = '${repo.workdir}$testSubmodule/master.txt';
|
final submoduleFilePath =
|
||||||
|
p.join(repo.workdir, testSubmodule, 'master.txt');
|
||||||
expect(File(submoduleFilePath).existsSync(), false);
|
expect(File(submoduleFilePath).existsSync(), false);
|
||||||
|
|
||||||
repo.updateSubmodule(submodule: testSubmodule, init: true);
|
repo.updateSubmodule(submodule: testSubmodule, init: true);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -13,7 +14,7 @@ void main() {
|
||||||
late Oid tagOid;
|
late Oid tagOid;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
tagOid = repo['f0fdbf506397e9f58c59b88dfdd72778ec06cc0c'];
|
tagOid = repo['f0fdbf506397e9f58c59b88dfdd72778ec06cc0c'];
|
||||||
tag = repo.lookupTag(tagOid);
|
tag = repo.lookupTag(tagOid);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -12,7 +13,7 @@ void main() {
|
||||||
const fileSHA = '1377554ebea6f98a2c748183bc5a96852af12ac2';
|
const fileSHA = '1377554ebea6f98a2c748183bc5a96852af12ac2';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
tree = repo.lookupTree(
|
tree = repo.lookupTree(
|
||||||
repo['a8ae3dd59e6e1802c6f78e05e301bfd57c9f334f'],
|
repo['a8ae3dd59e6e1802c6f78e05e301bfd57c9f334f'],
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -12,7 +13,7 @@ void main() {
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
tree = repo.lookupTree(repo['a8ae3dd59e6e1802c6f78e05e301bfd57c9f334f']);
|
tree = repo.lookupTree(repo['a8ae3dd59e6e1802c6f78e05e301bfd57c9f334f']);
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'helpers/util.dart';
|
import 'helpers/util.dart';
|
||||||
|
@ -9,14 +10,14 @@ import 'helpers/util.dart';
|
||||||
void main() {
|
void main() {
|
||||||
late Repository repo;
|
late Repository repo;
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
final worktreeDir = Directory('${Directory.systemTemp.path}/worktree');
|
final worktreeDir = Directory(p.join(Directory.systemTemp.path, 'worktree'));
|
||||||
const worktreeName = 'worktree';
|
const worktreeName = 'worktree';
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
if (worktreeDir.existsSync()) {
|
if (worktreeDir.existsSync()) {
|
||||||
worktreeDir.deleteSync(recursive: true);
|
worktreeDir.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
tmpDir = setupRepo(Directory('test/assets/test_repo/'));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -41,10 +42,10 @@ void main() {
|
||||||
expect(repo.worktrees, [worktreeName]);
|
expect(repo.worktrees, [worktreeName]);
|
||||||
expect(branches.any((branch) => branch.name == worktreeName), true);
|
expect(branches.any((branch) => branch.name == worktreeName), true);
|
||||||
expect(worktree.name, worktreeName);
|
expect(worktree.name, worktreeName);
|
||||||
expect(worktree.path, contains('/worktree'));
|
expect(worktree.path, contains('worktree'));
|
||||||
expect(worktree.isLocked, false);
|
expect(worktree.isLocked, false);
|
||||||
expect(worktree.toString(), contains('Worktree{'));
|
expect(worktree.toString(), contains('Worktree{'));
|
||||||
expect(File('${worktreeDir.path}/.git').existsSync(), true);
|
expect(File(p.join(worktreeDir.path, '.git')).existsSync(), true);
|
||||||
|
|
||||||
for (final branch in branches) {
|
for (final branch in branches) {
|
||||||
branch.free();
|
branch.free();
|
||||||
|
@ -111,7 +112,7 @@ void main() {
|
||||||
final lookedupWorktree = repo.lookupWorktree(worktreeName);
|
final lookedupWorktree = repo.lookupWorktree(worktreeName);
|
||||||
|
|
||||||
expect(lookedupWorktree.name, worktreeName);
|
expect(lookedupWorktree.name, worktreeName);
|
||||||
expect(lookedupWorktree.path, contains('/worktree'));
|
expect(lookedupWorktree.path, contains('worktree'));
|
||||||
expect(lookedupWorktree.isLocked, false);
|
expect(lookedupWorktree.isLocked, false);
|
||||||
|
|
||||||
lookedupWorktree.free();
|
lookedupWorktree.free();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue