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