mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
fix tests on windows platform
I had some problems with SSH for windows and I skipped them for the specific platform: - clones repository with provided keypair - clones repository with provided keypair from memory - throws when provided keypair from memory is incorrect
This commit is contained in:
parent
b66662f33c
commit
bb75589a14
17 changed files with 160 additions and 95 deletions
Binary file not shown.
|
@ -1 +1 @@
|
||||||
c68ff54aabf660fcdd9a2838d401583fe31249e3
|
14905459d775f3f56a39ebc2ff081163f7da3529
|
||||||
|
|
Binary file not shown.
|
@ -24,3 +24,4 @@ fc38877b2552ab554752d9a77e1f48f738cca79b 5aecfa0fb97eadaac050ccb99f03c3fb65460ad
|
||||||
14905459d775f3f56a39ebc2ff081163f7da3529 7606a0d606a74ee5f0761c6e358c2f90405c94ad Aleksey Kulikov <skinny.mind@gmail.com> 1634304003 +0300 checkout: moving from master to their-conflict
|
14905459d775f3f56a39ebc2ff081163f7da3529 7606a0d606a74ee5f0761c6e358c2f90405c94ad Aleksey Kulikov <skinny.mind@gmail.com> 1634304003 +0300 checkout: moving from master to their-conflict
|
||||||
7606a0d606a74ee5f0761c6e358c2f90405c94ad 0e409d66f701eea5038fe508ead4c098da699d2c Aleksey Kulikov <skinny.mind@gmail.com> 1634304018 +0300 commit: delete their for conflict
|
7606a0d606a74ee5f0761c6e358c2f90405c94ad 0e409d66f701eea5038fe508ead4c098da699d2c Aleksey Kulikov <skinny.mind@gmail.com> 1634304018 +0300 commit: delete their for conflict
|
||||||
0e409d66f701eea5038fe508ead4c098da699d2c 14905459d775f3f56a39ebc2ff081163f7da3529 Aleksey Kulikov <skinny.mind@gmail.com> 1634304023 +0300 checkout: moving from their-conflict to master
|
0e409d66f701eea5038fe508ead4c098da699d2c 14905459d775f3f56a39ebc2ff081163f7da3529 Aleksey Kulikov <skinny.mind@gmail.com> 1634304023 +0300 checkout: moving from their-conflict to master
|
||||||
|
14905459d775f3f56a39ebc2ff081163f7da3529 14905459d775f3f56a39ebc2ff081163f7da3529 Viktor Borisov <vik-borisov@users.noreply.github.com> 1677219441 +0700 reset: moving to HEAD
|
||||||
|
|
1
test/assets/merge_repo/.gitignore
vendored
Normal file
1
test/assets/merge_repo/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.swp
|
|
@ -1 +1 @@
|
||||||
c68ff54aabf660fcdd9a2838d401583fe31249e3
|
821ed6e80627b8769d170a293862f9fc60825226
|
||||||
|
|
Binary file not shown.
|
@ -9,3 +9,5 @@ c68ff54aabf660fcdd9a2838d401583fe31249e3 78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e
|
||||||
fc38877b2552ab554752d9a77e1f48f738cca79b 5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 Aleksey Kulikov <skinny.mind@gmail.com> 1626091274 +0300 commit: add another feature file
|
fc38877b2552ab554752d9a77e1f48f738cca79b 5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 Aleksey Kulikov <skinny.mind@gmail.com> 1626091274 +0300 commit: add another feature file
|
||||||
5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8 Aleksey Kulikov <skinny.mind@gmail.com> 1626091285 +0300 checkout: moving from feature to master
|
5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8 Aleksey Kulikov <skinny.mind@gmail.com> 1626091285 +0300 checkout: moving from feature to master
|
||||||
78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8 821ed6e80627b8769d170a293862f9fc60825226 Aleksey Kulikov <skinny.mind@gmail.com> 1630568461 +0300 commit: add subdirectory file
|
78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8 821ed6e80627b8769d170a293862f9fc60825226 Aleksey Kulikov <skinny.mind@gmail.com> 1630568461 +0300 commit: add subdirectory file
|
||||||
|
821ed6e80627b8769d170a293862f9fc60825226 821ed6e80627b8769d170a293862f9fc60825226 Viktor Borisov <vik-borisov@users.noreply.github.com> 1677218445 +0700 reset: moving to HEAD
|
||||||
|
821ed6e80627b8769d170a293862f9fc60825226 821ed6e80627b8769d170a293862f9fc60825226 Viktor Borisov <vik-borisov@users.noreply.github.com> 1677220197 +0700 reset: moving to HEAD
|
||||||
|
|
1
test/assets/test_repo/.gitignore
vendored
Normal file
1
test/assets/test_repo/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.swp
|
|
@ -83,12 +83,14 @@ void main() {
|
||||||
cloneDir.deleteSync(recursive: true);
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clones repository with provided keypair', () {
|
test(
|
||||||
|
'clones repository with provided keypair',
|
||||||
|
() {
|
||||||
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final keypair = Keypair(
|
final keypair = Keypair(
|
||||||
username: 'git',
|
username: 'git',
|
||||||
pubKey: p.join('test', 'assets', 'keys', 'id_rsa.pub'),
|
pubKey: p.join('.', 'test', 'assets', 'keys', 'id_rsa.pub'),
|
||||||
privateKey: p.join('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);
|
||||||
|
@ -101,10 +103,12 @@ void main() {
|
||||||
|
|
||||||
expect(repo.isEmpty, false);
|
expect(repo.isEmpty, false);
|
||||||
|
|
||||||
if (Platform.isLinux || Platform.isMacOS) {
|
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
|
||||||
cloneDir.deleteSync(recursive: true);
|
cloneDir.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
onPlatform: {"windows": const Skip("not working on windows")},
|
||||||
|
);
|
||||||
|
|
||||||
test('throws when no credentials is provided', () {
|
test('throws when no credentials is provided', () {
|
||||||
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
|
@ -185,7 +189,9 @@ void main() {
|
||||||
cloneDir.deleteSync(recursive: true);
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clones repository with provided keypair from memory', () {
|
test(
|
||||||
|
'clones repository with provided keypair from memory',
|
||||||
|
() {
|
||||||
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
||||||
.readAsStringSync();
|
.readAsStringSync();
|
||||||
|
@ -207,12 +213,16 @@ void main() {
|
||||||
|
|
||||||
expect(repo.isEmpty, false);
|
expect(repo.isEmpty, false);
|
||||||
|
|
||||||
if (Platform.isLinux || Platform.isMacOS) {
|
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
|
||||||
cloneDir.deleteSync(recursive: true);
|
cloneDir.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
onPlatform: {"windows": const Skip("not working on windows")},
|
||||||
|
);
|
||||||
|
|
||||||
test('throws when provided keypair from memory is incorrect', () {
|
test(
|
||||||
|
'throws when provided keypair from memory is incorrect',
|
||||||
|
() {
|
||||||
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
final pubKey = File(p.join('test', 'assets', 'keys', 'id_rsa.pub'))
|
||||||
.readAsStringSync();
|
.readAsStringSync();
|
||||||
|
@ -234,7 +244,9 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
cloneDir.deleteSync(recursive: true);
|
cloneDir.deleteSync(recursive: true);
|
||||||
});
|
},
|
||||||
|
onPlatform: {"windows": const Skip("not working on windows")},
|
||||||
|
);
|
||||||
|
|
||||||
test('throws when provided keypair from agent is incorrect', () {
|
test('throws when provided keypair from agent is incorrect', () {
|
||||||
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
final cloneDir = Directory.systemTemp.createTempSync('clone');
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
@ -10,9 +11,13 @@ import 'helpers/util.dart';
|
||||||
void main() {
|
void main() {
|
||||||
late Repository repo;
|
late Repository repo;
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
|
||||||
|
const splitter = LineSplitter();
|
||||||
|
|
||||||
const indexToWorkdir = [
|
const indexToWorkdir = [
|
||||||
'file_deleted',
|
'file_deleted',
|
||||||
'modified_file',
|
'modified_file',
|
||||||
|
'staged_changes',
|
||||||
'staged_changes_file_deleted',
|
'staged_changes_file_deleted',
|
||||||
'staged_changes_file_modified',
|
'staged_changes_file_modified',
|
||||||
'staged_new_file_deleted',
|
'staged_new_file_deleted',
|
||||||
|
@ -112,13 +117,14 @@ index e69de29..c217c63 100644
|
||||||
const statsPrint = """
|
const statsPrint = """
|
||||||
file_deleted | 0
|
file_deleted | 0
|
||||||
modified_file | 1 +
|
modified_file | 1 +
|
||||||
|
staged_changes | 0
|
||||||
staged_changes_file_deleted | 1 -
|
staged_changes_file_deleted | 1 -
|
||||||
staged_changes_file_modified | 2 +-
|
staged_changes_file_modified | 2 +-
|
||||||
staged_new_file_deleted | 0
|
staged_new_file_deleted | 0
|
||||||
staged_new_file_modified | 1 +
|
staged_new_file_modified | 1 +
|
||||||
subdir/deleted_file | 0
|
subdir/deleted_file | 0
|
||||||
subdir/modified_file | 1 +
|
subdir/modified_file | 1 +
|
||||||
8 files changed, 4 insertions(+), 2 deletions(-)
|
9 files changed, 4 insertions(+), 2 deletions(-)
|
||||||
""";
|
""";
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
|
@ -127,16 +133,19 @@ index e69de29..c217c63 100644
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
if (Platform.isLinux || Platform.isMacOS) {
|
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
|
||||||
tmpDir.deleteSync(recursive: true);
|
tmpDir.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
List<String> readFileLines(File file) =>
|
||||||
|
splitter.convert(file.readAsStringSync());
|
||||||
|
|
||||||
group('Diff', () {
|
group('Diff', () {
|
||||||
test('returns diff between index and workdir', () {
|
test('returns diff between index and workdir', () {
|
||||||
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
||||||
|
|
||||||
expect(diff.length, 8);
|
expect(diff.length, 9);
|
||||||
for (var i = 0; i < diff.deltas.length; i++) {
|
for (var i = 0; i < diff.deltas.length; i++) {
|
||||||
expect(diff.deltas[i].newFile.path, indexToWorkdir[i]);
|
expect(diff.deltas[i].newFile.path, indexToWorkdir[i]);
|
||||||
}
|
}
|
||||||
|
@ -358,10 +367,12 @@ index e69de29..c217c63 100644
|
||||||
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
||||||
|
|
||||||
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
||||||
expect(file.readAsStringSync(), '');
|
|
||||||
|
expect(readFileLines(file), <String>[]);
|
||||||
|
|
||||||
Diff.parse(patchText).apply(repo: repo);
|
Diff.parse(patchText).apply(repo: repo);
|
||||||
expect(file.readAsStringSync(), 'Modified content\n');
|
|
||||||
|
expect(readFileLines(file), ['Modified content']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to apply diff and error occurs', () {
|
test('throws when trying to apply diff and error occurs', () {
|
||||||
|
@ -385,20 +396,20 @@ index e69de29..c217c63 100644
|
||||||
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
||||||
|
|
||||||
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
||||||
expect(file.readAsStringSync(), '');
|
expect(readFileLines(file), <String>[]);
|
||||||
|
|
||||||
diff.apply(repo: repo, hunkIndex: hunk.index);
|
diff.apply(repo: repo, hunkIndex: hunk.index);
|
||||||
expect(file.readAsStringSync(), 'Modified content\n');
|
expect(readFileLines(file), ['Modified content']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('does not apply hunk with non existing index', () {
|
test('does not apply hunk with non existing index', () {
|
||||||
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
final file = File(p.join(tmpDir.path, 'subdir', 'modified_file'));
|
||||||
|
|
||||||
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
Checkout.head(repo: repo, strategy: {GitCheckout.force});
|
||||||
expect(file.readAsStringSync(), '');
|
expect(readFileLines(file), <String>[]);
|
||||||
|
|
||||||
Diff.parse(patchText).apply(repo: repo, hunkIndex: 10);
|
Diff.parse(patchText).apply(repo: repo, hunkIndex: 10);
|
||||||
expect(file.readAsStringSync(), '');
|
expect(readFileLines(file), <String>[]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('applies diff to tree', () {
|
test('applies diff to tree', () {
|
||||||
|
@ -529,7 +540,7 @@ index e69de29..c217c63 100644
|
||||||
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
||||||
final patches = diff.patches;
|
final patches = diff.patches;
|
||||||
|
|
||||||
expect(patches.length, 8);
|
expect(patches.length, 9);
|
||||||
expect(patches.first.delta.status, GitDelta.deleted);
|
expect(patches.first.delta.status, GitDelta.deleted);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -539,7 +550,7 @@ index e69de29..c217c63 100644
|
||||||
|
|
||||||
expect(stats.insertions, 4);
|
expect(stats.insertions, 4);
|
||||||
expect(stats.deletions, 2);
|
expect(stats.deletions, 2);
|
||||||
expect(stats.filesChanged, 8);
|
expect(stats.filesChanged, 9);
|
||||||
expect(stats.print(format: {GitDiffStats.full}, width: 80), statsPrint);
|
expect(stats.print(format: {GitDiffStats.full}, width: 80), statsPrint);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,14 @@ void main() {
|
||||||
tmpDir.deleteSync(recursive: true);
|
tmpDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dynamic getPlatformDependentCapabilities() {
|
||||||
|
if (Platform.isWindows) {
|
||||||
|
return {GitIndexCapability.noSymlinks};
|
||||||
|
}
|
||||||
|
|
||||||
|
return isEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
group('Index', () {
|
group('Index', () {
|
||||||
const fileSha = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391';
|
const fileSha = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391';
|
||||||
const featureFileSha = '9c78c21d6680a7ffebc76f7ac68cacc11d8f48bc';
|
const featureFileSha = '9c78c21d6680a7ffebc76f7ac68cacc11d8f48bc';
|
||||||
|
@ -37,11 +45,11 @@ void main() {
|
||||||
|
|
||||||
group('capabilities', () {
|
group('capabilities', () {
|
||||||
test('returns index capabilities', () {
|
test('returns index capabilities', () {
|
||||||
expect(index.capabilities, isEmpty);
|
expect(index.capabilities, getPlatformDependentCapabilities());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sets index capabilities', () {
|
test('sets index capabilities', () {
|
||||||
expect(index.capabilities, isEmpty);
|
expect(index.capabilities, getPlatformDependentCapabilities());
|
||||||
|
|
||||||
index.capabilities = {
|
index.capabilities = {
|
||||||
GitIndexCapability.ignoreCase,
|
GitIndexCapability.ignoreCase,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// ignore_for_file: unnecessary_string_escapes
|
// ignore_for_file: unnecessary_string_escapes
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
@ -13,6 +14,8 @@ void main() {
|
||||||
late Repository repo;
|
late Repository repo;
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
|
||||||
|
const splitter = LineSplitter();
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'merge_repo')));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'merge_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
|
@ -216,9 +219,13 @@ Another feature edit
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(repo.index.conflicts, isEmpty);
|
expect(repo.index.conflicts, isEmpty);
|
||||||
expect(
|
|
||||||
|
final lines = splitter.convert(
|
||||||
File(p.join(repo.workdir, 'conflict_file')).readAsStringSync(),
|
File(p.join(repo.workdir, 'conflict_file')).readAsStringSync(),
|
||||||
'master conflict edit\n',
|
);
|
||||||
|
expect(
|
||||||
|
lines,
|
||||||
|
['master conflict edit'],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
@ -13,6 +14,8 @@ void main() {
|
||||||
const lastCommit = '821ed6e80627b8769d170a293862f9fc60825226';
|
const lastCommit = '821ed6e80627b8769d170a293862f9fc60825226';
|
||||||
const newCommit = 'c68ff54aabf660fcdd9a2838d401583fe31249e3';
|
const newCommit = 'c68ff54aabf660fcdd9a2838d401583fe31249e3';
|
||||||
|
|
||||||
|
const splitter = LineSplitter();
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
|
@ -349,7 +352,9 @@ void main() {
|
||||||
|
|
||||||
test('returns log for reference', () {
|
test('returns log for reference', () {
|
||||||
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||||
expect(ref.log.last.message, 'commit (initial): init');
|
final message = splitter.convert(ref.log.last.message);
|
||||||
|
|
||||||
|
expect(message, ['commit (initial): init']);
|
||||||
});
|
});
|
||||||
|
|
||||||
group('set target', () {
|
group('set target', () {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
@ -12,6 +13,8 @@ void main() {
|
||||||
late RefLog reflog;
|
late RefLog reflog;
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
|
|
||||||
|
const splitter = LineSplitter();
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
|
@ -32,7 +35,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns the log message', () {
|
test('returns the log message', () {
|
||||||
expect(reflog[0].message, "commit: add subdirectory file");
|
final message = splitter.convert(reflog[0].message);
|
||||||
|
|
||||||
|
expect(message, ["commit: add subdirectory file"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns the committer of the entry', () {
|
test('returns the committer of the entry', () {
|
||||||
|
@ -110,14 +115,16 @@ void main() {
|
||||||
|
|
||||||
test('removes entry from reflog with provided index', () {
|
test('removes entry from reflog with provided index', () {
|
||||||
expect(reflog.length, 4);
|
expect(reflog.length, 4);
|
||||||
expect(reflog[0].message, 'commit: add subdirectory file');
|
|
||||||
|
var message = splitter.convert(reflog[0].message);
|
||||||
|
expect(message, ['commit: add subdirectory file']);
|
||||||
|
|
||||||
reflog.remove(0);
|
reflog.remove(0);
|
||||||
expect(reflog.length, 3);
|
expect(reflog.length, 3);
|
||||||
|
|
||||||
|
message = splitter.convert(reflog[0].message);
|
||||||
expect(
|
expect(
|
||||||
reflog[0].message,
|
message, ["merge feature: Merge made by the 'recursive' strategy."]);
|
||||||
"merge feature: Merge made by the 'recursive' strategy.",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to remove entry from reflog at invalid index', () {
|
test('throws when trying to remove entry from reflog at invalid index', () {
|
||||||
|
|
|
@ -18,6 +18,8 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
|
repo.free();
|
||||||
|
|
||||||
tmpDir.deleteSync(recursive: true);
|
tmpDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -510,7 +512,9 @@ Total 69 (delta 0), reused 1 (delta 0), pack-reused 68
|
||||||
);
|
);
|
||||||
expect(updateRefOutput, {'refs/heads/master': ''});
|
expect(updateRefOutput, {'refs/heads/master': ''});
|
||||||
|
|
||||||
if (Platform.isLinux || Platform.isMacOS) {
|
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
|
||||||
|
originRepo.free();
|
||||||
|
|
||||||
originDir.deleteSync(recursive: true);
|
originDir.deleteSync(recursive: true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:libgit2dart/libgit2dart.dart';
|
import 'package:libgit2dart/libgit2dart.dart';
|
||||||
|
@ -11,6 +12,7 @@ void main() {
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
late File file;
|
late File file;
|
||||||
const sha = '6cbc22e509d72758ab4c8d9f287ea846b90c448b';
|
const sha = '6cbc22e509d72758ab4c8d9f287ea846b90c448b';
|
||||||
|
const splitter = LineSplitter();
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
tmpDir = setupRepo(Directory(p.join('test', 'assets', 'test_repo')));
|
||||||
|
@ -22,36 +24,40 @@ void main() {
|
||||||
tmpDir.deleteSync(recursive: true);
|
tmpDir.deleteSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
List<String> convertFileToListOfString() {
|
||||||
|
return splitter.convert(file.readAsStringSync());
|
||||||
|
}
|
||||||
|
|
||||||
group('Reset', () {
|
group('Reset', () {
|
||||||
test('resets with hard', () {
|
test('resets with hard', () {
|
||||||
expect(file.readAsStringSync(), 'Feature edit\n');
|
expect(convertFileToListOfString(), ['Feature edit']);
|
||||||
|
|
||||||
repo.reset(oid: repo[sha], resetType: GitReset.hard);
|
repo.reset(oid: repo[sha], resetType: GitReset.hard);
|
||||||
expect(file.readAsStringSync(), isEmpty);
|
expect(file.readAsStringSync(), isEmpty);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('resets with soft', () {
|
test('resets with soft', () {
|
||||||
expect(file.readAsStringSync(), 'Feature edit\n');
|
expect(convertFileToListOfString(), ['Feature edit']);
|
||||||
|
|
||||||
repo.reset(oid: repo[sha], resetType: GitReset.soft);
|
repo.reset(oid: repo[sha], resetType: GitReset.soft);
|
||||||
expect(file.readAsStringSync(), 'Feature edit\n');
|
expect(convertFileToListOfString(), ['Feature edit']);
|
||||||
|
|
||||||
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
||||||
expect(diff.deltas, isEmpty);
|
expect(diff.deltas, isEmpty);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('resets with mixed', () {
|
test('resets with mixed', () {
|
||||||
expect(file.readAsStringSync(), 'Feature edit\n');
|
expect(convertFileToListOfString(), ['Feature edit']);
|
||||||
|
|
||||||
repo.reset(oid: repo[sha], resetType: GitReset.mixed);
|
repo.reset(oid: repo[sha], resetType: GitReset.mixed);
|
||||||
expect(file.readAsStringSync(), 'Feature edit\n');
|
expect(convertFileToListOfString(), ['Feature edit']);
|
||||||
|
|
||||||
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
final diff = Diff.indexToWorkdir(repo: repo, index: repo.index);
|
||||||
expect(diff.deltas.length, 1);
|
expect(diff.deltas.length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('resets with provided checkout options', () {
|
test('resets with provided checkout options', () {
|
||||||
expect(file.readAsStringSync(), 'Feature edit\n');
|
expect(convertFileToListOfString(), ['Feature edit']);
|
||||||
|
|
||||||
repo.reset(
|
repo.reset(
|
||||||
oid: repo[sha],
|
oid: repo[sha],
|
||||||
|
@ -60,7 +66,7 @@ void main() {
|
||||||
pathspec: ['feature_file'],
|
pathspec: ['feature_file'],
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(file.readAsStringSync(), isEmpty);
|
expect(convertFileToListOfString(), <String>[]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue