mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 12:19:09 -04:00
feat: add ability to compare objects (#54)
This commit is contained in:
parent
5dfedadfe6
commit
bad40bdb61
45 changed files with 466 additions and 137 deletions
|
@ -1,10 +1,13 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/annotated.dart' as bindings;
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class AnnotatedCommit {
|
||||
@immutable
|
||||
class AnnotatedCommit extends Equatable {
|
||||
/// Lookups an annotated commit from the given commit [oid].
|
||||
///
|
||||
/// It is preferable to use [AnnotatedCommit.fromReference] instead of this
|
||||
|
@ -96,6 +99,9 @@ class AnnotatedCommit {
|
|||
bindings.free(_annotatedCommitPointer);
|
||||
_finalizer.detach(this);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [oid];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -410,14 +410,6 @@ Pointer<git_reference> setTargetSymbolic({
|
|||
}
|
||||
}
|
||||
|
||||
/// Compare two references.
|
||||
bool compare({
|
||||
required Pointer<git_reference> ref1Pointer,
|
||||
required Pointer<git_reference> ref2Pointer,
|
||||
}) {
|
||||
return libgit2.git_reference_cmp(ref1Pointer, ref2Pointer) == 0 || false;
|
||||
}
|
||||
|
||||
/// Recursively peel reference until object of the specified type is found.
|
||||
///
|
||||
/// The retrieved peeled object is owned by the repository and should be closed
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import 'dart:collection';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/blame.dart' as bindings;
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Blame with IterableMixin<BlameHunk> {
|
||||
/// Returns the blame for a single file.
|
||||
|
@ -120,7 +122,8 @@ final _finalizer = Finalizer<Pointer<git_blame>>(
|
|||
);
|
||||
// coverage:ignore-end
|
||||
|
||||
class BlameHunk {
|
||||
@immutable
|
||||
class BlameHunk extends Equatable {
|
||||
/// Initializes a new instance of the [BlameHunk] class from
|
||||
/// provided pointer to blame hunk object in memory.
|
||||
const BlameHunk._(this._blameHunkPointer);
|
||||
|
@ -183,6 +186,19 @@ class BlameHunk {
|
|||
'originCommitter: $originCommitter, originCommitOid: $originCommitOid, '
|
||||
'originPath: $originPath}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
linesCount,
|
||||
isBoundary,
|
||||
finalStartLineNumber,
|
||||
finalCommitter,
|
||||
finalCommitOid,
|
||||
originStartLineNumber,
|
||||
originCommitter,
|
||||
originCommitOid,
|
||||
originPath,
|
||||
];
|
||||
}
|
||||
|
||||
class _BlameIterator implements Iterator<BlameHunk> {
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/blob.dart' as bindings;
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Blob {
|
||||
@immutable
|
||||
class Blob extends Equatable {
|
||||
/// Initializes a new instance of [Blob] class from provided pointer to
|
||||
/// blob object in memory.
|
||||
///
|
||||
|
@ -124,6 +127,9 @@ class Blob {
|
|||
String toString() {
|
||||
return 'Blob{oid: $oid, isBinary: $isBinary, size: $size}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [oid];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/branch.dart' as bindings;
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/reference.dart' as reference_bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Branch {
|
||||
@immutable
|
||||
class Branch extends Equatable {
|
||||
/// Initializes a new instance of [Branch] class from provided pointer to
|
||||
/// branch object in memory.
|
||||
///
|
||||
|
@ -228,6 +231,9 @@ class Branch {
|
|||
return 'Branch{name: $name, target: $target, isHead: $isHead, '
|
||||
'isCheckedOut: $isCheckedOut}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [target, name];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/commit.dart' as bindings;
|
||||
import 'package:libgit2dart/src/bindings/graph.dart' as graph_bindings;
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Commit {
|
||||
@immutable
|
||||
class Commit extends Equatable {
|
||||
/// Initializes a new instance of [Commit] class from provided pointer to
|
||||
/// commit object in memory.
|
||||
///
|
||||
|
@ -338,6 +341,9 @@ class Commit {
|
|||
'messageEncoding: $messageEncoding, time: $time, committer: $committer,'
|
||||
' author: $author}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [oid];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -2,11 +2,13 @@ import 'dart:collection';
|
|||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/config.dart' as bindings;
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/util.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Config with IterableMixin<ConfigEntry> {
|
||||
/// Initializes a new instance of [Config] class from provided
|
||||
|
@ -209,8 +211,9 @@ final _finalizer = Finalizer<Pointer<git_config>>(
|
|||
);
|
||||
// coverage:ignore-end
|
||||
|
||||
class ConfigEntry {
|
||||
ConfigEntry._({
|
||||
@immutable
|
||||
class ConfigEntry extends Equatable {
|
||||
const ConfigEntry._({
|
||||
required this.name,
|
||||
required this.value,
|
||||
required this.includeDepth,
|
||||
|
@ -234,6 +237,9 @@ class ConfigEntry {
|
|||
return 'ConfigEntry{name: $name, value: $value, '
|
||||
'includeDepth: $includeDepth, level: $level}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [name, value, includeDepth, level];
|
||||
}
|
||||
|
||||
class _ConfigIterator implements Iterator<ConfigEntry> {
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/diff.dart' as bindings;
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/util.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Diff {
|
||||
@immutable
|
||||
class Diff extends Equatable {
|
||||
/// Initializes a new instance of [Diff] class from provided
|
||||
/// pointer to diff object in memory.
|
||||
///
|
||||
|
@ -461,8 +464,11 @@ class Diff {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Diff{length: $length}';
|
||||
return 'Diff{length: $length, patchOid: $patchOid}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [patchOid];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
@ -471,7 +477,8 @@ final _finalizer = Finalizer<Pointer<git_diff>>(
|
|||
);
|
||||
// coverage:ignore-end
|
||||
|
||||
class DiffDelta {
|
||||
@immutable
|
||||
class DiffDelta extends Equatable {
|
||||
/// Initializes a new instance of [DiffDelta] class from provided
|
||||
/// pointer to diff delta object in memory.
|
||||
const DiffDelta(this._diffDeltaPointer);
|
||||
|
@ -519,6 +526,16 @@ class DiffDelta {
|
|||
return 'DiffDelta{status: $status, flags: $flags, similarity: $similarity, '
|
||||
'numberOfFiles: $numberOfFiles, oldFile: $oldFile, newFile: $newFile}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
status,
|
||||
flags,
|
||||
similarity,
|
||||
numberOfFiles,
|
||||
oldFile,
|
||||
newFile,
|
||||
];
|
||||
}
|
||||
|
||||
/// Description of one side of a delta.
|
||||
|
@ -526,7 +543,8 @@ class DiffDelta {
|
|||
/// Although this is called a "file", it could represent a file, a symbolic
|
||||
/// link, a submodule commit id, or even a tree (although that only if you
|
||||
/// are tracking type changes or ignored/untracked directories).
|
||||
class DiffFile {
|
||||
@immutable
|
||||
class DiffFile extends Equatable {
|
||||
/// Initializes a new instance of [DiffFile] class from provided diff file
|
||||
/// object.
|
||||
const DiffFile._(this._diffFile);
|
||||
|
@ -560,6 +578,9 @@ class DiffFile {
|
|||
return 'DiffFile{oid: $oid, path: $path, size: $size, flags: $flags, '
|
||||
'mode: $mode}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [oid, path, size, flags, mode];
|
||||
}
|
||||
|
||||
class DiffStats {
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import 'dart:collection';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/index.dart' as bindings;
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Index with IterableMixin<IndexEntry> {
|
||||
/// Initializes a new instance of [Index] class from provided
|
||||
|
@ -323,7 +325,8 @@ final _finalizer = Finalizer<Pointer<git_index>>(
|
|||
);
|
||||
// coverage:ignore-end
|
||||
|
||||
class IndexEntry {
|
||||
@immutable
|
||||
class IndexEntry extends Equatable {
|
||||
/// Initializes a new instance of [IndexEntry] class.
|
||||
///
|
||||
/// Note: For internal use.
|
||||
|
@ -367,6 +370,9 @@ class IndexEntry {
|
|||
String toString() {
|
||||
return 'IndexEntry{oid: $oid, path: $path, mode: $mode, stage: $stage}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [oid, path, mode, stage];
|
||||
}
|
||||
|
||||
class ConflictEntry {
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/note.dart' as bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Note {
|
||||
@immutable
|
||||
class Note extends Equatable {
|
||||
/// Initializes a new instance of the [Note] class from provided
|
||||
/// pointer to note and annotatedOid objects in memory.
|
||||
///
|
||||
|
@ -143,6 +146,9 @@ class Note {
|
|||
String toString() {
|
||||
return 'Note{oid: $oid, message: $message, annotatedOid: $annotatedOid}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [oid];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/odb.dart' as bindings;
|
||||
import 'package:libgit2dart/src/util.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Odb {
|
||||
@immutable
|
||||
class Odb extends Equatable {
|
||||
/// Initializes a new instance of [Odb] class from provided
|
||||
/// pointer to Odb object in memory.
|
||||
///
|
||||
|
@ -101,6 +104,9 @@ class Odb {
|
|||
bindings.free(_odbPointer);
|
||||
_finalizer.detach(this);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [objects];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
@ -109,7 +115,8 @@ final _finalizer = Finalizer<Pointer<git_odb>>(
|
|||
);
|
||||
// coverage:ignore-end
|
||||
|
||||
class OdbObject {
|
||||
@immutable
|
||||
class OdbObject extends Equatable {
|
||||
/// Initializes a new instance of the [OdbObject] class from
|
||||
/// provided pointer to odbObject object in memory.
|
||||
OdbObject._(this._odbObjectPointer) {
|
||||
|
@ -144,6 +151,9 @@ class OdbObject {
|
|||
String toString() {
|
||||
return 'OdbObject{oid: $oid, type: $type, size: $size}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [oid];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/odb.dart' as odb_bindings;
|
||||
|
@ -8,7 +9,7 @@ import 'package:libgit2dart/src/util.dart';
|
|||
import 'package:meta/meta.dart';
|
||||
|
||||
@immutable
|
||||
class Oid {
|
||||
class Oid extends Equatable {
|
||||
/// Initializes a new instance of [Oid] class from provided
|
||||
/// pointer to Oid object in memory.
|
||||
///
|
||||
|
@ -54,13 +55,6 @@ class Oid {
|
|||
/// Hexadecimal SHA string.
|
||||
String get sha => bindings.toSHA(_oidPointer);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return (other is Oid) &&
|
||||
(bindings.compare(aPointer: _oidPointer, bPointer: other._oidPointer) ==
|
||||
0);
|
||||
}
|
||||
|
||||
bool operator <(Oid other) {
|
||||
return bindings.compare(
|
||||
aPointer: _oidPointer,
|
||||
|
@ -93,9 +87,9 @@ class Oid {
|
|||
1;
|
||||
}
|
||||
|
||||
@override // coverage:ignore-line
|
||||
int get hashCode => _oidPointer.address.hashCode; // coverage:ignore-line
|
||||
|
||||
@override
|
||||
String toString() => 'Oid{sha: $sha}';
|
||||
|
||||
@override
|
||||
List<Object?> get props => [sha];
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/patch.dart' as bindings;
|
||||
import 'package:libgit2dart/src/util.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Patch {
|
||||
@immutable
|
||||
class Patch extends Equatable {
|
||||
/// Initializes a new instance of [Patch] class from provided
|
||||
/// pointer to patch object in memory and pointers to old and new blobs/buffers.
|
||||
///
|
||||
|
@ -264,6 +267,9 @@ class Patch {
|
|||
|
||||
@override
|
||||
String toString() => 'Patch{size: ${size()}, delta: $delta}';
|
||||
|
||||
@override
|
||||
List<Object?> get props => [delta];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
@ -296,7 +302,8 @@ class PatchStats {
|
|||
}
|
||||
}
|
||||
|
||||
class DiffHunk {
|
||||
@immutable
|
||||
class DiffHunk extends Equatable {
|
||||
const DiffHunk._({
|
||||
required this.linesCount,
|
||||
required this.index,
|
||||
|
@ -338,9 +345,22 @@ class DiffHunk {
|
|||
'oldStart: $oldStart, oldLines: $oldLines, newStart: $newStart, '
|
||||
'newLines: $newLines, header: $header}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
linesCount,
|
||||
index,
|
||||
oldStart,
|
||||
oldLines,
|
||||
newStart,
|
||||
newLines,
|
||||
header,
|
||||
lines
|
||||
];
|
||||
}
|
||||
|
||||
class DiffLine {
|
||||
@immutable
|
||||
class DiffLine extends Equatable {
|
||||
const DiffLine._({
|
||||
required this.origin,
|
||||
required this.oldLineNumber,
|
||||
|
@ -374,4 +394,14 @@ class DiffLine {
|
|||
'newLineNumber: $newLineNumber, numLines: $numLines, '
|
||||
'contentOffset: $contentOffset, content: $content}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
origin,
|
||||
oldLineNumber,
|
||||
newLineNumber,
|
||||
numLines,
|
||||
contentOffset,
|
||||
content,
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/object.dart' as object_bindings;
|
||||
|
@ -7,8 +8,10 @@ import 'package:libgit2dart/src/bindings/refdb.dart' as refdb_bindings;
|
|||
import 'package:libgit2dart/src/bindings/reference.dart' as bindings;
|
||||
import 'package:libgit2dart/src/bindings/repository.dart'
|
||||
as repository_bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Reference {
|
||||
@immutable
|
||||
class Reference extends Equatable {
|
||||
/// Initializes a new instance of the [Reference] class.
|
||||
///
|
||||
/// Note: For internal use. Instead, use one of:
|
||||
|
@ -79,7 +82,7 @@ class Reference {
|
|||
_finalizer.attach(this, _refPointer, detach: this);
|
||||
}
|
||||
|
||||
late Pointer<git_reference> _refPointer;
|
||||
late final Pointer<git_reference> _refPointer;
|
||||
|
||||
/// Pointer to memory address for allocated reference object.
|
||||
///
|
||||
|
@ -124,6 +127,39 @@ class Reference {
|
|||
);
|
||||
}
|
||||
|
||||
/// Updates the [target] of reference with provided [name].
|
||||
///
|
||||
/// [target] being either Oid for direct reference or string reference name
|
||||
/// for symbolic reference.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if [target]
|
||||
/// is not [Oid] or string.
|
||||
static void setTarget({
|
||||
required Repository repo,
|
||||
required String name,
|
||||
required Object target,
|
||||
String? logMessage,
|
||||
}) {
|
||||
final ref = Reference.lookup(repo: repo, name: name);
|
||||
if (target is Oid) {
|
||||
bindings.setTarget(
|
||||
refPointer: ref.pointer,
|
||||
oidPointer: target.pointer,
|
||||
logMessage: logMessage,
|
||||
);
|
||||
} else if (target is String) {
|
||||
bindings.setTargetSymbolic(
|
||||
refPointer: ref.pointer,
|
||||
target: target,
|
||||
logMessage: logMessage,
|
||||
);
|
||||
} else {
|
||||
throw ArgumentError.value(
|
||||
'$target must be either Oid or String reference name',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// List of all the references names that can be found in a [repo]sitory.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
|
@ -177,35 +213,6 @@ class Reference {
|
|||
return Oid(oidPointer);
|
||||
}
|
||||
|
||||
/// Updates the [target] of this reference.
|
||||
///
|
||||
/// [target] being either Oid for direct reference or string reference name
|
||||
/// for symbolic reference.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if [target]
|
||||
/// is not [Oid] or string.
|
||||
void setTarget({required Object target, String? logMessage}) {
|
||||
if (target is Oid) {
|
||||
final newPointer = bindings.setTarget(
|
||||
refPointer: _refPointer,
|
||||
oidPointer: target.pointer,
|
||||
logMessage: logMessage,
|
||||
);
|
||||
_refPointer = newPointer;
|
||||
} else if (target is String) {
|
||||
final newPointer = bindings.setTargetSymbolic(
|
||||
refPointer: _refPointer,
|
||||
target: target,
|
||||
logMessage: logMessage,
|
||||
);
|
||||
_refPointer = newPointer;
|
||||
} else {
|
||||
throw ArgumentError.value(
|
||||
'$target must be either Oid or String reference name',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Recursively peel reference until object of the specified [type] is found.
|
||||
///
|
||||
/// The retrieved peeled object is owned by the repository and should be
|
||||
|
@ -272,17 +279,6 @@ class Reference {
|
|||
/// Whether reference is a tag.
|
||||
bool get isTag => bindings.isTag(_refPointer);
|
||||
|
||||
/// Compares two references.
|
||||
bool equals(Reference other) {
|
||||
return bindings.compare(
|
||||
ref1Pointer: _refPointer,
|
||||
ref2Pointer: other._refPointer,
|
||||
);
|
||||
}
|
||||
|
||||
/// Compares two references.
|
||||
bool notEquals(Reference other) => !equals(other);
|
||||
|
||||
/// Releases memory allocated for reference object.
|
||||
void free() {
|
||||
bindings.free(_refPointer);
|
||||
|
@ -295,6 +291,9 @@ class Reference {
|
|||
'isBranch: $isBranch, isNote: $isNote, isRemote: $isRemote, '
|
||||
'isTag: $isTag}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [target];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import 'dart:collection';
|
||||
import 'dart:ffi';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/reference.dart' as reference_bindings;
|
||||
import 'package:libgit2dart/src/bindings/reflog.dart' as bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class RefLog with IterableMixin<RefLogEntry> {
|
||||
/// Initializes a new instance of [RefLog] class from provided [Reference].
|
||||
|
@ -109,7 +111,8 @@ final _finalizer = Finalizer<Pointer<git_reflog>>(
|
|||
);
|
||||
// coverage:ignore-end
|
||||
|
||||
class RefLogEntry {
|
||||
@immutable
|
||||
class RefLogEntry extends Equatable {
|
||||
/// Initializes a new instance of [RefLogEntry] class from provided
|
||||
/// pointer to RefLogEntry object in memory.
|
||||
const RefLogEntry._(this._entryPointer);
|
||||
|
@ -133,6 +136,9 @@ class RefLogEntry {
|
|||
|
||||
@override
|
||||
String toString() => 'RefLogEntry{message: $message, committer: $committer}';
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message, committer, newOid, oldOid];
|
||||
}
|
||||
|
||||
class _RefLogIterator implements Iterator<RefLogEntry> {
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/refspec.dart' as bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Refspec {
|
||||
@immutable
|
||||
class Refspec extends Equatable {
|
||||
/// Initializes a new instance of the [Refspec] class
|
||||
/// from provided pointer to refspec object in memory.
|
||||
///
|
||||
|
@ -72,6 +75,9 @@ class Refspec {
|
|||
@override
|
||||
String toString() {
|
||||
return 'Refspec{source: $source, destination: $destination, force: $force, '
|
||||
'string: $string}';
|
||||
'string: $string, direction: $direction}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [source, destination, force, string, direction];
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/remote.dart' as bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Remote {
|
||||
@immutable
|
||||
class Remote extends Equatable {
|
||||
/// Lookups remote with provided [name] in a [repo]sitory.
|
||||
///
|
||||
/// The [name] will be checked for validity.
|
||||
|
@ -310,6 +313,9 @@ class Remote {
|
|||
return 'Remote{name: $name, url: $url, pushUrl: $pushUrl, '
|
||||
'refspecCount: $refspecCount}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [name];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
@ -378,7 +384,8 @@ class RemoteCallback {
|
|||
final String? fetch;
|
||||
}
|
||||
|
||||
class RemoteReference {
|
||||
@immutable
|
||||
class RemoteReference extends Equatable {
|
||||
const RemoteReference._({
|
||||
required this.isLocal,
|
||||
required this.localId,
|
||||
|
@ -408,4 +415,7 @@ class RemoteReference {
|
|||
return 'RemoteReference{isLocal: $isLocal, localId: $localId, '
|
||||
'name: $name, oid: $oid, symRef: $symRef}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [isLocal, localId, name, oid, symRef];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
|
@ -7,7 +8,7 @@ import 'package:libgit2dart/src/util.dart';
|
|||
import 'package:meta/meta.dart';
|
||||
|
||||
@immutable
|
||||
class Signature {
|
||||
class Signature extends Equatable {
|
||||
/// Initializes a new instance of [Signature] class from provided pointer to
|
||||
/// signature object in memory.
|
||||
///
|
||||
|
@ -74,16 +75,8 @@ class Signature {
|
|||
/// Timezone offset in minutes.
|
||||
int get offset => _signaturePointer.ref.when.offset;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return (other is Signature) &&
|
||||
(name == other.name) &&
|
||||
(email == other.email) &&
|
||||
(time == other.time) &&
|
||||
(offset == other.offset) &&
|
||||
(_signaturePointer.ref.when.sign ==
|
||||
other._signaturePointer.ref.when.sign);
|
||||
}
|
||||
/// Indicator for questionable '-0000' offsets in signature.
|
||||
String get sign => String.fromCharCode(_signaturePointer.ref.when.sign);
|
||||
|
||||
/// Releases memory allocated for signature object.
|
||||
void free() {
|
||||
|
@ -91,15 +84,14 @@ class Signature {
|
|||
_finalizer.detach(this);
|
||||
}
|
||||
|
||||
@override // coverage:ignore-line
|
||||
int get hashCode =>
|
||||
_signaturePointer.address.hashCode; // coverage:ignore-line
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Signature{name: $name, email: $email, time: $time, '
|
||||
'offset: $offset}';
|
||||
'offset: $sign$offset}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [name, email, time, offset, sign];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/stash.dart' as bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Stash {
|
||||
@immutable
|
||||
class Stash extends Equatable {
|
||||
/// Initializes a new instance of [Stash] class from provided stash [index],
|
||||
/// [message] and [oid].
|
||||
const Stash({
|
||||
|
@ -146,4 +149,7 @@ class Stash {
|
|||
String toString() {
|
||||
return 'Stash{index: $index, message: $message, oid: $oid}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [index, message, oid];
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/submodule.dart' as bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Submodule {
|
||||
@immutable
|
||||
class Submodule extends Equatable {
|
||||
/// Lookups submodule information by [name] or path (they are usually the
|
||||
/// same).
|
||||
///
|
||||
|
@ -267,10 +270,23 @@ class Submodule {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Submodule{name: $name, path: $path, url: $url, status: $status, '
|
||||
'branch: $branch, headOid: $headOid, indexOid: $indexOid, '
|
||||
'workdirOid: $workdirOid, ignore: $ignore, updateRule: $updateRule}';
|
||||
return 'Submodule{name: $name, path: $path, url: $url, branch: $branch, '
|
||||
'headOid: $headOid, indexOid: $indexOid, workdirOid: $workdirOid, '
|
||||
'ignore: $ignore, updateRule: $updateRule}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
name,
|
||||
path,
|
||||
url,
|
||||
branch,
|
||||
headOid,
|
||||
indexOid,
|
||||
workdirOid,
|
||||
ignore,
|
||||
updateRule,
|
||||
];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/object.dart' as object_bindings;
|
||||
import 'package:libgit2dart/src/bindings/tag.dart' as bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Tag {
|
||||
@immutable
|
||||
class Tag extends Equatable {
|
||||
/// Initializes a new instance of [Tag] class from provided pointer to
|
||||
/// tag object in memory.
|
||||
///
|
||||
|
@ -223,6 +226,9 @@ class Tag {
|
|||
return 'Tag{oid: $oid, name: $name, message: $message, target: $target, '
|
||||
'tagger: $tagger}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [name];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import 'dart:ffi';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/tree.dart' as bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Tree {
|
||||
@immutable
|
||||
class Tree extends Equatable {
|
||||
/// Initializes a new instance of [Tree] class from provided pointer to
|
||||
/// tree object in memory.
|
||||
///
|
||||
|
@ -102,6 +105,9 @@ class Tree {
|
|||
String toString() {
|
||||
return 'Tree{oid: $oid, length: $length}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [oid];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
@ -110,12 +116,13 @@ final _finalizer = Finalizer<Pointer<git_tree>>(
|
|||
);
|
||||
// coverage:ignore-end
|
||||
|
||||
class TreeEntry {
|
||||
@immutable
|
||||
class TreeEntry extends Equatable {
|
||||
/// Initializes a new instance of [TreeEntry] class from provided pointer to
|
||||
/// tree entry object in memory.
|
||||
///
|
||||
/// Note: For internal use.
|
||||
TreeEntry(this._treeEntryPointer);
|
||||
const TreeEntry(this._treeEntryPointer);
|
||||
|
||||
/// Initializes a new instance of [TreeEntry] class from provided pointer to
|
||||
/// tree entry object in memory.
|
||||
|
@ -150,6 +157,9 @@ class TreeEntry {
|
|||
|
||||
@override
|
||||
String toString() => 'TreeEntry{oid: $oid, name: $name, filemode: $filemode}';
|
||||
|
||||
@override
|
||||
List<Object?> get props => [oid, name, filemode];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/bindings/worktree.dart' as bindings;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
class Worktree {
|
||||
@immutable
|
||||
class Worktree extends Equatable {
|
||||
/// Creates new worktree.
|
||||
///
|
||||
/// If [ref] is provided, no new branch will be created but specified [ref]
|
||||
|
@ -93,8 +96,12 @@ class Worktree {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Worktree{name: $name, path: $path}';
|
||||
return 'Worktree{name: $name, path: $path, isLocked: $isLocked, '
|
||||
'isPrunable: $isPrunable, isValid: $isValid}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [name, path, isLocked, isValid];
|
||||
}
|
||||
|
||||
// coverage:ignore-start
|
||||
|
|
|
@ -13,6 +13,7 @@ environment:
|
|||
dependencies:
|
||||
args: ^2.3.0
|
||||
cli_util: ^0.3.5
|
||||
equatable: ^2.0.3
|
||||
ffi: ^1.1.2
|
||||
meta: ^1.7.0
|
||||
path: ^1.8.1
|
||||
|
|
|
@ -107,5 +107,12 @@ void main() {
|
|||
final annotated = AnnotatedCommit.lookup(repo: repo, oid: tip);
|
||||
expect(() => annotated.free(), returnsNormally);
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(
|
||||
AnnotatedCommit.lookup(repo: repo, oid: tip),
|
||||
equals(AnnotatedCommit.lookup(repo: repo, oid: tip)),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -211,5 +211,12 @@ void main() {
|
|||
final blame = Blame.file(repo: repo, path: 'feature_file');
|
||||
expect(blame.toString(), contains('BlameHunk{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(
|
||||
Blame.file(repo: repo, path: 'feature_file'),
|
||||
equals(Blame.file(repo: repo, path: 'feature_file')),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -153,5 +153,12 @@ void main() {
|
|||
final blob = Blob.lookup(repo: repo, oid: repo[blobSHA]);
|
||||
expect(blob.toString(), contains('Blob{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(
|
||||
Blob.lookup(repo: repo, oid: repo[blobSHA]),
|
||||
equals(Blob.lookup(repo: repo, oid: repo[blobSHA])),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -327,5 +327,12 @@ void main() {
|
|||
final branch = Branch.lookup(repo: repo, name: 'master');
|
||||
expect(branch.toString(), contains('Branch{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(
|
||||
Branch.lookup(repo: repo, name: 'master'),
|
||||
equals(Branch.lookup(repo: repo, name: 'master')),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -396,5 +396,12 @@ Some description.
|
|||
final commit = Commit.lookup(repo: repo, oid: tip);
|
||||
expect(commit.toString(), contains('Commit{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(
|
||||
Commit.lookup(repo: repo, oid: tip),
|
||||
equals(Commit.lookup(repo: repo, oid: tip)),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -217,5 +217,9 @@ void main() {
|
|||
final entry = config.first;
|
||||
expect(entry.toString(), contains('ConfigEntry{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(Config.open(filePath), equals(Config.open(filePath)));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -580,5 +580,15 @@ index e69de29..c217c63 100644
|
|||
expect(patch.delta.oldFile.toString(), contains('DiffFile{'));
|
||||
expect(stats.toString(), contains('DiffStats{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(Diff.parse(patchText), equals(Diff.parse(patchText)));
|
||||
|
||||
final diff = Diff.parse(patchText);
|
||||
expect(diff.deltas[0], equals(diff.deltas[0]));
|
||||
|
||||
final delta = diff.deltas[0];
|
||||
expect(delta.oldFile, equals(delta.oldFile));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -509,5 +509,9 @@ void main() {
|
|||
expect(index.toString(), contains('Index{'));
|
||||
expect(index['file'].toString(), contains('IndexEntry{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(repo.index, equals(repo.index));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -134,5 +134,13 @@ void main() {
|
|||
final note = Note.lookup(repo: repo, annotatedOid: repo['821ed6e']);
|
||||
expect(note.toString(), contains('Note{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
final oid = repo.head.target;
|
||||
expect(
|
||||
Note.lookup(repo: repo, annotatedOid: oid),
|
||||
equals(Note.lookup(repo: repo, annotatedOid: oid)),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ void main() {
|
|||
expect(object.type, GitObject.blob);
|
||||
expect(object.data, blobContent);
|
||||
expect(object.size, 13);
|
||||
expect(object, equals(repo.odb.read(repo[blobSha])));
|
||||
});
|
||||
|
||||
test('throws when trying to read object and error occurs', () {
|
||||
|
@ -115,5 +116,9 @@ void main() {
|
|||
final object = repo.odb.read(repo[blobSha]);
|
||||
expect(object.toString(), contains('OdbObject{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(repo.odb, equals(repo.odb));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -230,5 +230,25 @@ index e69de29..0000000
|
|||
expect(patch.hunks[0].toString(), contains('DiffHunk{'));
|
||||
expect(patch.hunks[0].lines[0].toString(), contains('DiffLine{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
final patch = Patch.fromBuffers(
|
||||
oldBuffer: oldBuffer,
|
||||
newBuffer: newBuffer,
|
||||
oldBufferPath: path,
|
||||
newBufferPath: path,
|
||||
);
|
||||
final anotherPatch = Patch.fromBuffers(
|
||||
oldBuffer: oldBuffer,
|
||||
newBuffer: newBuffer,
|
||||
oldBufferPath: path,
|
||||
newBufferPath: path,
|
||||
);
|
||||
expect(patch, equals(anotherPatch));
|
||||
expect(patch.hunks[0], equals(patch.hunks[0]));
|
||||
|
||||
final hunk = patch.hunks[0];
|
||||
expect(hunk.lines[0], equals(hunk.lines[0]));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ void main() {
|
|||
final duplicate = ref.duplicate();
|
||||
|
||||
expect(repo.references.length, 6);
|
||||
expect(duplicate.equals(ref), true);
|
||||
expect(duplicate, equals(ref));
|
||||
});
|
||||
|
||||
group('create direct', () {
|
||||
|
@ -354,25 +354,35 @@ void main() {
|
|||
|
||||
group('set target', () {
|
||||
test('sets direct reference with provided oid target', () {
|
||||
Reference.setTarget(
|
||||
repo: repo,
|
||||
name: 'refs/heads/master',
|
||||
target: repo[newCommit],
|
||||
);
|
||||
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||
ref.setTarget(target: repo[newCommit]);
|
||||
expect(ref.target.sha, newCommit);
|
||||
});
|
||||
|
||||
test('sets symbolic target with provided reference name', () {
|
||||
Reference.setTarget(
|
||||
repo: repo,
|
||||
name: 'HEAD',
|
||||
target: 'refs/heads/feature',
|
||||
);
|
||||
final ref = Reference.lookup(repo: repo, name: 'HEAD');
|
||||
expect(ref.target.sha, lastCommit);
|
||||
|
||||
ref.setTarget(target: 'refs/heads/feature');
|
||||
expect(ref.target.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
||||
});
|
||||
|
||||
test('sets target with log message', () {
|
||||
final ref = Reference.lookup(repo: repo, name: 'HEAD');
|
||||
expect(ref.target.sha, lastCommit);
|
||||
|
||||
repo.setIdentity(name: 'name', email: 'email');
|
||||
ref.setTarget(target: 'refs/heads/feature', logMessage: 'log message');
|
||||
Reference.setTarget(
|
||||
repo: repo,
|
||||
name: 'HEAD',
|
||||
target: 'refs/heads/feature',
|
||||
logMessage: 'log message',
|
||||
);
|
||||
|
||||
final ref = Reference.lookup(repo: repo, name: 'HEAD');
|
||||
expect(ref.target.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
||||
final logEntry = ref.log.first;
|
||||
expect(logEntry.message, 'log message');
|
||||
|
@ -381,18 +391,28 @@ void main() {
|
|||
});
|
||||
|
||||
test('throws on invalid target', () {
|
||||
final ref = Reference.lookup(repo: repo, name: 'HEAD');
|
||||
expect(
|
||||
() => ref.setTarget(target: 'refs/heads/invalid~'),
|
||||
() => Reference.setTarget(
|
||||
repo: repo,
|
||||
name: 'HEAD',
|
||||
target: 'refs/heads/invalid~',
|
||||
),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
|
||||
expect(
|
||||
() => ref.setTarget(target: Oid(nullptr)),
|
||||
() => Reference.setTarget(
|
||||
repo: repo,
|
||||
name: 'HEAD',
|
||||
target: Oid(nullptr),
|
||||
),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
|
||||
expect(() => ref.setTarget(target: 0), throwsA(isA<ArgumentError>()));
|
||||
expect(
|
||||
() => Reference.setTarget(repo: repo, name: 'HEAD', target: 0),
|
||||
throwsA(isA<ArgumentError>()),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -458,17 +478,6 @@ void main() {
|
|||
});
|
||||
});
|
||||
|
||||
test('checks equality', () {
|
||||
final ref1 = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||
final ref2 = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||
final ref3 = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
||||
|
||||
expect(ref1.equals(ref2), true);
|
||||
expect(ref1.notEquals(ref2), false);
|
||||
expect(ref1.equals(ref3), false);
|
||||
expect(ref1.notEquals(ref3), true);
|
||||
});
|
||||
|
||||
test('peels to non-tag object when no type is provided', () {
|
||||
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||
final commit = Commit.lookup(repo: repo, oid: ref.target);
|
||||
|
@ -530,5 +539,12 @@ void main() {
|
|||
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||
expect(ref.toString(), contains('Reference{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(
|
||||
Reference.lookup(repo: repo, name: 'HEAD'),
|
||||
equals(Reference.lookup(repo: repo, name: 'refs/heads/master')),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -153,5 +153,10 @@ void main() {
|
|||
test('returns string representation of RefLogEntry object', () {
|
||||
expect(reflog[0].toString(), contains('RefLogEntry{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
final ref = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||
expect(RefLog(repo.head), equals(RefLog(ref)));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ void main() {
|
|||
expect(remote.url, remoteUrl);
|
||||
expect(remote.pushUrl, '');
|
||||
expect(remote.toString(), contains('Remote{'));
|
||||
expect(remote, equals(Remote.lookup(repo: repo, name: 'origin')));
|
||||
});
|
||||
|
||||
test('throws when provided name for lookup is not found', () {
|
||||
|
@ -42,6 +43,13 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test('throws when trying to create remote and name already exists', () {
|
||||
expect(
|
||||
() => Remote.create(repo: repo, name: 'origin', url: remoteUrl),
|
||||
throwsA(isA<LibGit2Error>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('creates without fetchspec', () {
|
||||
final remote = Remote.create(
|
||||
repo: repo,
|
||||
|
@ -188,6 +196,8 @@ void main() {
|
|||
refspec.rTransform('refs/remotes/origin/master'),
|
||||
'refs/heads/master',
|
||||
);
|
||||
|
||||
expect(refspec, equals(remote.getRefspec(0)));
|
||||
});
|
||||
|
||||
test('throws when trying to transform refspec with invalid reference name',
|
||||
|
@ -270,6 +280,7 @@ void main() {
|
|||
expect(refs.first.symRef, 'refs/heads/master');
|
||||
expect((refs.first.oid).sha, '49322bb17d3acc9146f98c97d078513228bbf3c0');
|
||||
expect(refs.first.toString(), contains('RemoteReference{'));
|
||||
expect(refs.first, remote.ls().first);
|
||||
});
|
||||
|
||||
test(
|
||||
|
|
|
@ -59,7 +59,7 @@ void main() {
|
|||
var headParse = RevParse.ext(repo: repo, spec: 'master');
|
||||
|
||||
expect(headParse.object.oid.sha, headSHA);
|
||||
expect(headParse.reference?.equals(masterRef), true);
|
||||
expect(headParse.reference, equals(masterRef));
|
||||
expect(headParse.toString(), contains('RevParse{'));
|
||||
|
||||
final featureRef = Reference.lookup(
|
||||
|
@ -72,7 +72,7 @@ void main() {
|
|||
headParse.object.oid.sha,
|
||||
'5aecfa0fb97eadaac050ccb99f03c3fb65460ad4',
|
||||
);
|
||||
expect(headParse.reference?.equals(featureRef), true);
|
||||
expect(headParse.reference, equals(featureRef));
|
||||
});
|
||||
|
||||
test('.ext() returns only commit when no intermidiate reference found', () {
|
||||
|
|
|
@ -47,6 +47,7 @@ void main() {
|
|||
lessThan(5),
|
||||
);
|
||||
expect(sig.offset, isA<int>());
|
||||
expect(sig.sign, isNotEmpty);
|
||||
});
|
||||
|
||||
test('returns correct values', () {
|
||||
|
@ -77,5 +78,12 @@ void main() {
|
|||
test('returns string representation of Signature object', () {
|
||||
expect(signature.toString(), contains('Signature{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(
|
||||
Signature.create(name: name, email: email, time: time),
|
||||
equals(Signature.create(name: name, email: email, time: time)),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -211,5 +211,12 @@ void main() {
|
|||
|
||||
expect(repo.stashes[0].toString(), contains('Stash{'));
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
File(filePath).writeAsStringSync('edit', mode: FileMode.append);
|
||||
Stash.create(repo: repo, stasher: stasher, message: 'WIP');
|
||||
|
||||
expect(repo.stashes.first, equals(repo.stashes.first));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -243,5 +243,12 @@ void main() {
|
|||
final submodule = Submodule.lookup(repo: repo, name: testSubmodule);
|
||||
expect(() => submodule.free(), returnsNormally);
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(
|
||||
Submodule.lookup(repo: repo, name: testSubmodule),
|
||||
equals(Submodule.lookup(repo: repo, name: testSubmodule)),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -384,5 +384,12 @@ void main() {
|
|||
tag = Tag.lookup(repo: repo, oid: tagOid);
|
||||
expect(() => tag.free(), returnsNormally);
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(
|
||||
Tag.lookup(repo: repo, oid: tagOid),
|
||||
equals(Tag.lookup(repo: repo, oid: tagOid)),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -101,5 +101,14 @@ void main() {
|
|||
'looked up by path', () {
|
||||
expect(() => tree['dir/dir_file.txt'].free(), returnsNormally);
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
expect(
|
||||
Tree.lookup(repo: repo, oid: repo['a8ae3dd']),
|
||||
equals(Tree.lookup(repo: repo, oid: repo['a8ae3dd'])),
|
||||
);
|
||||
|
||||
expect(tree[0], equals(tree[0]));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -166,5 +166,14 @@ void main() {
|
|||
);
|
||||
expect(() => worktree.free(), returnsNormally);
|
||||
});
|
||||
|
||||
test('supports value comparison', () {
|
||||
final worktree = Worktree.create(
|
||||
repo: repo,
|
||||
name: worktreeName,
|
||||
path: worktreeDir.path,
|
||||
);
|
||||
expect(worktree, equals(Worktree.lookup(repo: repo, name: worktreeName)));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue