test: improve coverage

This commit is contained in:
Aleksey Kulikov 2021-10-15 17:37:38 +03:00
parent d75acbfdd3
commit d6eae1e9ed
71 changed files with 710 additions and 229 deletions

View file

@ -21,7 +21,16 @@ Pointer<git_diff> indexToWorkdir({
interhunkLines: interhunkLines, interhunkLines: interhunkLines,
); );
libgit2.git_diff_index_to_workdir(out, repoPointer, indexPointer, opts); final error = libgit2.git_diff_index_to_workdir(
out,
repoPointer,
indexPointer,
opts,
);
if (error < 0) {
throw LibGit2Error(libgit2.git_error_last());
}
calloc.free(opts); calloc.free(opts);
@ -46,7 +55,7 @@ Pointer<git_diff> treeToIndex({
interhunkLines: interhunkLines, interhunkLines: interhunkLines,
); );
libgit2.git_diff_tree_to_index( final error = libgit2.git_diff_tree_to_index(
out, out,
repoPointer, repoPointer,
treePointer, treePointer,
@ -54,6 +63,10 @@ Pointer<git_diff> treeToIndex({
opts, opts,
); );
if (error < 0) {
throw LibGit2Error(libgit2.git_error_last());
}
calloc.free(opts); calloc.free(opts);
return out.value; return out.value;
@ -76,7 +89,16 @@ Pointer<git_diff> treeToWorkdir({
interhunkLines: interhunkLines, interhunkLines: interhunkLines,
); );
libgit2.git_diff_tree_to_workdir(out, repoPointer, treePointer, opts); final error = libgit2.git_diff_tree_to_workdir(
out,
repoPointer,
treePointer,
opts,
);
if (error < 0) {
throw LibGit2Error(libgit2.git_error_last());
}
calloc.free(opts); calloc.free(opts);
@ -101,7 +123,7 @@ Pointer<git_diff> treeToTree({
interhunkLines: interhunkLines, interhunkLines: interhunkLines,
); );
libgit2.git_diff_tree_to_tree( final error = libgit2.git_diff_tree_to_tree(
out, out,
repoPointer, repoPointer,
oldTreePointer, oldTreePointer,
@ -109,6 +131,10 @@ Pointer<git_diff> treeToTree({
opts, opts,
); );
if (error < 0) {
throw LibGit2Error(libgit2.git_error_last());
}
calloc.free(opts); calloc.free(opts);
return out.value; return out.value;
@ -351,15 +377,18 @@ Pointer<git_diff_options> _diffOptionsInit({
required int interhunkLines, required int interhunkLines,
}) { }) {
final opts = calloc<git_diff_options>(); final opts = calloc<git_diff_options>();
final optsError = final optsError = libgit2.git_diff_options_init(
libgit2.git_diff_options_init(opts, GIT_DIFF_OPTIONS_VERSION); opts,
GIT_DIFF_OPTIONS_VERSION,
);
if (optsError < 0) {
calloc.free(opts);
throw LibGit2Error(libgit2.git_error_last());
} else {
opts.ref.flags = flags; opts.ref.flags = flags;
opts.ref.context_lines = contextLines; opts.ref.context_lines = contextLines;
opts.ref.interhunk_lines = interhunkLines; opts.ref.interhunk_lines = interhunkLines;
if (optsError < 0) {
throw LibGit2Error(libgit2.git_error_last());
} else {
return opts; return opts;
} }
} }

View file

@ -120,16 +120,16 @@ void merge({
String mergeFileFromIndex({ String mergeFileFromIndex({
required Pointer<git_repository> repoPointer, required Pointer<git_repository> repoPointer,
required Pointer<git_index_entry>? ancestorPointer, required Pointer<git_index_entry>? ancestorPointer,
required Pointer<git_index_entry>? oursPointer, required Pointer<git_index_entry> oursPointer,
required Pointer<git_index_entry>? theirsPointer, required Pointer<git_index_entry> theirsPointer,
}) { }) {
final out = calloc<git_merge_file_result>(); final out = calloc<git_merge_file_result>();
final error = libgit2.git_merge_file_from_index( final error = libgit2.git_merge_file_from_index(
out, out,
repoPointer, repoPointer,
ancestorPointer ?? nullptr, ancestorPointer ?? nullptr,
oursPointer ?? nullptr, oursPointer,
theirsPointer ?? nullptr, theirsPointer,
nullptr, nullptr,
); );

View file

@ -235,6 +235,8 @@ bool isTag(Pointer<git_reference> ref) {
/// ///
/// The message for the reflog will be ignored if the reference does not belong in the /// The message for the reflog will be ignored if the reference does not belong in the
/// standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog. /// standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog.
///
/// Throws a [LibGit2Error] if error occured.
Pointer<git_reference> createDirect({ Pointer<git_reference> createDirect({
required Pointer<git_repository> repoPointer, required Pointer<git_repository> repoPointer,
required String name, required String name,
@ -288,6 +290,8 @@ Pointer<git_reference> createDirect({
/// ///
/// The message for the reflog will be ignored if the reference does not belong in the standard /// The message for the reflog will be ignored if the reference does not belong in the standard
/// set (HEAD, branches and remote-tracking branches) and it does not have a reflog. /// set (HEAD, branches and remote-tracking branches) and it does not have a reflog.
///
/// Throws a [LibGit2Error] if error occured.
Pointer<git_reference> createSymbolic({ Pointer<git_reference> createSymbolic({
required Pointer<git_repository> repoPointer, required Pointer<git_repository> repoPointer,
required String name, required String name,

View file

@ -73,7 +73,7 @@ Pointer<git_tree_entry> getByName({
/// Retrieve a tree entry contained in a tree or in any of its subtrees, given its relative path. /// Retrieve a tree entry contained in a tree or in any of its subtrees, given its relative path.
/// ///
/// Unlike the other lookup functions, the returned tree entry is owned by the user and must be /// Unlike the other lookup functions, the returned tree entry is owned by the user and must be
/// freed explicitly with `entryFree()`. /// freed explicitly with [entryFree].
/// ///
/// Throws a [LibGit2Error] if error occured. /// Throws a [LibGit2Error] if error occured.
Pointer<git_tree_entry> getByPath({ Pointer<git_tree_entry> getByPath({
@ -122,7 +122,7 @@ int compare({
/// Free a user-owned tree entry. /// Free a user-owned tree entry.
/// ///
/// IMPORTANT: This function is only needed for tree entries owned by the user, /// IMPORTANT: This function is only needed for tree entries owned by the user,
/// such as `getByPath()`. /// such as [getByPath].
void entryFree(Pointer<git_tree_entry> entry) => void entryFree(Pointer<git_tree_entry> entry) =>
libgit2.git_tree_entry_free(entry); libgit2.git_tree_entry_free(entry);

View file

@ -6,10 +6,6 @@ import 'bindings/libgit2_bindings.dart';
import 'bindings/blame.dart' as bindings; import 'bindings/blame.dart' as bindings;
class Blame with IterableMixin<BlameHunk> { class Blame with IterableMixin<BlameHunk> {
/// Initializes a new instance of the [Blame] class from
/// provided pointer to blame object in memory.
Blame(this._blamePointer);
/// Initializes a new instance of the [Blame] class by getting /// Initializes a new instance of the [Blame] class by getting
/// the blame for a single file. /// the blame for a single file.
/// ///

View file

@ -78,6 +78,9 @@ class KeypairFromAgent implements Credentials {
@override @override
GitCredential get credentialType => GitCredential.sshKey; GitCredential get credentialType => GitCredential.sshKey;
@override
String toString() => 'KeypairFromAgent{username: $username}';
} }
/// Ssh key credential used for reading the keys from memory. /// Ssh key credential used for reading the keys from memory.
@ -106,7 +109,7 @@ class KeypairFromMemory implements Credentials {
@override @override
String toString() { String toString() {
return 'KeypairFromAgent{username: $username, pubKey: $pubKey, privateKey: $privateKey, ' return 'KeypairFromMemory{username: $username, pubKey: $pubKey, privateKey: $privateKey, '
'passPhrase: $passPhrase}'; 'passPhrase: $passPhrase}';
} }
} }

View file

@ -2,12 +2,14 @@ import 'dart:ffi';
import 'package:ffi/ffi.dart'; import 'package:ffi/ffi.dart';
import 'bindings/libgit2_bindings.dart'; import 'bindings/libgit2_bindings.dart';
/// Details of the last error that occurred.
class LibGit2Error { class LibGit2Error {
LibGit2Error(this.errorPointer); LibGit2Error(this._errorPointer);
final Pointer<git_error> errorPointer;
final Pointer<git_error> _errorPointer;
@override @override
String toString() { String toString() {
return errorPointer.ref.message.cast<Utf8>().toDartString(); return _errorPointer.ref.message.cast<Utf8>().toDartString();
} }
} }

View file

@ -67,9 +67,7 @@ class Index with IterableMixin<IndexEntry> {
? their = null ? their = null
: their = IndexEntry(entry['their']!); : their = IndexEntry(entry['their']!);
if (ancestor != null) { if (our != null) {
path = ancestor.path;
} else if (our != null) {
path = our.path; path = our.path;
} else { } else {
path = their!.path; path = their!.path;

View file

@ -5,10 +5,6 @@ import 'bindings/mailmap.dart' as bindings;
import 'util.dart'; import 'util.dart';
class Mailmap { class Mailmap {
/// Initializes a new instance of [Mailmap] class from provided
/// pointer to mailmap object in memory.
Mailmap(this._mailmapPointer);
/// Initializes a new instance of [Mailmap] class. /// Initializes a new instance of [Mailmap] class.
/// ///
/// This object is empty, so you'll have to add a mailmap file before you can /// This object is empty, so you'll have to add a mailmap file before you can
@ -49,10 +45,8 @@ class Mailmap {
_mailmapPointer = bindings.fromRepository(repo.pointer); _mailmapPointer = bindings.fromRepository(repo.pointer);
} }
late final Pointer<git_mailmap> _mailmapPointer;
/// Pointer to memory address for allocated mailmap object. /// Pointer to memory address for allocated mailmap object.
Pointer<git_mailmap> get pointer => _mailmapPointer; late final Pointer<git_mailmap> _mailmapPointer;
/// Returns list containing resolved [name] and [email] to the corresponding real name /// Returns list containing resolved [name] and [email] to the corresponding real name
/// and real email respectively. /// and real email respectively.

View file

@ -79,8 +79,8 @@ class Oid {
1); 1);
} }
@override @override // coverage:ignore-line
int get hashCode => _oidPointer.address.hashCode; int get hashCode => _oidPointer.address.hashCode; // coverage:ignore-line
@override @override
String toString() => 'Oid{sha: $sha}'; String toString() => 'Oid{sha: $sha}';

View file

@ -13,10 +13,8 @@ class PackBuilder {
_packbuilderPointer = bindings.init(repo.pointer); _packbuilderPointer = bindings.init(repo.pointer);
} }
late final Pointer<git_packbuilder> _packbuilderPointer;
/// Pointer to memory address for allocated packbuilder object. /// Pointer to memory address for allocated packbuilder object.
Pointer<git_packbuilder> get pointer => _packbuilderPointer; late final Pointer<git_packbuilder> _packbuilderPointer;
/// Adds a single object. /// Adds a single object.
/// ///

View file

@ -1,5 +1,4 @@
import 'dart:ffi'; import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'package:libgit2dart/libgit2dart.dart'; import 'package:libgit2dart/libgit2dart.dart';
import 'bindings/libgit2_bindings.dart'; import 'bindings/libgit2_bindings.dart';
import 'bindings/rebase.dart' as bindings; import 'bindings/rebase.dart' as bindings;
@ -80,7 +79,7 @@ class Rebase {
} }
/// Commits the current patch. You must have resolved any conflicts that were /// Commits the current patch. You must have resolved any conflicts that were
/// introduced during the patch application from the `next()` invocation. /// introduced during the patch application from the [next] invocation.
/// ///
/// Throws a [LibGit2Error] if error occured. /// Throws a [LibGit2Error] if error occured.
void commit({ void commit({
@ -126,18 +125,9 @@ class RebaseOperation {
); );
} }
/// Returns the commit [Oid] being cherry-picked. This will be populated for /// Returns the commit [Oid] being cherry-picked.
/// all operations except those of type [GitRebaseOperation.exec].
Oid get oid => Oid.fromRaw(_rebaseOperationPointer.ref.id); Oid get oid => Oid.fromRaw(_rebaseOperationPointer.ref.id);
/// The executable the user has requested be run. This will only
/// be populated for operations of type [GitRebaseOperation.exec].
String get exec {
return _rebaseOperationPointer.ref.exec == nullptr
? ''
: _rebaseOperationPointer.ref.exec.cast<Utf8>().toDartString();
}
@override @override
String toString() => 'RebaseOperation{type: $type, oid: $oid}'; String toString() => 'RebaseOperation{type: $type, oid: $oid}';
} }

View file

@ -5,7 +5,6 @@ import 'bindings/reference.dart' as bindings;
import 'bindings/object.dart' as object_bindings; import 'bindings/object.dart' as object_bindings;
import 'bindings/refdb.dart' as refdb_bindings; import 'bindings/refdb.dart' as refdb_bindings;
import 'bindings/repository.dart' as repository_bindings; import 'bindings/repository.dart' as repository_bindings;
import 'util.dart';
class Reference { class Reference {
/// Initializes a new instance of the [Reference] class. /// Initializes a new instance of the [Reference] class.
@ -30,6 +29,9 @@ class Reference {
/// ///
/// The [logMessage] message for the reflog will be ignored if the reference does not belong in the /// The [logMessage] message for the reflog will be ignored if the reference does not belong in the
/// standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog. /// standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog.
///
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided [target]
/// is not Oid or String reference name.
Reference.create({ Reference.create({
required Repository repo, required Repository repo,
required String name, required String name,
@ -37,35 +39,25 @@ class Reference {
bool force = false, bool force = false,
String? logMessage, String? logMessage,
}) { }) {
late final Oid oid;
late final bool isDirect;
if (target is Oid) { if (target is Oid) {
oid = target;
isDirect = true;
} else if (isValidShaHex(target as String)) {
oid = Oid.fromSHA(repo: repo, sha: target);
isDirect = true;
} else {
isDirect = false;
}
if (isDirect) {
_refPointer = bindings.createDirect( _refPointer = bindings.createDirect(
repoPointer: repo.pointer, repoPointer: repo.pointer,
name: name, name: name,
oidPointer: oid.pointer, oidPointer: target.pointer,
force: force,
logMessage: logMessage,
);
} else if (target is String) {
_refPointer = bindings.createSymbolic(
repoPointer: repo.pointer,
name: name,
target: target,
force: force, force: force,
logMessage: logMessage, logMessage: logMessage,
); );
} else { } else {
_refPointer = bindings.createSymbolic( throw ArgumentError.value(
repoPointer: repo.pointer, '$target must be either Oid or String reference name');
name: name,
target: target as String,
force: force,
logMessage: logMessage,
);
} }
} }
@ -275,8 +267,8 @@ class Reference {
/// Releases memory allocated for reference object. /// Releases memory allocated for reference object.
void free() => bindings.free(_refPointer); void free() => bindings.free(_refPointer);
@override @override // coverage:ignore-line
int get hashCode => _refPointer.address.hashCode; int get hashCode => _refPointer.address.hashCode; // coverage:ignore-line
@override @override
String toString() { String toString() {

View file

@ -50,7 +50,7 @@ class RefLogEntry {
Signature get committer => Signature(bindings.entryCommiter(_entryPointer)); Signature get committer => Signature(bindings.entryCommiter(_entryPointer));
@override @override
String toString() => 'ReflogEntry{message: $message, committer: $committer}'; String toString() => 'RefLogEntry{message: $message, committer: $committer}';
} }
class _RefLogIterator implements Iterator<RefLogEntry> { class _RefLogIterator implements Iterator<RefLogEntry> {

View file

@ -4,10 +4,6 @@ import 'bindings/libgit2_bindings.dart';
import 'bindings/remote.dart' as bindings; import 'bindings/remote.dart' as bindings;
class Remote { class Remote {
/// Initializes a new instance of [Remote] class from provided pointer
/// to remote object in memory.
Remote(this._remotePointer);
/// Initializes a new instance of [Remote] class by looking up remote with /// Initializes a new instance of [Remote] class by looking up remote with
/// provided [name] in a [repo]sitory. /// provided [name] in a [repo]sitory.
/// ///

View file

@ -375,6 +375,9 @@ class Repository {
/// ///
/// The [logMessage] message for the reflog will be ignored if the reference does not belong in the /// The [logMessage] message for the reflog will be ignored if the reference does not belong in the
/// standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog. /// standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog.
///
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided [target]
/// is not Oid or String reference name.
Reference createReference({ Reference createReference({
required String name, required String name,
required Object target, required Object target,
@ -838,14 +841,14 @@ class Repository {
/// Throws a [LibGit2Error] if error occured. /// Throws a [LibGit2Error] if error occured.
String mergeFileFromIndex({ String mergeFileFromIndex({
required IndexEntry? ancestor, required IndexEntry? ancestor,
required IndexEntry? ours, required IndexEntry ours,
required IndexEntry? theirs, required IndexEntry theirs,
}) { }) {
return merge_bindings.mergeFileFromIndex( return merge_bindings.mergeFileFromIndex(
repoPointer: _repoPointer, repoPointer: _repoPointer,
ancestorPointer: ancestor?.pointer, ancestorPointer: ancestor?.pointer,
oursPointer: ours?.pointer, oursPointer: ours.pointer,
theirsPointer: theirs?.pointer, theirsPointer: theirs.pointer,
); );
} }
@ -1435,7 +1438,7 @@ class Repository {
bool? alwaysUseLongFormat, bool? alwaysUseLongFormat,
String? dirtySuffix, String? dirtySuffix,
}) { }) {
late final Pointer<git_describe_result> describeResult; Pointer<git_describe_result> describeResult = nullptr;
if (commit != null) { if (commit != null) {
describeResult = describe_bindings.commit( describeResult = describe_bindings.commit(

View file

@ -78,8 +78,9 @@ class Signature {
/// Releases memory allocated for signature object. /// Releases memory allocated for signature object.
void free() => bindings.free(_signaturePointer); void free() => bindings.free(_signaturePointer);
@override @override // coverage:ignore-line
int get hashCode => _signaturePointer.address.hashCode; int get hashCode =>
_signaturePointer.address.hashCode; // coverage:ignore-line
@override @override
String toString() { String toString() {

View file

@ -4,10 +4,6 @@ import 'bindings/libgit2_bindings.dart';
import 'bindings/submodule.dart' as bindings; import 'bindings/submodule.dart' as bindings;
class Submodule { class Submodule {
/// Initializes a new instance of [Submodule] class from provided
/// pointer to submodule object in memory.
Submodule(this._submodulePointer);
/// Initializes a new instance of [Submodule] class by looking up /// Initializes a new instance of [Submodule] class by looking up
/// submodule information by name or path. /// submodule information by name or path.
/// ///
@ -53,10 +49,8 @@ class Submodule {
bindings.addFinalize(_submodulePointer); bindings.addFinalize(_submodulePointer);
} }
late final Pointer<git_submodule> _submodulePointer;
/// Pointer to memory address for allocated submodule object. /// Pointer to memory address for allocated submodule object.
Pointer<git_submodule> get pointer => _submodulePointer; late final Pointer<git_submodule> _submodulePointer;
/// Copies submodule info into ".git/config" file. /// Copies submodule info into ".git/config" file.
/// ///

View file

@ -21,10 +21,8 @@ class Tag {
); );
} }
late final Pointer<git_tag> _tagPointer;
/// Pointer to memory address for allocated tag object. /// Pointer to memory address for allocated tag object.
Pointer<git_tag> get pointer => _tagPointer; late final Pointer<git_tag> _tagPointer;
/// Creates a new tag in the repository for provided [target] object. /// Creates a new tag in the repository for provided [target] object.
/// ///

View file

@ -40,7 +40,7 @@ class Tree {
return result; return result;
} }
/// Looksup a tree entry in the tree. /// Lookups a tree entry in the tree.
/// ///
/// If integer [value] is provided, lookup is done by entry position in the tree. /// If integer [value] is provided, lookup is done by entry position in the tree.
/// ///
@ -158,53 +158,9 @@ class TreeEntry {
return GitFilemode.values.singleWhere((mode) => modeInt == mode.value); return GitFilemode.values.singleWhere((mode) => modeInt == mode.value);
} }
@override
bool operator ==(other) {
return (other is TreeEntry) &&
(bindings.compare(
aPointer: _treeEntryPointer,
bPointer: other._treeEntryPointer) ==
0);
}
bool operator <(other) {
return (other is TreeEntry) &&
(bindings.compare(
aPointer: _treeEntryPointer,
bPointer: other._treeEntryPointer) ==
-1);
}
bool operator <=(other) {
return (other is TreeEntry) &&
(bindings.compare(
aPointer: _treeEntryPointer,
bPointer: other._treeEntryPointer) ==
-1);
}
bool operator >(other) {
return (other is TreeEntry) &&
(bindings.compare(
aPointer: _treeEntryPointer,
bPointer: other._treeEntryPointer) ==
1);
}
bool operator >=(other) {
return (other is TreeEntry) &&
(bindings.compare(
aPointer: _treeEntryPointer,
bPointer: other._treeEntryPointer) ==
1);
}
/// Releases memory allocated for tree entry object. /// Releases memory allocated for tree entry object.
void free() => bindings.entryFree(_treeEntryPointer); void free() => bindings.entryFree(_treeEntryPointer);
@override
int get hashCode => _treeEntryPointer.address.hashCode;
@override @override
String toString() => 'TreeEntry{oid: $oid, name: $name, filemode: $filemode}'; String toString() => 'TreeEntry{oid: $oid, name: $name, filemode: $filemode}';
} }

View file

@ -17,10 +17,8 @@ class TreeBuilder {
); );
} }
late final Pointer<git_treebuilder> _treeBuilderPointer;
/// Pointer to memory address for allocated tree builder object. /// Pointer to memory address for allocated tree builder object.
Pointer<git_treebuilder> get pointer => _treeBuilderPointer; late final Pointer<git_treebuilder> _treeBuilderPointer;
/// Returns the number of entries listed in a tree builder. /// Returns the number of entries listed in a tree builder.
int get length => bindings.entryCount(_treeBuilderPointer); int get length => bindings.entryCount(_treeBuilderPointer);

View file

@ -7,14 +7,14 @@ DynamicLibrary loadLibrary() {
return DynamicLibrary.open( return DynamicLibrary.open(
'${Directory.current.path}/libgit2/libgit2.so.1.3.0'); '${Directory.current.path}/libgit2/libgit2.so.1.3.0');
} }
if (Platform.isMacOS) { // if (Platform.isMacOS) {
return DynamicLibrary.open( // return DynamicLibrary.open(
'${Directory.current.path}/libgit2/libgit2-1.2.0.dylib'); // '${Directory.current.path}/libgit2/libgit2-1.2.0.dylib');
} // }
if (Platform.isWindows) { // if (Platform.isWindows) {
return DynamicLibrary.open( // return DynamicLibrary.open(
'${Directory.current.path}/libgit2/libgit2-1.2.0.dll'); // '${Directory.current.path}/libgit2/libgit2-1.2.0.dll');
} // }
throw Exception('Platform not implemented'); throw Exception('Platform not implemented');
} }

View file

@ -1 +1 @@
master conflict commit delete their for conflict

Binary file not shown.

View file

@ -13,3 +13,14 @@ fc38877b2552ab554752d9a77e1f48f738cca79b 5aecfa0fb97eadaac050ccb99f03c3fb65460ad
821ed6e80627b8769d170a293862f9fc60825226 47af50e6a799d7d0dde6630d2644f9484fb670f7 Aleksey Kulikov <skinny.mind@gmail.com> 1631172155 +0300 commit: conflict branch commit 821ed6e80627b8769d170a293862f9fc60825226 47af50e6a799d7d0dde6630d2644f9484fb670f7 Aleksey Kulikov <skinny.mind@gmail.com> 1631172155 +0300 commit: conflict branch commit
47af50e6a799d7d0dde6630d2644f9484fb670f7 821ed6e80627b8769d170a293862f9fc60825226 Aleksey Kulikov <skinny.mind@gmail.com> 1631172159 +0300 checkout: moving from conflict-branch to master 47af50e6a799d7d0dde6630d2644f9484fb670f7 821ed6e80627b8769d170a293862f9fc60825226 Aleksey Kulikov <skinny.mind@gmail.com> 1631172159 +0300 checkout: moving from conflict-branch to master
821ed6e80627b8769d170a293862f9fc60825226 14905459d775f3f56a39ebc2ff081163f7da3529 Aleksey Kulikov <skinny.mind@gmail.com> 1631172175 +0300 commit: master conflict commit 821ed6e80627b8769d170a293862f9fc60825226 14905459d775f3f56a39ebc2ff081163f7da3529 Aleksey Kulikov <skinny.mind@gmail.com> 1631172175 +0300 commit: master conflict commit
14905459d775f3f56a39ebc2ff081163f7da3529 5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 Aleksey Kulikov <skinny.mind@gmail.com> 1634223805 +0300 checkout: moving from master to ancestor-conflict
5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 7606a0d606a74ee5f0761c6e358c2f90405c94ad Aleksey Kulikov <skinny.mind@gmail.com> 1634223835 +0300 commit: conflict with ancestor
7606a0d606a74ee5f0761c6e358c2f90405c94ad 5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 Aleksey Kulikov <skinny.mind@gmail.com> 1634223845 +0300 checkout: moving from ancestor-conflict to feature
5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 2ee89b2f7124b8e4632bc6a20774a90b795245e4 Aleksey Kulikov <skinny.mind@gmail.com> 1634223881 +0300 commit: conflict with ancestor
2ee89b2f7124b8e4632bc6a20774a90b795245e4 14905459d775f3f56a39ebc2ff081163f7da3529 Aleksey Kulikov <skinny.mind@gmail.com> 1634225232 +0300 checkout: moving from feature to master
14905459d775f3f56a39ebc2ff081163f7da3529 2ee89b2f7124b8e4632bc6a20774a90b795245e4 Aleksey Kulikov <skinny.mind@gmail.com> 1634303915 +0300 checkout: moving from master to our-conflict
2ee89b2f7124b8e4632bc6a20774a90b795245e4 0db17b23a1acd67d5e44650d61aac7d4d83ec193 Aleksey Kulikov <skinny.mind@gmail.com> 1634303926 +0300 commit: delete our for conflict
0db17b23a1acd67d5e44650d61aac7d4d83ec193 14905459d775f3f56a39ebc2ff081163f7da3529 Aleksey Kulikov <skinny.mind@gmail.com> 1634303933 +0300 checkout: moving from our-conflict to master
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
0e409d66f701eea5038fe508ead4c098da699d2c 14905459d775f3f56a39ebc2ff081163f7da3529 Aleksey Kulikov <skinny.mind@gmail.com> 1634304023 +0300 checkout: moving from their-conflict to master

View file

@ -0,0 +1,2 @@
0000000000000000000000000000000000000000 5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 Aleksey Kulikov <skinny.mind@gmail.com> 1634223805 +0300 branch: Created from 5aecfa0
5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 7606a0d606a74ee5f0761c6e358c2f90405c94ad Aleksey Kulikov <skinny.mind@gmail.com> 1634223835 +0300 commit: conflict with ancestor

View file

@ -2,3 +2,4 @@
f17d0d48eae3aa08cecf29128a35e310c97b3521 6cbc22e509d72758ab4c8d9f287ea846b90c448b Aleksey Kulikov <skinny.mind@gmail.com> 1626091020 +0300 commit: add feature file f17d0d48eae3aa08cecf29128a35e310c97b3521 6cbc22e509d72758ab4c8d9f287ea846b90c448b Aleksey Kulikov <skinny.mind@gmail.com> 1626091020 +0300 commit: add feature file
6cbc22e509d72758ab4c8d9f287ea846b90c448b fc38877b2552ab554752d9a77e1f48f738cca79b Aleksey Kulikov <skinny.mind@gmail.com> 1626091054 +0300 commit: edit feature file 6cbc22e509d72758ab4c8d9f287ea846b90c448b fc38877b2552ab554752d9a77e1f48f738cca79b Aleksey Kulikov <skinny.mind@gmail.com> 1626091054 +0300 commit: edit feature file
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 2ee89b2f7124b8e4632bc6a20774a90b795245e4 Aleksey Kulikov <skinny.mind@gmail.com> 1634223881 +0300 commit: conflict with ancestor

View file

@ -0,0 +1,2 @@
0000000000000000000000000000000000000000 2ee89b2f7124b8e4632bc6a20774a90b795245e4 Aleksey Kulikov <skinny.mind@gmail.com> 1634303915 +0300 branch: Created from 2ee89b2
2ee89b2f7124b8e4632bc6a20774a90b795245e4 0db17b23a1acd67d5e44650d61aac7d4d83ec193 Aleksey Kulikov <skinny.mind@gmail.com> 1634303926 +0300 commit: delete our for conflict

View file

@ -0,0 +1,2 @@
0000000000000000000000000000000000000000 7606a0d606a74ee5f0761c6e358c2f90405c94ad Aleksey Kulikov <skinny.mind@gmail.com> 1634304003 +0300 branch: Created from 7606a0d
7606a0d606a74ee5f0761c6e358c2f90405c94ad 0e409d66f701eea5038fe508ead4c098da699d2c Aleksey Kulikov <skinny.mind@gmail.com> 1634304018 +0300 commit: delete their for conflict

View file

@ -0,0 +1,2 @@
xĄŽKj1łÖ)z0úKĆ$ëśBęî‰ĹčcĆrŔ·Ďř ŢÔâA=
GkevúcîĚ@¬˛ÖŮť<>Í6ć@hbÎʸÄZ¦Ś~!˘(niç>!x铤<17>ev« ^ˇgă"ęuV:\l"ó:vř®ĽÝů ?ŹZ¶ńçűVzžZéôőŰR©'íĘk[Eř”FJq¬Gčä7.qĺÉ0Ż\vXŹ}­§ř˛

View file

@ -0,0 +1 @@
7606a0d606a74ee5f0761c6e358c2f90405c94ad

View file

@ -1 +1 @@
5aecfa0fb97eadaac050ccb99f03c3fb65460ad4 2ee89b2f7124b8e4632bc6a20774a90b795245e4

View file

@ -0,0 +1 @@
0db17b23a1acd67d5e44650d61aac7d4d83ec193

View file

@ -0,0 +1 @@
0e409d66f701eea5038fe508ead4c098da699d2c

View file

@ -142,5 +142,11 @@ void main() {
blame.free(); blame.free();
}); });
test('returns string representation of BlameHunk object', () {
final blame = repo.blame(path: 'feature_file');
expect(blame.toString(), contains('BlameHunk{'));
blame.free();
});
}); });
} }

View file

@ -63,7 +63,13 @@ void main() {
test('throws when creating new blob from invalid path', () { test('throws when creating new blob from invalid path', () {
expect( expect(
() => repo.createBlobFromWorkdir('invalid/path.txt'), () => repo.createBlobFromWorkdir('invalid/path.txt'),
throwsA(isA<LibGit2Error>()), throwsA(
isA<LibGit2Error>().having(
(e) => e.toString(),
'message',
"could not find '${repo.workdir}invalid/path.txt' to stat: No such file or directory",
),
),
); );
}); });
@ -128,10 +134,10 @@ index e69de29..0000000
}); });
test('successfully creates from one blob (delete)', () { test('successfully creates from one blob (delete)', () {
final a = repo.lookupBlob( final _blob = repo.lookupBlob(
repo['e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'], repo['e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'],
); );
final patch = a.diff( final patch = _blob.diff(
newBlob: null, newBlob: null,
oldAsPath: path, oldAsPath: path,
newAsPath: path, newAsPath: path,
@ -143,16 +149,14 @@ index e69de29..0000000
}); });
test('successfully creates from blob and buffer', () { test('successfully creates from blob and buffer', () {
final a = repo.lookupBlob( final _blob = repo.lookupBlob(
repo['e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'], repo['e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'],
); );
final patch = Patch.create(
a: a,
b: 'Feature edit\n',
aPath: path,
bPath: path,
);
final patch = _blob.diffToBuffer(
buffer: 'Feature edit\n',
oldAsPath: path,
);
expect(patch.text, blobPatch); expect(patch.text, blobPatch);
patch.free(); patch.free();
@ -174,5 +178,9 @@ index e69de29..0000000
patch.free(); patch.free();
}); });
}); });
test('returns string representation of Blob object', () {
expect(blob.toString(), contains('Blob{'));
});
}); });
} }

View file

@ -186,5 +186,11 @@ void main() {
); );
}); });
}); });
test('returns string representation of Branch object', () {
final branch = repo.lookupBranch('master');
expect(branch.toString(), contains('Branch{'));
branch.free();
});
}); });
} }

View file

@ -147,5 +147,11 @@ void main() {
parent2.free(); parent2.free();
commit.free(); commit.free();
}); });
test('returns string representation of Commit object', () {
final commit = repo.lookupCommit(mergeCommit);
expect(commit.toString(), contains('Commit{'));
commit.free();
});
}); });
} }

View file

@ -23,6 +23,7 @@ void main() {
expect(credentials, isA<Credentials>()); expect(credentials, isA<Credentials>());
expect(credentials.username, 'user'); expect(credentials.username, 'user');
expect(credentials.credentialType, GitCredential.username); expect(credentials.credentialType, GitCredential.username);
expect(credentials.toString(), contains('Username{'));
}); });
test('successfully initializes username/password credentials', () { test('successfully initializes username/password credentials', () {
@ -35,6 +36,7 @@ void main() {
expect(credentials.username, 'user'); expect(credentials.username, 'user');
expect(credentials.password, 'password'); expect(credentials.password, 'password');
expect(credentials.credentialType, GitCredential.userPassPlainText); expect(credentials.credentialType, GitCredential.userPassPlainText);
expect(credentials.toString(), contains('UserPass{'));
}); });
test('successfully initializes keypair credentials', () { test('successfully initializes keypair credentials', () {
@ -51,6 +53,7 @@ void main() {
expect(credentials.privateKey, 'id_rsa'); expect(credentials.privateKey, 'id_rsa');
expect(credentials.passPhrase, 'passphrase'); expect(credentials.passPhrase, 'passphrase');
expect(credentials.credentialType, GitCredential.sshKey); expect(credentials.credentialType, GitCredential.sshKey);
expect(credentials.toString(), contains('Keypair{'));
}); });
test('successfully initializes keypair from memory credentials', () { test('successfully initializes keypair from memory credentials', () {
@ -67,6 +70,7 @@ void main() {
expect(credentials.privateKey, 'private key data'); expect(credentials.privateKey, 'private key data');
expect(credentials.passPhrase, 'passphrase'); expect(credentials.passPhrase, 'passphrase');
expect(credentials.credentialType, GitCredential.sshMemory); expect(credentials.credentialType, GitCredential.sshMemory);
expect(credentials.toString(), contains('KeypairFromMemory{'));
}); });
test('successfully initializes keypair from agent credentials', () { test('successfully initializes keypair from agent credentials', () {
@ -75,6 +79,7 @@ void main() {
expect(credentials, isA<Credentials>()); expect(credentials, isA<Credentials>());
expect(credentials.username, 'user'); expect(credentials.username, 'user');
expect(credentials.credentialType, GitCredential.sshKey); expect(credentials.credentialType, GitCredential.sshKey);
expect(credentials.toString(), contains('KeypairFromAgent{'));
}); });
test('sucessfully clones repository with provided keypair', () { test('sucessfully clones repository with provided keypair', () {

View file

@ -131,5 +131,14 @@ void main() {
index.free(); index.free();
}); });
test('successfully describes with max candidates tags flag set', () {
final index = repo.index;
index.clear();
expect(repo.describe(maxCandidatesTags: 0), 'v0.2');
index.free();
});
}); });
} }

View file

@ -103,17 +103,24 @@ index e69de29..c217c63 100644
final head = repo.head; final head = repo.head;
final commit = repo.lookupCommit(head.target); final commit = repo.lookupCommit(head.target);
final tree = commit.tree; final tree = commit.tree;
final diff = index.diffToTree(tree: tree); final diff1 = index.diffToTree(tree: tree);
final diff2 = tree.diffToIndex(index: index);
expect(diff.length, 8); expect(diff1.length, 8);
for (var i = 0; i < diff.deltas.length; i++) { for (var i = 0; i < diff1.deltas.length; i++) {
expect(diff.deltas[i].newFile.path, indexToTree[i]); expect(diff1.deltas[i].newFile.path, indexToTree[i]);
}
expect(diff2.length, 8);
for (var i = 0; i < diff2.deltas.length; i++) {
expect(diff2.deltas[i].newFile.path, indexToTree[i]);
} }
commit.free(); commit.free();
head.free(); head.free();
tree.free(); tree.free();
diff.free(); diff1.free();
diff2.free();
index.free(); index.free();
}); });
@ -157,9 +164,7 @@ index e69de29..c217c63 100644
final head = repo.head; final head = repo.head;
final commit = repo.lookupCommit(head.target); final commit = repo.lookupCommit(head.target);
final tree1 = commit.tree; final tree1 = commit.tree;
final tree2 = repo.lookupTree( final tree2 = repo.lookupTree(repo['b85d53c']);
repo['b85d53c9236e89aff2b62558adaa885fd1d6ff1c'],
);
final diff = repo.diff(a: tree1, b: tree2); final diff = repo.diff(a: tree1, b: tree2);
expect(diff.length, 10); expect(diff.length, 10);
@ -174,6 +179,12 @@ index e69de29..c217c63 100644
diff.free(); diff.free();
}); });
test('throws when trying to diff between null and tree', () {
final tree = repo.lookupTree(repo['b85d53c']);
expect(() => repo.diff(a: null, b: tree), throwsA(isA<ArgumentError>()));
tree.free();
});
test('successfully merges diffs', () { test('successfully merges diffs', () {
final head = repo.head; final head = repo.head;
final commit = repo.lookupCommit(head.target); final commit = repo.lookupCommit(head.target);
@ -377,5 +388,24 @@ index e69de29..c217c63 100644
patch.free(); patch.free();
diff.free(); diff.free();
}); });
test(
'returns string representation of Diff, DiffDelta, DiffFile, '
'DiffHunk, DiffLine and DiffStats objects', () {
final diff = Diff.parse(patchText);
final patch = Patch.fromDiff(diff: diff, index: 0);
final stats = diff.stats;
expect(diff.toString(), contains('Diff{'));
expect(patch.delta.toString(), contains('DiffDelta{'));
expect(patch.delta.oldFile.toString(), contains('DiffFile{'));
expect(patch.hunks[0].toString(), contains('DiffHunk{'));
expect(patch.hunks[0].lines[0].toString(), contains('DiffLine{'));
expect(stats.toString(), contains('DiffStats{'));
stats.free();
patch.free();
diff.free();
});
}); });
} }

View file

@ -1,9 +1,8 @@
import 'dart:io'; import 'dart:io';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
final tmpDir = Directory.systemTemp.createTempSync('testrepo');
Directory setupRepo(Directory repoDir) { Directory setupRepo(Directory repoDir) {
final tmpDir = Directory.systemTemp.createTempSync('testrepo');
if (tmpDir.existsSync()) { if (tmpDir.existsSync()) {
tmpDir.deleteSync(recursive: true); tmpDir.deleteSync(recursive: true);
} }

View file

@ -29,7 +29,9 @@ void main() {
}); });
test('returns mode of index entry', () { test('returns mode of index entry', () {
expect(index['file'].mode, GitFilemode.blob); for (final entry in index) {
expect(entry.mode, GitFilemode.blob);
}
}); });
test('returns index entry at provided position', () { test('returns index entry at provided position', () {
@ -174,5 +176,104 @@ void main() {
final oid = index.writeTree(); final oid = index.writeTree();
expect(oid.sha, 'a8ae3dd59e6e1802c6f78e05e301bfd57c9f334f'); expect(oid.sha, 'a8ae3dd59e6e1802c6f78e05e301bfd57c9f334f');
}); });
test('returns conflicts with ancestor, our and their present', () {
final repoDir = setupRepo(Directory('test/assets/mergerepo/'));
final conflictRepo = Repository.open(repoDir.path);
final conflictBranch = conflictRepo.lookupBranch('ancestor-conflict');
conflictRepo.checkout(refName: 'refs/heads/feature');
conflictRepo.merge(conflictBranch.target);
final index = conflictRepo.index;
final conflictedFile = index.conflicts['feature_file']!;
expect(conflictedFile.ancestor?.path, 'feature_file');
expect(conflictedFile.our?.path, 'feature_file');
expect(conflictedFile.their?.path, 'feature_file');
expect(conflictedFile.toString(), contains('ConflictEntry{'));
index.free();
conflictBranch.free();
conflictRepo.free();
repoDir.deleteSync(recursive: true);
});
test('returns conflicts with our and their present and null ancestor', () {
final repoDir = setupRepo(Directory('test/assets/mergerepo/'));
final conflictRepo = Repository.open(repoDir.path);
final conflictBranch = conflictRepo.lookupBranch('conflict-branch');
conflictRepo.merge(conflictBranch.target);
final index = conflictRepo.index;
final conflictedFile = index.conflicts['conflict_file']!;
expect(conflictedFile.ancestor?.path, null);
expect(conflictedFile.our?.path, 'conflict_file');
expect(conflictedFile.their?.path, 'conflict_file');
expect(conflictedFile.toString(), contains('ConflictEntry{'));
index.free();
conflictBranch.free();
conflictRepo.free();
repoDir.deleteSync(recursive: true);
});
test('returns conflicts with ancestor and their present and null our', () {
final repoDir = setupRepo(Directory('test/assets/mergerepo/'));
final conflictRepo = Repository.open(repoDir.path);
final conflictBranch = conflictRepo.lookupBranch('ancestor-conflict');
conflictRepo.checkout(refName: 'refs/heads/our-conflict');
conflictRepo.merge(conflictBranch.target);
final index = conflictRepo.index;
final conflictedFile = index.conflicts['feature_file']!;
expect(conflictedFile.ancestor?.path, 'feature_file');
expect(conflictedFile.our?.path, null);
expect(conflictedFile.their?.path, 'feature_file');
expect(conflictedFile.toString(), contains('ConflictEntry{'));
index.free();
conflictBranch.free();
conflictRepo.free();
repoDir.deleteSync(recursive: true);
});
test('returns conflicts with ancestor and our present and null their', () {
final repoDir = setupRepo(Directory('test/assets/mergerepo/'));
final conflictRepo = Repository.open(repoDir.path);
final conflictBranch = conflictRepo.lookupBranch('their-conflict');
conflictRepo.checkout(refName: 'refs/heads/feature');
conflictRepo.merge(conflictBranch.target);
final index = conflictRepo.index;
final conflictedFile = index.conflicts['feature_file']!;
expect(conflictedFile.ancestor?.path, 'feature_file');
expect(conflictedFile.our?.path, 'feature_file');
expect(conflictedFile.their?.path, null);
expect(conflictedFile.toString(), contains('ConflictEntry{'));
index.free();
conflictBranch.free();
conflictRepo.free();
repoDir.deleteSync(recursive: true);
});
test('returns string representation of Index and IndexEntry objects', () {
final index = repo.index;
expect(index.toString(), contains('Index{'));
expect(index['file'].toString(), contains('IndexEntry{'));
index.free();
});
}); });
} }

View file

@ -206,5 +206,25 @@ Santa Claus <santa.claus@northpole.xx> <me@company.xx>
mailmap.free(); mailmap.free();
}); });
test('successfully resolves signature', () {
final signature = Signature.create(
name: 'nick1',
email: 'bugs@company.xx',
);
final realSignature = Signature.create(
name: 'Some Dude',
email: 'some@dude.xx',
);
final mailmap = Mailmap.empty();
mailmap.addEntry(
realName: 'Some Dude',
realEmail: 'some@dude.xx',
replaceName: 'nick1',
replaceEmail: 'bugs@company.xx',
);
expect(mailmap.resolveSignature(signature), realSignature);
});
}); });
} }

View file

@ -148,7 +148,7 @@ void main() {
}); });
group('merge file from index', () { group('merge file from index', () {
test('successfully merges', () { test('successfully merges without ancestor', () {
const diffExpected = """ const diffExpected = """
\<<<<<<< conflict_file \<<<<<<< conflict_file
master conflict edit master conflict edit
@ -160,10 +160,40 @@ conflict branch edit
final index = repo.index; final index = repo.index;
repo.merge(conflictBranch.target); repo.merge(conflictBranch.target);
final conflictedFile = index.conflicts['conflict_file']!;
final diff = repo.mergeFileFromIndex( final diff = repo.mergeFileFromIndex(
ancestor: index.conflicts['conflict_file']!.ancestor, ancestor: null,
ours: index.conflicts['conflict_file']!.our, ours: conflictedFile.our!,
theirs: index.conflicts['conflict_file']!.their, theirs: conflictedFile.their!,
);
expect(
diff,
diffExpected,
);
index.free();
conflictBranch.free();
});
test('successfully merges with ancestor', () {
const diffExpected = """
\<<<<<<< feature_file
Feature edit on feature branch
=======
Another feature edit
>>>>>>> feature_file
""";
final conflictBranch = repo.lookupBranch('ancestor-conflict');
repo.checkout(refName: 'refs/heads/feature');
final index = repo.index;
repo.merge(conflictBranch.target);
final conflictedFile = index.conflicts['feature_file']!;
final diff = repo.mergeFileFromIndex(
ancestor: conflictedFile.ancestor,
ours: conflictedFile.our!,
theirs: conflictedFile.their!,
); );
expect( expect(

View file

@ -93,5 +93,11 @@ void main() {
head.free(); head.free();
signature.free(); signature.free();
}); });
test('returns string representation of Note object', () {
final note = repo.lookupNote(annotatedOid: repo['821ed6e']);
expect(note.toString(), contains('Note{'));
note.free();
});
}); });
} }

View file

@ -34,17 +34,16 @@ void main() {
}); });
test('successfully adds disk alternate', () { test('successfully adds disk alternate', () {
final oid = Oid.fromSHA(repo: repo, sha: blobSha);
final odb = Odb.create(); final odb = Odb.create();
odb.addDiskAlternate('${repo.workdir}.git/objects/'); odb.addDiskAlternate('${repo.workdir}.git/objects/');
expect(odb.contains(oid), true); expect(odb.contains(repo[blobSha]), true);
odb.free(); odb.free();
}); });
test('successfully reads object', () { test('successfully reads object', () {
final oid = Oid.fromSHA(repo: repo, sha: blobSha); final oid = repo[blobSha];
final odb = repo.odb; final odb = repo.odb;
final object = odb.read(oid); final object = odb.read(oid);
@ -58,23 +57,14 @@ void main() {
}); });
test('returns list of all objects oid\'s in database', () { test('returns list of all objects oid\'s in database', () {
final oid = Oid.fromSHA(repo: repo, sha: commitSha);
final odb = repo.odb; final odb = repo.odb;
expect(odb.objects, isNot(isEmpty)); expect(odb.objects, isNot(isEmpty));
expect(odb.objects.contains(oid), true); expect(odb.objects.contains(repo[commitSha]), true);
odb.free(); odb.free();
}); });
test('finds object by short oid', () {
final oid = Oid.fromSHA(
repo: repo,
sha: commitSha.substring(0, 5),
);
expect(oid.sha, commitSha);
});
test('successfully writes data', () { test('successfully writes data', () {
final odb = repo.odb; final odb = repo.odb;
final oid = odb.write(type: GitObject.blob, data: 'testing'); final oid = odb.write(type: GitObject.blob, data: 'testing');
@ -96,5 +86,12 @@ void main() {
odb.free(); odb.free();
}); });
test('returns string representation of OdbObject object', () {
final odb = repo.odb;
final object = odb.read(repo[blobSha]);
expect(object.toString(), contains('OdbObject{'));
odb.free();
});
}); });
} }

View file

@ -35,6 +35,19 @@ void main() {
expect(oid, isA<Oid>()); expect(oid, isA<Oid>());
expect(oid.sha, sha); expect(oid.sha, sha);
}); });
test('throws when sha hex string is too short', () {
expect(
() => Oid.fromSHA(repo: repo, sha: 'sha'),
throwsA(
isA<ArgumentError>().having(
(e) => e.invalidValue,
'value',
'sha is not a valid sha hex string',
),
),
);
});
}); });
group('fromRaw()', () { group('fromRaw()', () {
@ -72,5 +85,9 @@ void main() {
expect(oid1 >= oid2, true); expect(oid1 >= oid2, true);
}); });
}); });
test('returns string representation of Oid object', () {
expect(repo[sha].toString(), contains('Oid{'));
});
}); });
} }

View file

@ -69,12 +69,15 @@ void main() {
odb.free(); odb.free();
}); });
test('successfully packs into provided path', () { test('successfully 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(); Directory('${repo.workdir}test-pack').createSync();
final writtenCount = repo.pack(path: '${repo.workdir}test-pack'); final writtenCount = repo.pack(
path: '${repo.workdir}test-pack',
threads: 1,
);
expect(writtenCount, objectsCount); expect(writtenCount, objectsCount);
expect( expect(
Directory('${repo.workdir}test-pack').listSync().isNotEmpty, Directory('${repo.workdir}test-pack').listSync().isNotEmpty,
@ -101,5 +104,11 @@ void main() {
final writtenCount = repo.pack(packDelegate: packDelegate); final writtenCount = repo.pack(packDelegate: packDelegate);
expect(writtenCount, 18); expect(writtenCount, 18);
}); });
test('returns string representation of PackBuilder object', () {
final packbuilder = PackBuilder(repo);
expect(packbuilder.toString(), contains('PackBuilder{'));
packbuilder.free();
});
}); });
} }

View file

@ -174,5 +174,18 @@ index e69de29..0000000
commit.free(); commit.free();
}); });
test('returns string representation of Patch object', () {
final patch = Patch.create(
a: oldBlob,
b: newBlob,
aPath: path,
bPath: path,
);
expect(patch.toString(), contains('Patch{'));
patch.free();
});
}); });
} }

View file

@ -44,9 +44,13 @@ void main() {
final operation = rebase.next(); final operation = rebase.next();
expect(operation.type, GitRebaseOperation.pick); expect(operation.type, GitRebaseOperation.pick);
expect(operation.oid.sha, shas[i]); expect(operation.oid.sha, shas[i]);
expect(operation.exec, ''); expect(operation.toString(), contains('RebaseOperation{'));
rebase.commit(committer: signature); rebase.commit(
committer: signature,
author: signature,
message: 'rebase message',
);
} }
rebase.finish(); rebase.finish();

View file

@ -64,7 +64,7 @@ void main() {
test('returns the short name', () { test('returns the short name', () {
final ref = repo.createReference( final ref = repo.createReference(
name: 'refs/remotes/origin/master', name: 'refs/remotes/origin/master',
target: lastCommit, target: repo[lastCommit],
); );
final head = repo.head; final head = repo.head;
@ -91,7 +91,7 @@ void main() {
test('checks if reference is a remote branch', () { test('checks if reference is a remote branch', () {
final ref = repo.createReference( final ref = repo.createReference(
name: 'refs/remotes/origin/master', name: 'refs/remotes/origin/master',
target: lastCommit, target: repo[lastCommit],
); );
expect(ref.isRemote, true); expect(ref.isRemote, true);
@ -129,33 +129,11 @@ void main() {
ref.free(); ref.free();
}); });
test('successfully creates with SHA hash as target', () {
final refFromHash = repo.createReference(
name: 'refs/tags/from.hash',
target: lastCommit,
);
expect(repo.references, contains('refs/tags/from.hash'));
refFromHash.free();
});
test('successfully creates with short SHA hash as target', () {
final refFromHash = repo.createReference(
name: 'refs/tags/from.short.hash',
target: '78b8bf',
);
expect(repo.references, contains('refs/tags/from.short.hash'));
refFromHash.free();
});
test('successfully creates with log message', () { test('successfully creates with log message', () {
repo.setIdentity(name: 'name', email: 'email'); repo.setIdentity(name: 'name', email: 'email');
final ref = repo.createReference( final ref = repo.createReference(
name: 'refs/heads/log.message', name: 'refs/heads/log.message',
target: lastCommit, target: repo[lastCommit],
logMessage: 'log message', logMessage: 'log message',
); );
@ -178,13 +156,21 @@ void main() {
), ),
throwsA(isA<LibGit2Error>()), throwsA(isA<LibGit2Error>()),
); );
expect(
() => repo.createReference(
name: 'refs/tags/invalid',
target: 0,
),
throwsA(isA<ArgumentError>()),
);
}); });
test('throws if name is not valid', () { test('throws if name is not valid', () {
expect( expect(
() => repo.createReference( () => repo.createReference(
name: 'refs/tags/invalid~', name: 'refs/tags/invalid~',
target: lastCommit, target: repo[lastCommit],
), ),
throwsA(isA<LibGit2Error>()), throwsA(isA<LibGit2Error>()),
); );
@ -193,12 +179,12 @@ void main() {
test('successfully creates with force flag if name already exists', () { test('successfully creates with force flag if name already exists', () {
final ref = repo.createReference( final ref = repo.createReference(
name: 'refs/tags/test', name: 'refs/tags/test',
target: lastCommit, target: repo[lastCommit],
); );
final forceRef = repo.createReference( final forceRef = repo.createReference(
name: 'refs/tags/test', name: 'refs/tags/test',
target: lastCommit, target: repo[lastCommit],
force: true, force: true,
); );
@ -211,13 +197,13 @@ void main() {
test('throws if name already exists', () { test('throws if name already exists', () {
final ref = repo.createReference( final ref = repo.createReference(
name: 'refs/tags/test', name: 'refs/tags/test',
target: lastCommit, target: repo[lastCommit],
); );
expect( expect(
() => repo.createReference( () => repo.createReference(
name: 'refs/tags/test', name: 'refs/tags/test',
target: lastCommit, target: repo[lastCommit],
), ),
throwsA(isA<LibGit2Error>()), throwsA(isA<LibGit2Error>()),
); );
@ -309,7 +295,7 @@ void main() {
test('successfully deletes reference', () { test('successfully deletes reference', () {
final ref = repo.createReference( final ref = repo.createReference(
name: 'refs/tags/test', name: 'refs/tags/test',
target: lastCommit, target: repo[lastCommit],
); );
expect(repo.references, contains('refs/tags/test')); expect(repo.references, contains('refs/tags/test'));
@ -384,6 +370,10 @@ void main() {
() => ref.setTarget(target: 'refs/heads/invalid~'), () => ref.setTarget(target: 'refs/heads/invalid~'),
throwsA(isA<LibGit2Error>()), throwsA(isA<LibGit2Error>()),
); );
expect(
() => ref.setTarget(target: 0),
throwsA(isA<ArgumentError>()),
);
ref.free(); ref.free();
}); });
@ -476,15 +466,32 @@ void main() {
test('successfully peels to object of provided type', () { test('successfully peels to object of provided type', () {
final ref = repo.lookupReference('refs/heads/master'); final ref = repo.lookupReference('refs/heads/master');
final blob = repo.lookupBlob(repo['9c78c21']);
final blobRef = repo.createReference(
name: 'refs/tags/blob',
target: blob.oid,
);
final tagRef = repo.lookupReference('refs/tags/v0.2');
final commit = repo.lookupCommit(ref.target); final commit = repo.lookupCommit(ref.target);
final tree = commit.tree; final tree = commit.tree;
final peeledCommit = ref.peel(GitObject.commit) as Commit; final peeledCommit = ref.peel(GitObject.commit) as Commit;
final peeledTree = ref.peel(GitObject.tree) as Tree; final peeledTree = ref.peel(GitObject.tree) as Tree;
final peeledBlob = blobRef.peel(GitObject.blob) as Blob;
final peeledTag = tagRef.peel(GitObject.tag) as Tag;
expect(peeledCommit.oid, commit.oid); expect(peeledCommit.oid, commit.oid);
expect(peeledTree.oid, tree.oid); expect(peeledTree.oid, tree.oid);
expect(peeledBlob.content, 'Feature edit\n');
expect(peeledTag.name, 'v0.2');
peeledTag.free();
peeledBlob.free();
peeledTree.free();
peeledCommit.free(); peeledCommit.free();
tagRef.free();
blobRef.free();
blob.free();
commit.free(); commit.free();
tree.free(); tree.free();
ref.free(); ref.free();
@ -501,5 +508,11 @@ void main() {
final newRefs = repo.references; final newRefs = repo.references;
expect(newRefs, oldRefs); expect(newRefs, oldRefs);
}); });
test('returns string representation of Reference object', () {
final ref = repo.lookupReference('refs/heads/master');
expect(ref.toString(), contains('Reference{'));
ref.free();
});
}); });
} }

View file

@ -41,5 +41,9 @@ void main() {
expect(reflog[0].committer.email, 'skinny.mind@gmail.com'); expect(reflog[0].committer.email, 'skinny.mind@gmail.com');
expect(reflog[0].committer.time, 1630568461); expect(reflog[0].committer.time, 1630568461);
}); });
test('returns string representation of RefLogEntry object', () {
expect(reflog[0].toString(), contains('RefLogEntry{'));
});
}); });
} }

View file

@ -1,4 +1,5 @@
import 'dart:io'; import 'dart:io';
import 'package:libgit2dart/src/git_types.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:libgit2dart/libgit2dart.dart'; import 'package:libgit2dart/libgit2dart.dart';
import 'helpers/util.dart'; import 'helpers/util.dart';
@ -30,6 +31,7 @@ void main() {
expect(remote.name, remoteName); expect(remote.name, remoteName);
expect(remote.url, remoteUrl); expect(remote.url, remoteUrl);
expect(remote.pushUrl, ''); expect(remote.pushUrl, '');
expect(remote.toString(), contains('Remote{'));
remote.free(); remote.free();
}); });
@ -143,7 +145,9 @@ void main() {
expect(refspec.source, 'refs/heads/*'); expect(refspec.source, 'refs/heads/*');
expect(refspec.destination, 'refs/remotes/origin/*'); expect(refspec.destination, 'refs/remotes/origin/*');
expect(refspec.force, true); expect(refspec.force, true);
expect(refspec.direction, GitDirection.fetch);
expect(refspec.string, '+refs/heads/*:refs/remotes/origin/*'); expect(refspec.string, '+refs/heads/*:refs/remotes/origin/*');
expect(refspec.toString(), contains('Refspec{'));
expect(remote.fetchRefspecs, ['+refs/heads/*:refs/remotes/origin/*']); expect(remote.fetchRefspecs, ['+refs/heads/*:refs/remotes/origin/*']);
expect(refspec.matchesSource('refs/heads/master'), true); expect(refspec.matchesSource('refs/heads/master'), true);
@ -231,6 +235,7 @@ void main() {
expect(stats.totalDeltas, 3); expect(stats.totalDeltas, 3);
expect(stats.indexedDeltas, 3); expect(stats.indexedDeltas, 3);
expect(stats.receivedBytes, 0); expect(stats.receivedBytes, 0);
expect(stats.toString(), contains('TransferProgress{'));
remote.free(); remote.free();
}); });

View file

@ -30,6 +30,15 @@ void main() {
config.free(); config.free();
}); });
test('returns snapshot of repository config', () {
final snapshot = repo.configSnapshot;
expect(
snapshot['remote.origin.url'].value,
'git://github.com/SkinnyMind/libgit2dart.git',
);
snapshot.free();
});
test('returns list of commits by walking from provided starting oid', () { test('returns list of commits by walking from provided starting oid', () {
const log = [ const log = [
'821ed6e80627b8769d170a293862f9fc60825226', '821ed6e80627b8769d170a293862f9fc60825226',
@ -111,6 +120,10 @@ void main() {
repo.setHead('refs/heads/not.there'); repo.setHead('refs/heads/not.there');
expect(repo.isBranchUnborn, true); expect(repo.isBranchUnborn, true);
}); });
test('throws when target is invalid', () {
expect(() => repo.setHead(0), throwsA(isA<ArgumentError>()));
});
}); });
group('createBlob', () { group('createBlob', () {
@ -196,6 +209,18 @@ void main() {
index.free(); index.free();
}); });
test('cleans up state', () {
expect(repo.state, GitRepositoryState.none);
final commit = repo.lookupCommit(repo['5aecfa0']);
repo.cherryPick(commit);
expect(repo.state, GitRepositoryState.cherrypick);
repo.stateCleanup();
expect(repo.state, GitRepositoryState.none);
commit.free();
});
test('returns status of a single file for provided path', () { test('returns status of a single file for provided path', () {
final index = repo.index; final index = repo.index;
index.remove('file'); index.remove('file');
@ -284,5 +309,9 @@ void main() {
commit1.free(); commit1.free();
commit2.free(); commit2.free();
}); });
test('returns string representation of Repository object', () {
expect(repo.toString(), contains('Repository{'));
});
}); });
} }

View file

@ -41,6 +41,7 @@ void main() {
expect(headParse.object.oid.sha, headSHA); expect(headParse.object.oid.sha, headSHA);
expect(headParse.reference, masterRef); expect(headParse.reference, masterRef);
expect(headParse.toString(), contains('RevParse{'));
masterRef.free(); masterRef.free();
headParse.object.free(); headParse.object.free();
@ -77,6 +78,7 @@ void main() {
expect(revspec.from.oid.sha, headSHA); expect(revspec.from.oid.sha, headSHA);
expect(revspec.to, isNull); expect(revspec.to, isNull);
expect(revspec.flags, {GitRevSpec.single}); expect(revspec.flags, {GitRevSpec.single});
expect(revspec.toString(), contains('RevSpec{'));
revspec.from.free(); revspec.from.free();

View file

@ -56,5 +56,9 @@ void main() {
otherSignature.free(); otherSignature.free();
}); });
test('returns string representation of Signature object', () {
expect(signature.toString(), contains('Signature{'));
});
}); });
} }

View file

@ -30,10 +30,41 @@ void main() {
mode: FileMode.append, mode: FileMode.append,
); );
repo.createStash(stasher: stasher, includeUntracked: true); repo.createStash(stasher: stasher);
expect(repo.status.isEmpty, true); expect(repo.status.isEmpty, true);
}); });
test('successfully saves changes to stash including ignored', () {
final swpPath = File('${tmpDir.path}/some.swp');
swpPath.writeAsStringSync('ignored');
repo.createStash(
stasher: stasher,
includeUntracked: true,
includeIgnored: true,
);
expect(repo.status.isEmpty, true);
expect(swpPath.existsSync(), false);
repo.applyStash();
expect(swpPath.existsSync(), true);
});
test('leaves changes added to index intact', () {
File('${tmpDir.path}/file').writeAsStringSync(
'edit',
mode: FileMode.append,
);
final index = repo.index;
index.add('file');
repo.createStash(stasher: stasher, keepIndex: true);
expect(repo.status.isEmpty, false);
expect(repo.stashes.length, 1);
index.free();
});
test('successfully applies changes from stash', () { test('successfully applies changes from stash', () {
File('${tmpDir.path}/file').writeAsStringSync( File('${tmpDir.path}/file').writeAsStringSync(
'edit', 'edit',
@ -47,6 +78,23 @@ void main() {
expect(repo.status, contains('file')); expect(repo.status, contains('file'));
}); });
test('successfully applies changes from stash including index changes', () {
File('${tmpDir.path}/stash.this').writeAsStringSync('stash');
final index = repo.index;
index.add('stash.this');
expect(index.find('stash.this'), true);
repo.createStash(stasher: stasher, includeUntracked: true);
expect(repo.status.isEmpty, true);
expect(index.find('stash.this'), false);
repo.applyStash(reinstateIndex: true);
expect(repo.status, contains('stash.this'));
expect(index.find('stash.this'), true);
index.free();
});
test('successfully drops stash', () { test('successfully drops stash', () {
File('${tmpDir.path}/file').writeAsStringSync( File('${tmpDir.path}/file').writeAsStringSync(
'edit', 'edit',
@ -71,6 +119,23 @@ void main() {
expect(() => repo.applyStash(), throwsA(isA<LibGit2Error>())); expect(() => repo.applyStash(), throwsA(isA<LibGit2Error>()));
}); });
test('successfully pops from stash including index changes', () {
File('${tmpDir.path}/stash.this').writeAsStringSync('stash');
final index = repo.index;
index.add('stash.this');
expect(index.find('stash.this'), true);
repo.createStash(stasher: stasher, includeUntracked: true);
expect(repo.status.isEmpty, true);
expect(index.find('stash.this'), false);
repo.popStash(reinstateIndex: true);
expect(repo.status, contains('stash.this'));
expect(index.find('stash.this'), true);
index.free();
});
test('returns list of stashes', () { test('returns list of stashes', () {
File('${tmpDir.path}/file').writeAsStringSync( File('${tmpDir.path}/file').writeAsStringSync(
'edit', 'edit',
@ -85,5 +150,11 @@ void main() {
expect(stash.index, 0); expect(stash.index, 0);
expect(stash.message, 'On master: WIP'); expect(stash.message, 'On master: WIP');
}); });
test('returns string representation of Stash object', () {
File('${tmpDir.path}/stash.this').writeAsStringSync('stash');
repo.createStash(stasher: stasher, includeUntracked: true);
expect(repo.stashes[0].toString(), contains('Stash{'));
});
}); });
} }

View file

@ -38,6 +38,7 @@ void main() {
expect(submodule.workdirOid?.sha, null); expect(submodule.workdirOid?.sha, null);
expect(submodule.ignore, GitSubmoduleIgnore.none); expect(submodule.ignore, GitSubmoduleIgnore.none);
expect(submodule.updateRule, GitSubmoduleUpdate.checkout); expect(submodule.updateRule, GitSubmoduleUpdate.checkout);
expect(submodule.toString(), contains('Submodule{'));
submodule.free(); submodule.free();
}); });
@ -70,6 +71,10 @@ void main() {
final subHead = submoduleRepo.head; final subHead = submoduleRepo.head;
expect(submoduleRepo, isA<Repository>()); expect(submoduleRepo, isA<Repository>());
expect(subHead.target.sha, submoduleHeadSha); expect(subHead.target.sha, submoduleHeadSha);
expect(
submodule.workdirOid?.sha,
'49322bb17d3acc9146f98c97d078513228bbf3c0',
);
subHead.free(); subHead.free();
submoduleRepo.free(); submoduleRepo.free();

View file

@ -42,12 +42,13 @@ void main() {
expect(tag.message, 'annotated tag\n'); expect(tag.message, 'annotated tag\n');
expect(target.message, 'add subdirectory file\n'); expect(target.message, 'add subdirectory file\n');
expect(tagger, signature); expect(tagger, signature);
expect(tag.toString(), contains('Tag{'));
signature.free(); signature.free();
target.free(); target.free();
}); });
test('successfully creates new tag', () { test('successfully creates new tag with commit as target', () {
final signature = Signature.create( final signature = Signature.create(
name: 'Author', name: 'Author',
email: 'author@email.com', email: 'author@email.com',
@ -80,6 +81,104 @@ void main() {
signature.free(); signature.free();
}); });
test('successfully creates new tag with tree as target', () {
final signature = Signature.create(
name: 'Author',
email: 'author@email.com',
time: 1234,
);
const tagName = 'tag';
final target = repo['a8ae3dd59e6e1802c6f78e05e301bfd57c9f334f'];
const message = 'init tag\n';
final oid = repo.createTag(
tagName: tagName,
target: target,
targetType: GitObject.tree,
tagger: signature,
message: message,
);
final newTag = repo.lookupTag(oid);
final tagger = newTag.tagger;
final newTagTarget = newTag.target as Tree;
expect(newTag.oid.sha, 'ca715c0bafad5d39d568675aad69f71a82178416');
expect(newTag.name, tagName);
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.oid, target);
newTag.free();
newTagTarget.free();
signature.free();
});
test('successfully creates new tag with blob as target', () {
final signature = Signature.create(
name: 'Author',
email: 'author@email.com',
time: 1234,
);
const tagName = 'tag';
final target = repo['9c78c21d6680a7ffebc76f7ac68cacc11d8f48bc'];
const message = 'init tag\n';
final oid = repo.createTag(
tagName: tagName,
target: target,
targetType: GitObject.blob,
tagger: signature,
message: message,
);
final newTag = repo.lookupTag(oid);
final tagger = newTag.tagger;
final newTagTarget = newTag.target as Blob;
expect(newTag.oid.sha, '8b1edabda95e934d2252e563219315b08e38dce5');
expect(newTag.name, tagName);
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.oid, target);
newTag.free();
newTagTarget.free();
signature.free();
});
test('successfully creates new tag with tag as target', () {
final signature = Signature.create(
name: 'Author',
email: 'author@email.com',
time: 1234,
);
const tagName = 'tag';
const message = 'init tag\n';
final oid = repo.createTag(
tagName: tagName,
target: tag.oid,
targetType: GitObject.tag,
tagger: signature,
message: message,
);
final newTag = repo.lookupTag(oid);
final tagger = newTag.tagger;
final newTagTarget = newTag.target as Tag;
expect(newTag.oid.sha, '20286cf6c3b150b58b6c419814b0931d9b17c2ba');
expect(newTag.name, tagName);
expect(newTag.message, message);
expect(tagger, signature);
expect(newTagTarget.oid, tag.oid);
newTag.free();
newTagTarget.free();
signature.free();
});
test('returns list of tags in repository', () { test('returns list of tags in repository', () {
expect(Tag.list(repo), ['v0.1', 'v0.2']); expect(Tag.list(repo), ['v0.1', 'v0.2']);
}); });

View file

@ -26,6 +26,7 @@ void main() {
group('Tree', () { group('Tree', () {
test('successfully initializes tree from provided Oid', () { test('successfully initializes tree from provided Oid', () {
expect(tree, isA<Tree>()); expect(tree, isA<Tree>());
expect(tree.toString(), contains('Tree{'));
}); });
test('returns correct values', () { test('returns correct values', () {
@ -55,6 +56,7 @@ void main() {
test('returns tree entry with provided path to file', () { test('returns tree entry with provided path to file', () {
final entry = tree['dir/dir_file.txt']; final entry = tree['dir/dir_file.txt'];
expect(entry.oid.sha, 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'); expect(entry.oid.sha, 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391');
expect(entry.toString(), contains('TreeEntry{'));
entry.free(); entry.free();
}); });
@ -62,6 +64,10 @@ void main() {
expect(() => tree['invalid/path'], throwsA(isA<LibGit2Error>())); expect(() => tree['invalid/path'], throwsA(isA<LibGit2Error>()));
}); });
test('throws when looking up with invalid argument type', () {
expect(() => tree[true], throwsA(isA<ArgumentError>()));
});
test('successfully creates tree', () { test('successfully creates tree', () {
final fileOid = repo.createBlob('blob content'); final fileOid = repo.createBlob('blob content');
final builder = TreeBuilder(repo: repo); final builder = TreeBuilder(repo: repo);

View file

@ -24,6 +24,7 @@ void main() {
test('successfully initializes tree builder when no tree is provided', () { test('successfully initializes tree builder when no tree is provided', () {
final builder = TreeBuilder(repo: repo); final builder = TreeBuilder(repo: repo);
expect(builder, isA<TreeBuilder>()); expect(builder, isA<TreeBuilder>());
expect(builder.toString(), contains('TreeBuilder{'));
builder.free(); builder.free();
}); });

View file

@ -40,6 +40,7 @@ void main() {
expect(worktree.name, worktreeName); expect(worktree.name, worktreeName);
expect(worktree.path, worktreeDir.path); expect(worktree.path, worktreeDir.path);
expect(worktree.isLocked, false); expect(worktree.isLocked, false);
expect(worktree.toString(), contains('Worktree{'));
expect(File('${worktreeDir.path}/.git').existsSync(), true); expect(File('${worktreeDir.path}/.git').existsSync(), true);
for (final branch in branches) { for (final branch in branches) {