mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
refactor!: use Oid instead of String for arguments
This commit is contained in:
parent
23787adc3a
commit
1972c6d1ab
39 changed files with 264 additions and 290 deletions
|
@ -23,22 +23,22 @@ List<Map<String, Pointer>> list(Pointer<git_repository> repo) {
|
||||||
var nextError = 0;
|
var nextError = 0;
|
||||||
|
|
||||||
while (nextError >= 0) {
|
while (nextError >= 0) {
|
||||||
final noteId = calloc<git_oid>();
|
final noteOid = calloc<git_oid>();
|
||||||
var annotatedId = calloc<git_oid>();
|
var annotatedOid = calloc<git_oid>();
|
||||||
nextError = libgit2.git_note_next(noteId, annotatedId, iterator.value);
|
nextError = libgit2.git_note_next(noteOid, annotatedOid, iterator.value);
|
||||||
if (nextError >= 0) {
|
if (nextError >= 0) {
|
||||||
final out = calloc<Pointer<git_note>>();
|
final out = calloc<Pointer<git_note>>();
|
||||||
final error = libgit2.git_note_read(out, repo, notesRef, annotatedId);
|
final error = libgit2.git_note_read(out, repo, notesRef, annotatedOid);
|
||||||
|
|
||||||
calloc.free(noteId);
|
calloc.free(noteOid);
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
calloc.free(out);
|
calloc.free(out);
|
||||||
calloc.free(annotatedId);
|
calloc.free(annotatedOid);
|
||||||
calloc.free(iterator);
|
calloc.free(iterator);
|
||||||
throw LibGit2Error(libgit2.git_error_last());
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
result.add({'note': out.value, 'annotatedId': annotatedId});
|
result.add({'note': out.value, 'annotatedOid': annotatedOid});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -19,7 +19,7 @@ Pointer<git_oid> target(Pointer<git_reference> ref) {
|
||||||
final result = libgit2.git_reference_target(ref);
|
final result = libgit2.git_reference_target(ref);
|
||||||
|
|
||||||
if (result == nullptr) {
|
if (result == nullptr) {
|
||||||
throw Exception('OID for reference isn\'t available');
|
throw Exception('Oid for reference isn\'t available');
|
||||||
} else {
|
} else {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,30 +106,30 @@ class BlameHunk {
|
||||||
/// version of the file.
|
/// version of the file.
|
||||||
int get finalStartLineNumber => _blameHunkPointer.ref.final_start_line_number;
|
int get finalStartLineNumber => _blameHunkPointer.ref.final_start_line_number;
|
||||||
|
|
||||||
/// Returns the author of [finalCommitId]. If [GitBlameFlag.useMailmap] has been
|
/// Returns the author of [finalCommitOid]. If [GitBlameFlag.useMailmap] has been
|
||||||
/// specified, it will contain the canonical real name and email address.
|
/// specified, it will contain the canonical real name and email address.
|
||||||
Signature get finalCommitter =>
|
Signature get finalCommitter =>
|
||||||
Signature(_blameHunkPointer.ref.final_signature);
|
Signature(_blameHunkPointer.ref.final_signature);
|
||||||
|
|
||||||
/// Returns the [Oid] of the commit where this line was last changed.
|
/// Returns the [Oid] of the commit where this line was last changed.
|
||||||
Oid get finalCommitId => Oid.fromRaw(_blameHunkPointer.ref.final_commit_id);
|
Oid get finalCommitOid => Oid.fromRaw(_blameHunkPointer.ref.final_commit_id);
|
||||||
|
|
||||||
/// Returns the 1-based line number where this hunk begins, in the file
|
/// Returns the 1-based line number where this hunk begins, in the file
|
||||||
/// named by [originPath] in the commit specified by [originCommitId].
|
/// named by [originPath] in the commit specified by [originCommitId].
|
||||||
int get originStartLineNumber => _blameHunkPointer.ref.orig_start_line_number;
|
int get originStartLineNumber => _blameHunkPointer.ref.orig_start_line_number;
|
||||||
|
|
||||||
/// Returns the author of [originCommitId]. If [GitBlameFlag.useMailmap] has been
|
/// Returns the author of [originCommitOid]. If [GitBlameFlag.useMailmap] has been
|
||||||
/// specified, it will contain the canonical real name and email address.
|
/// specified, it will contain the canonical real name and email address.
|
||||||
Signature get originCommitter =>
|
Signature get originCommitter =>
|
||||||
Signature(_blameHunkPointer.ref.orig_signature);
|
Signature(_blameHunkPointer.ref.orig_signature);
|
||||||
|
|
||||||
/// Returns the [Oid] of the commit where this hunk was found. This will usually be
|
/// Returns the [Oid] of the commit where this hunk was found. This will usually be
|
||||||
/// the same as [finalCommitId], except when [GitBlameFlag.trackCopiesAnyCommitCopies]
|
/// the same as [finalCommitOid], except when [GitBlameFlag.trackCopiesAnyCommitCopies]
|
||||||
/// been specified.
|
/// been specified.
|
||||||
Oid get originCommitId => Oid.fromRaw(_blameHunkPointer.ref.orig_commit_id);
|
Oid get originCommitOid => Oid.fromRaw(_blameHunkPointer.ref.orig_commit_id);
|
||||||
|
|
||||||
/// Returns the path to the file where this hunk originated, as of the commit
|
/// Returns the path to the file where this hunk originated, as of the commit
|
||||||
/// specified by [originCommitId].
|
/// specified by [originCommitOid].
|
||||||
String get originPath =>
|
String get originPath =>
|
||||||
_blameHunkPointer.ref.orig_path.cast<Utf8>().toDartString();
|
_blameHunkPointer.ref.orig_path.cast<Utf8>().toDartString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,13 @@ class Blob {
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Blob(this._blobPointer);
|
Blob(this._blobPointer);
|
||||||
|
|
||||||
/// Lookups a blob object for provided [id] in a [repo]sitory.
|
/// Lookups a blob object for provided [oid] in a [repo]sitory.
|
||||||
///
|
///
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Blob.lookup({required Repository repo, required Oid id}) {
|
Blob.lookup({required Repository repo, required Oid oid}) {
|
||||||
_blobPointer = bindings.lookup(
|
_blobPointer = bindings.lookup(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
oidPointer: id.pointer,
|
oidPointer: oid.pointer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@ class Blob {
|
||||||
return Oid(bindings.createFromDisk(repoPointer: repo.pointer, path: path));
|
return Oid(bindings.createFromDisk(repoPointer: repo.pointer, path: path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the Oid of the blob.
|
/// Returns the [Oid] of the blob.
|
||||||
Oid get id => Oid(bindings.id(_blobPointer));
|
Oid get oid => Oid(bindings.id(_blobPointer));
|
||||||
|
|
||||||
/// Determines if the blob content is most certainly binary or not.
|
/// Determines if the blob content is most certainly binary or not.
|
||||||
///
|
///
|
||||||
|
|
|
@ -119,7 +119,7 @@ class Branch {
|
||||||
branch.free();
|
branch.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the OID pointed to by a branch.
|
/// Returns the [Oid] pointed to by a branch.
|
||||||
///
|
///
|
||||||
/// Throws an exception if error occured.
|
/// Throws an exception if error occured.
|
||||||
Oid get target => Oid(reference_bindings.target(_branchPointer));
|
Oid get target => Oid(reference_bindings.target(_branchPointer));
|
||||||
|
|
|
@ -11,13 +11,13 @@ class Commit {
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Commit(this._commitPointer);
|
Commit(this._commitPointer);
|
||||||
|
|
||||||
/// Lookups commit object for provided [id] in a [repo]sitory.
|
/// Lookups commit object for provided [oid] in a [repo]sitory.
|
||||||
///
|
///
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Commit.lookup({required Repository repo, required Oid id}) {
|
Commit.lookup({required Repository repo, required Oid oid}) {
|
||||||
_commitPointer = bindings.lookup(
|
_commitPointer = bindings.lookup(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
oidPointer: id.pointer,
|
oidPointer: oid.pointer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ class Commit {
|
||||||
/// The returned message will be slightly prettified by removing any potential leading newlines.
|
/// The returned message will be slightly prettified by removing any potential leading newlines.
|
||||||
String get message => bindings.message(_commitPointer);
|
String get message => bindings.message(_commitPointer);
|
||||||
|
|
||||||
/// Returns the id of a commit.
|
/// Returns the [Oid] of a commit.
|
||||||
Oid get id => Oid(bindings.id(_commitPointer));
|
Oid get oid => Oid(bindings.id(_commitPointer));
|
||||||
|
|
||||||
/// Returns the commit time (i.e. committer time) of a commit.
|
/// Returns the commit time (i.e. committer time) of a commit.
|
||||||
int get time => bindings.time(_commitPointer);
|
int get time => bindings.time(_commitPointer);
|
||||||
|
@ -79,7 +79,7 @@ class Commit {
|
||||||
/// Returns the author of a commit.
|
/// Returns the author of a commit.
|
||||||
Signature get author => Signature(bindings.author(_commitPointer));
|
Signature get author => Signature(bindings.author(_commitPointer));
|
||||||
|
|
||||||
/// Returns list of parent commits.
|
/// Returns list of parent commits [Oid]s.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
List<Oid> get parents {
|
List<Oid> get parents {
|
||||||
|
@ -109,5 +109,5 @@ class Commit {
|
||||||
void free() => bindings.free(_commitPointer);
|
void free() => bindings.free(_commitPointer);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'Commit{id: $id}';
|
String toString() => 'Commit{oid: $oid}';
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,9 +107,7 @@ class Diff {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculate the patch ID for the given patch.
|
/// Calculates a stable patch [Oid] for the given patch by summing the hash of the file diffs,
|
||||||
///
|
|
||||||
/// Calculate a stable patch ID for the given patch by summing the hash of the file diffs,
|
|
||||||
/// ignoring whitespace and line numbers. This can be used to derive whether two diffs are
|
/// ignoring whitespace and line numbers. This can be used to derive whether two diffs are
|
||||||
/// the same with a high probability.
|
/// the same with a high probability.
|
||||||
///
|
///
|
||||||
|
@ -181,9 +179,9 @@ class DiffFile {
|
||||||
|
|
||||||
final git_diff_file _diffFile;
|
final git_diff_file _diffFile;
|
||||||
|
|
||||||
/// Returns oid of the item. If the entry represents an absent side of a diff
|
/// Returns [Oid] of the item. If the entry represents an absent side of a diff
|
||||||
/// then the oid will be zeroes.
|
/// then the oid will be zeroes.
|
||||||
Oid get id => Oid.fromRaw(_diffFile.id);
|
Oid get oid => Oid.fromRaw(_diffFile.id);
|
||||||
|
|
||||||
/// Returns path to the entry relative to the working directory of the repository.
|
/// Returns path to the entry relative to the working directory of the repository.
|
||||||
String get path => _diffFile.path.cast<Utf8>().toDartString();
|
String get path => _diffFile.path.cast<Utf8>().toDartString();
|
||||||
|
|
|
@ -153,7 +153,7 @@ class Index with IterableMixin<IndexEntry> {
|
||||||
///
|
///
|
||||||
/// This method will scan the index and write a representation of its current state back to disk;
|
/// This method will scan the index and write a representation of its current state back to disk;
|
||||||
/// it recursively creates tree objects for each of the subtrees stored in the index, but only
|
/// it recursively creates tree objects for each of the subtrees stored in the index, but only
|
||||||
/// returns the OID of the root tree. This is the OID that can be used e.g. to create a commit.
|
/// returns the [Oid] of the root tree. This is the OID that can be used e.g. to create a commit.
|
||||||
///
|
///
|
||||||
/// The index must not contain any file in conflict.
|
/// The index must not contain any file in conflict.
|
||||||
///
|
///
|
||||||
|
@ -233,18 +233,20 @@ class IndexEntry {
|
||||||
/// Pointer to memory address for allocated index entry object.
|
/// Pointer to memory address for allocated index entry object.
|
||||||
Pointer<git_index_entry> get pointer => _indexEntryPointer;
|
Pointer<git_index_entry> get pointer => _indexEntryPointer;
|
||||||
|
|
||||||
/// Unique identity of the index entry.
|
/// Returns inique identity of the index entry.
|
||||||
Oid get id => Oid.fromRaw(_indexEntryPointer.ref.id);
|
Oid get oid => Oid.fromRaw(_indexEntryPointer.ref.id);
|
||||||
|
|
||||||
set id(Oid oid) => _indexEntryPointer.ref.id = oid.pointer.ref;
|
/// Sets inique identity of the index entry.
|
||||||
|
set oid(Oid oid) => _indexEntryPointer.ref.id = oid.pointer.ref;
|
||||||
|
|
||||||
/// Path of the index entry.
|
/// Returns path of the index entry.
|
||||||
String get path => _indexEntryPointer.ref.path.cast<Utf8>().toDartString();
|
String get path => _indexEntryPointer.ref.path.cast<Utf8>().toDartString();
|
||||||
|
|
||||||
|
/// Sets path of the index entry.
|
||||||
set path(String path) =>
|
set path(String path) =>
|
||||||
_indexEntryPointer.ref.path = path.toNativeUtf8().cast<Int8>();
|
_indexEntryPointer.ref.path = path.toNativeUtf8().cast<Int8>();
|
||||||
|
|
||||||
/// Returns id of the index entry as sha-1 hex.
|
/// Returns id of the index entry as sha hex.
|
||||||
String get sha => _oidToHex(_indexEntryPointer.ref.id);
|
String get sha => _oidToHex(_indexEntryPointer.ref.id);
|
||||||
|
|
||||||
/// Returns the UNIX file attributes of a index entry.
|
/// Returns the UNIX file attributes of a index entry.
|
||||||
|
|
|
@ -5,10 +5,10 @@ import 'bindings/note.dart' as bindings;
|
||||||
|
|
||||||
class Note {
|
class Note {
|
||||||
/// Initializes a new instance of the [Note] class from provided
|
/// Initializes a new instance of the [Note] class from provided
|
||||||
/// pointer to note and annotatedId objects in memory.
|
/// pointer to note and annotatedOid objects in memory.
|
||||||
Note(this._notePointer, this._annotatedIdPointer);
|
Note(this._notePointer, this._annotatedOidPointer);
|
||||||
|
|
||||||
/// Reads the note for an [annotatedId].
|
/// Reads the note for an [annotatedOid].
|
||||||
///
|
///
|
||||||
/// IMPORTANT: Notes must be freed manually when no longer needed to prevent
|
/// IMPORTANT: Notes must be freed manually when no longer needed to prevent
|
||||||
/// memory leak.
|
/// memory leak.
|
||||||
|
@ -16,31 +16,31 @@ class Note {
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Note.lookup({
|
Note.lookup({
|
||||||
required Repository repo,
|
required Repository repo,
|
||||||
required Oid annotatedId,
|
required Oid annotatedOid,
|
||||||
String notesRef = 'refs/notes/commits',
|
String notesRef = 'refs/notes/commits',
|
||||||
}) {
|
}) {
|
||||||
_notePointer = bindings.lookup(
|
_notePointer = bindings.lookup(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
oidPointer: annotatedId.pointer,
|
oidPointer: annotatedOid.pointer,
|
||||||
notesRef: notesRef,
|
notesRef: notesRef,
|
||||||
);
|
);
|
||||||
_annotatedIdPointer = annotatedId.pointer;
|
_annotatedOidPointer = annotatedOid.pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pointer to memory address for allocated note object.
|
/// Pointer to memory address for allocated note object.
|
||||||
late final Pointer<git_note> _notePointer;
|
late final Pointer<git_note> _notePointer;
|
||||||
|
|
||||||
/// Pointer to memory address for allocated annotetedId object.
|
/// Pointer to memory address for allocated annotetedOid object.
|
||||||
late final Pointer<git_oid> _annotatedIdPointer;
|
late final Pointer<git_oid> _annotatedOidPointer;
|
||||||
|
|
||||||
/// Adds a note for an [annotatedId].
|
/// Adds a note for an [annotatedOid].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static Oid create({
|
static Oid create({
|
||||||
required Repository repo,
|
required Repository repo,
|
||||||
required Signature author,
|
required Signature author,
|
||||||
required Signature committer,
|
required Signature committer,
|
||||||
required Oid annotatedId,
|
required Oid annotatedOid,
|
||||||
required String note,
|
required String note,
|
||||||
String notesRef = 'refs/notes/commits',
|
String notesRef = 'refs/notes/commits',
|
||||||
bool force = false,
|
bool force = false,
|
||||||
|
@ -49,19 +49,19 @@ class Note {
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
authorPointer: author.pointer,
|
authorPointer: author.pointer,
|
||||||
committerPointer: committer.pointer,
|
committerPointer: committer.pointer,
|
||||||
oidPointer: annotatedId.pointer,
|
oidPointer: annotatedOid.pointer,
|
||||||
note: note,
|
note: note,
|
||||||
notesRef: notesRef,
|
notesRef: notesRef,
|
||||||
force: force,
|
force: force,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes the note for an [annotatedId].
|
/// Deletes the note for an [annotatedOid].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static void delete({
|
static void delete({
|
||||||
required Repository repo,
|
required Repository repo,
|
||||||
required Oid annotatedId,
|
required Oid annotatedOid,
|
||||||
required Signature author,
|
required Signature author,
|
||||||
required Signature committer,
|
required Signature committer,
|
||||||
String notesRef = 'refs/notes/commits',
|
String notesRef = 'refs/notes/commits',
|
||||||
|
@ -70,7 +70,7 @@ class Note {
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
authorPointer: author.pointer,
|
authorPointer: author.pointer,
|
||||||
committerPointer: committer.pointer,
|
committerPointer: committer.pointer,
|
||||||
oidPointer: annotatedId.pointer,
|
oidPointer: annotatedOid.pointer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,19 +85,19 @@ class Note {
|
||||||
return notesPointers
|
return notesPointers
|
||||||
.map((e) => Note(
|
.map((e) => Note(
|
||||||
e['note'] as Pointer<git_note>,
|
e['note'] as Pointer<git_note>,
|
||||||
e['annotatedId'] as Pointer<git_oid>,
|
e['annotatedOid'] as Pointer<git_oid>,
|
||||||
))
|
))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the note object's [Oid].
|
/// Returns the note object's [Oid].
|
||||||
Oid get id => Oid(bindings.id(_notePointer));
|
Oid get oid => Oid(bindings.id(_notePointer));
|
||||||
|
|
||||||
/// Returns the note message.
|
/// Returns the note message.
|
||||||
String get message => bindings.message(_notePointer);
|
String get message => bindings.message(_notePointer);
|
||||||
|
|
||||||
/// Returns the [Oid] of the git object being annotated.
|
/// Returns the [Oid] of the git object being annotated.
|
||||||
Oid get annotatedId => Oid(_annotatedIdPointer);
|
Oid get annotatedOid => Oid(_annotatedOidPointer);
|
||||||
|
|
||||||
/// Releases memory allocated for note object.
|
/// Releases memory allocated for note object.
|
||||||
void free() => bindings.free(_notePointer);
|
void free() => bindings.free(_notePointer);
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Odb {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns list of all objects available in the database.
|
/// Returns list of all objects [Oid]s available in the database.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
List<Oid> get objects => bindings.objects(_odbPointer);
|
List<Oid> get objects => bindings.objects(_odbPointer);
|
||||||
|
@ -102,10 +102,10 @@ class OdbObject {
|
||||||
/// Pointer to memory address for allocated odbObject object.
|
/// Pointer to memory address for allocated odbObject object.
|
||||||
final Pointer<git_odb_object> _odbObjectPointer;
|
final Pointer<git_odb_object> _odbObjectPointer;
|
||||||
|
|
||||||
/// Returns the OID of an ODB object.
|
/// Returns the [Oid] of an ODB object.
|
||||||
///
|
///
|
||||||
/// This is the OID from which the object was read from.
|
/// This is the [Oid] from which the object was read from.
|
||||||
Oid get id => Oid(bindings.objectId(_odbObjectPointer));
|
Oid get oid => Oid(bindings.objectId(_odbObjectPointer));
|
||||||
|
|
||||||
/// Returns the type of an ODB object.
|
/// Returns the type of an ODB object.
|
||||||
GitObject get type {
|
GitObject get type {
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Oid {
|
||||||
/// Pointer to memory address for allocated oid object.
|
/// Pointer to memory address for allocated oid object.
|
||||||
Pointer<git_oid> get pointer => _oidPointer;
|
Pointer<git_oid> get pointer => _oidPointer;
|
||||||
|
|
||||||
/// Returns hexadecimal SHA-1 string.
|
/// Returns hexadecimal SHA string.
|
||||||
String get sha => bindings.toSHA(_oidPointer);
|
String get sha => bindings.toSHA(_oidPointer);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -126,9 +126,9 @@ class RebaseOperation {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The commit ID being cherry-picked. This will be populated for
|
/// Returns the commit [Oid] being cherry-picked. This will be populated for
|
||||||
/// all operations except those of type [GitRebaseOperation.exec].
|
/// all operations except those of type [GitRebaseOperation.exec].
|
||||||
Oid get id => Oid.fromRaw(_rebaseOperationPointer.ref.id);
|
Oid get oid => Oid.fromRaw(_rebaseOperationPointer.ref.id);
|
||||||
|
|
||||||
/// The executable the user has requested be run. This will only
|
/// The executable the user has requested be run. This will only
|
||||||
/// be populated for operations of type [GitRebaseOperation.exec].
|
/// be populated for operations of type [GitRebaseOperation.exec].
|
||||||
|
|
|
@ -149,9 +149,9 @@ class Reference {
|
||||||
: ReferenceType.symbolic;
|
: ReferenceType.symbolic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the OID pointed to by a reference.
|
/// Returns the [Oid] pointed to by a reference.
|
||||||
///
|
///
|
||||||
/// Throws an exception if error occured.
|
/// Throws an [Exception] if error occured.
|
||||||
Oid get target {
|
Oid get target {
|
||||||
late final Pointer<git_oid> oidPointer;
|
late final Pointer<git_oid> oidPointer;
|
||||||
|
|
||||||
|
@ -163,37 +163,33 @@ class Reference {
|
||||||
return Oid(oidPointer);
|
return Oid(oidPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Conditionally creates a new reference with the same name as the given reference
|
/// Updates the [target] of this reference.
|
||||||
/// but a different OID target.
|
|
||||||
///
|
///
|
||||||
/// The new reference will be written to disk, overwriting the given reference.
|
/// [target] being either Oid for direct reference or String reference name for symbolic
|
||||||
|
/// reference.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if [target] is not
|
||||||
void setTarget({required String target, String? logMessage}) {
|
/// [Oid] or String.
|
||||||
late final Oid oid;
|
void setTarget({required Object target, String? logMessage}) {
|
||||||
final owner = bindings.owner(_refPointer);
|
if (target is Oid) {
|
||||||
|
final newPointer = bindings.setTarget(
|
||||||
if (isValidShaHex(target)) {
|
|
||||||
final repo = Repository(owner);
|
|
||||||
oid = Oid.fromSHA(repo: repo, sha: target);
|
|
||||||
} else {
|
|
||||||
final ref = Reference(bindings.lookup(repoPointer: owner, name: target));
|
|
||||||
oid = ref.target;
|
|
||||||
ref.free();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == ReferenceType.direct) {
|
|
||||||
_refPointer = bindings.setTarget(
|
|
||||||
refPointer: _refPointer,
|
refPointer: _refPointer,
|
||||||
oidPointer: oid.pointer,
|
oidPointer: target.pointer,
|
||||||
logMessage: logMessage,
|
logMessage: logMessage,
|
||||||
);
|
);
|
||||||
} else {
|
free();
|
||||||
_refPointer = bindings.setTargetSymbolic(
|
_refPointer = newPointer;
|
||||||
|
} else if (target is String) {
|
||||||
|
final newPointer = bindings.setTargetSymbolic(
|
||||||
refPointer: _refPointer,
|
refPointer: _refPointer,
|
||||||
target: target,
|
target: target,
|
||||||
logMessage: logMessage,
|
logMessage: logMessage,
|
||||||
);
|
);
|
||||||
|
free();
|
||||||
|
_refPointer = newPointer;
|
||||||
|
} else {
|
||||||
|
throw ArgumentError.value(
|
||||||
|
'$target must be either Oid or String reference name');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,15 +204,19 @@ class Repository {
|
||||||
///
|
///
|
||||||
/// Otherwise, the HEAD will be detached and will directly point to the Commit.
|
/// Otherwise, the HEAD will be detached and will directly point to the Commit.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided [target]
|
||||||
void setHead(String target) {
|
/// is not Oid or String.
|
||||||
if (isValidShaHex(target)) {
|
void setHead(Object target) {
|
||||||
|
if (target is Oid) {
|
||||||
bindings.setHeadDetached(
|
bindings.setHeadDetached(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
commitishPointer: this[target].pointer,
|
commitishPointer: target.pointer,
|
||||||
);
|
);
|
||||||
} else {
|
} else if (target is String) {
|
||||||
bindings.setHead(repoPointer: _repoPointer, refname: target);
|
bindings.setHead(repoPointer: _repoPointer, refname: target);
|
||||||
|
} else {
|
||||||
|
throw ArgumentError.value(
|
||||||
|
'$target must be either Oid or String reference name');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,8 +271,9 @@ class Repository {
|
||||||
/// (merge, cherry-pick, etc) is in progress.
|
/// (merge, cherry-pick, etc) is in progress.
|
||||||
GitRepositoryState get state {
|
GitRepositoryState get state {
|
||||||
final stateInt = bindings.state(_repoPointer);
|
final stateInt = bindings.state(_repoPointer);
|
||||||
return GitRepositoryState.values
|
return GitRepositoryState.values.singleWhere(
|
||||||
.singleWhere((state) => stateInt == state.value);
|
(state) => stateInt == state.value,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes all the metadata associated with an ongoing command like
|
/// Removes all the metadata associated with an ongoing command like
|
||||||
|
@ -424,11 +429,11 @@ class Repository {
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Odb get odb => Odb(bindings.odb(_repoPointer));
|
Odb get odb => Odb(bindings.odb(_repoPointer));
|
||||||
|
|
||||||
/// Lookups a tree object for provided [id].
|
/// Lookups a tree object for provided [oid].
|
||||||
///
|
///
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Tree lookupTree(Oid id) {
|
Tree lookupTree(Oid oid) {
|
||||||
return Tree.lookup(repo: this, id: id);
|
return Tree.lookup(repo: this, oid: oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new action signature with default user and now timestamp.
|
/// Creates a new action signature with default user and now timestamp.
|
||||||
|
@ -439,17 +444,17 @@ class Repository {
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Signature get defaultSignature => Signature.defaultSignature(this);
|
Signature get defaultSignature => Signature.defaultSignature(this);
|
||||||
|
|
||||||
/// Returns the list of commits starting from provided [sha] hex string.
|
/// Returns the list of commits starting from provided commit [oid].
|
||||||
///
|
///
|
||||||
/// If [sorting] isn't provided default will be used (reverse chronological order, like in git).
|
/// If [sorting] isn't provided default will be used (reverse chronological order, like in git).
|
||||||
List<Commit> log({
|
List<Commit> log({
|
||||||
required String sha,
|
required Oid oid,
|
||||||
Set<GitSort> sorting = const {GitSort.none},
|
Set<GitSort> sorting = const {GitSort.none},
|
||||||
}) {
|
}) {
|
||||||
final walker = RevWalk(this);
|
final walker = RevWalk(this);
|
||||||
|
|
||||||
walker.sorting(sorting);
|
walker.sorting(sorting);
|
||||||
walker.push(this[sha]);
|
walker.push(oid);
|
||||||
final result = walker.walk();
|
final result = walker.walk();
|
||||||
|
|
||||||
walker.free();
|
walker.free();
|
||||||
|
@ -468,11 +473,11 @@ class Repository {
|
||||||
return RevParse.single(repo: this, spec: spec);
|
return RevParse.single(repo: this, spec: spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lookups commit object for provided [id].
|
/// Lookups commit object for provided [oid].
|
||||||
///
|
///
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Commit lookupCommit(Oid id) {
|
Commit lookupCommit(Oid oid) {
|
||||||
return Commit.lookup(repo: this, id: id);
|
return Commit.lookup(repo: this, oid: oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates new commit in the repository.
|
/// Creates new commit in the repository.
|
||||||
|
@ -529,11 +534,11 @@ class Repository {
|
||||||
return RevParse.range(repo: this, spec: spec);
|
return RevParse.range(repo: this, spec: spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lookups a blob object for provided [id].
|
/// Lookups a blob object for provided [oid].
|
||||||
///
|
///
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Blob lookupBlob(Oid id) {
|
Blob lookupBlob(Oid oid) {
|
||||||
return Blob.lookup(repo: this, id: id);
|
return Blob.lookup(repo: this, oid: oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new blob from a [content] string and writes it to ODB.
|
/// Creates a new blob from a [content] string and writes it to ODB.
|
||||||
|
@ -564,10 +569,10 @@ class Repository {
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
List<String> get tags => Tag.list(this);
|
List<String> get tags => Tag.list(this);
|
||||||
|
|
||||||
/// Lookups tag object for provided [id].
|
/// Lookups tag object for provided [oid].
|
||||||
///
|
///
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Tag lookupTag(Oid id) => Tag.lookup(repo: this, id: id);
|
Tag lookupTag(Oid oid) => Tag.lookup(repo: this, oid: oid);
|
||||||
|
|
||||||
/// Creates a new tag in the repository for provided [target] object.
|
/// Creates a new tag in the repository for provided [target] object.
|
||||||
///
|
///
|
||||||
|
@ -753,11 +758,11 @@ class Repository {
|
||||||
/// Finds a merge base between two commits.
|
/// Finds a merge base between two commits.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Oid mergeBase({required String a, required String b}) {
|
Oid mergeBase({required Oid a, required Oid b}) {
|
||||||
return Oid(merge_bindings.mergeBase(
|
return Oid(merge_bindings.mergeBase(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
aPointer: this[a].pointer,
|
aPointer: a.pointer,
|
||||||
bPointer: this[b].pointer,
|
bPointer: b.pointer,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -797,7 +802,7 @@ class Repository {
|
||||||
return [analysisSet, mergePreference];
|
return [analysisSet, mergePreference];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Merges the given commit(s) oid into HEAD, writing the results into the working directory.
|
/// Merges the given commit [oid] into HEAD, writing the results into the working directory.
|
||||||
/// Any changes are staged for commit and any conflicts are written to the index. Callers
|
/// Any changes are staged for commit and any conflicts are written to the index. Callers
|
||||||
/// should inspect the repository's index after this completes, resolve any conflicts and
|
/// should inspect the repository's index after this completes, resolve any conflicts and
|
||||||
/// prepare a commit.
|
/// prepare a commit.
|
||||||
|
@ -909,7 +914,7 @@ class Repository {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cherry-picks the provided commit, producing changes in the index and working directory.
|
/// Cherry-picks the provided [commit], producing changes in the index and working directory.
|
||||||
///
|
///
|
||||||
/// Any changes are staged for commit and any conflicts are written to the index. Callers
|
/// Any changes are staged for commit and any conflicts are written to the index. Callers
|
||||||
/// should inspect the repository's index after this completes, resolve any conflicts and
|
/// should inspect the repository's index after this completes, resolve any conflicts and
|
||||||
|
@ -982,14 +987,14 @@ class Repository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the current head to the specified commit and optionally resets the index
|
/// Sets the current head to the specified commit [oid] and optionally resets the index
|
||||||
/// and working tree to match.
|
/// and working tree to match.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void reset({required String target, required GitReset resetType}) {
|
void reset({required Oid oid, required GitReset resetType}) {
|
||||||
final object = object_bindings.lookup(
|
final object = object_bindings.lookup(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
oidPointer: this[target].pointer,
|
oidPointer: oid.pointer,
|
||||||
type: GitObject.any.value,
|
type: GitObject.any.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1296,30 +1301,30 @@ class Repository {
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
List<Note> get notes => Note.list(this);
|
List<Note> get notes => Note.list(this);
|
||||||
|
|
||||||
/// Reads the note for an [annotatedId].
|
/// Reads the note for an [annotatedOid].
|
||||||
///
|
///
|
||||||
/// IMPORTANT: Notes must be freed manually when no longer needed to prevent
|
/// IMPORTANT: Notes must be freed manually when no longer needed to prevent
|
||||||
/// memory leak.
|
/// memory leak.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Note lookupNote({
|
Note lookupNote({
|
||||||
required Oid annotatedId,
|
required Oid annotatedOid,
|
||||||
String notesRef = 'refs/notes/commits',
|
String notesRef = 'refs/notes/commits',
|
||||||
}) {
|
}) {
|
||||||
return Note.lookup(
|
return Note.lookup(
|
||||||
repo: this,
|
repo: this,
|
||||||
annotatedId: annotatedId,
|
annotatedOid: annotatedOid,
|
||||||
notesRef: notesRef,
|
notesRef: notesRef,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a note for an [annotatedId].
|
/// Adds a note for an [annotatedOid].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
Oid createNote({
|
Oid createNote({
|
||||||
required Signature author,
|
required Signature author,
|
||||||
required Signature committer,
|
required Signature committer,
|
||||||
required Oid annotatedId,
|
required Oid annotatedOid,
|
||||||
required String note,
|
required String note,
|
||||||
String notesRef = 'refs/notes/commits',
|
String notesRef = 'refs/notes/commits',
|
||||||
bool force = false,
|
bool force = false,
|
||||||
|
@ -1328,25 +1333,25 @@ class Repository {
|
||||||
repo: this,
|
repo: this,
|
||||||
author: author,
|
author: author,
|
||||||
committer: committer,
|
committer: committer,
|
||||||
annotatedId: annotatedId,
|
annotatedOid: annotatedOid,
|
||||||
note: note,
|
note: note,
|
||||||
notesRef: notesRef,
|
notesRef: notesRef,
|
||||||
force: force,
|
force: force,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes the note for an [annotatedId].
|
/// Deletes the note for an [annotatedOid].
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void deleteNote({
|
void deleteNote({
|
||||||
required Oid annotatedId,
|
required Oid annotatedOid,
|
||||||
required Signature author,
|
required Signature author,
|
||||||
required Signature committer,
|
required Signature committer,
|
||||||
String notesRef = 'refs/notes/commits',
|
String notesRef = 'refs/notes/commits',
|
||||||
}) {
|
}) {
|
||||||
Note.delete(
|
Note.delete(
|
||||||
repo: this,
|
repo: this,
|
||||||
annotatedId: annotatedId,
|
annotatedOid: annotatedOid,
|
||||||
author: author,
|
author: author,
|
||||||
committer: committer,
|
committer: committer,
|
||||||
notesRef: notesRef,
|
notesRef: notesRef,
|
||||||
|
@ -1359,11 +1364,11 @@ class Repository {
|
||||||
/// `git merge-base --is-ancestor`.
|
/// `git merge-base --is-ancestor`.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
bool descendantOf({required String commitSHA, required String ancestorSHA}) {
|
bool descendantOf({required Oid commit, required Oid ancestor}) {
|
||||||
return graph_bindings.descendantOf(
|
return graph_bindings.descendantOf(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
commitPointer: this[commitSHA].pointer,
|
commitPointer: commit.pointer,
|
||||||
ancestorPointer: this[ancestorSHA].pointer,
|
ancestorPointer: ancestor.pointer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1373,13 +1378,13 @@ class Repository {
|
||||||
/// but it helps to think of one as a branch and the other as its upstream, the ahead and
|
/// but it helps to think of one as a branch and the other as its upstream, the ahead and
|
||||||
/// behind values will be what git would report for the branches.
|
/// behind values will be what git would report for the branches.
|
||||||
List<int> aheadBehind({
|
List<int> aheadBehind({
|
||||||
required String localSHA,
|
required Oid local,
|
||||||
required String upstreamSHA,
|
required Oid upstream,
|
||||||
}) {
|
}) {
|
||||||
return graph_bindings.aheadBehind(
|
return graph_bindings.aheadBehind(
|
||||||
repoPointer: _repoPointer,
|
repoPointer: _repoPointer,
|
||||||
localPointer: this[localSHA].pointer,
|
localPointer: local.pointer,
|
||||||
upstreamPointer: this[upstreamSHA].pointer,
|
upstreamPointer: upstream.pointer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,14 @@ class RevWalk {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a new root for the traversal.
|
/// Adds a new root commit [oid] for the traversal.
|
||||||
///
|
///
|
||||||
/// The pushed commit will be marked as one of the roots from which to start the walk.
|
/// The pushed commit will be marked as one of the roots from which to start the walk.
|
||||||
/// This commit may not be walked if it or a child is hidden.
|
/// This commit may not be walked if it or a child is hidden.
|
||||||
///
|
///
|
||||||
/// At least one commit must be pushed onto the walker before a walk can be started.
|
/// At least one commit must be pushed onto the walker before a walk can be started.
|
||||||
///
|
///
|
||||||
/// The given id must belong to a committish on the walked repository.
|
/// The given [oid] must belong to a committish on the walked repository.
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
void push(Oid oid) {
|
void push(Oid oid) {
|
||||||
|
@ -54,7 +54,7 @@ class RevWalk {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Marks a commit (and its ancestors) uninteresting for the output.
|
/// Marks a commit [oid] (and its ancestors) uninteresting for the output.
|
||||||
///
|
///
|
||||||
/// The given id must belong to a committish on the walked repository.
|
/// The given id must belong to a committish on the walked repository.
|
||||||
///
|
///
|
||||||
|
|
|
@ -216,26 +216,26 @@ class Submodule {
|
||||||
|
|
||||||
/// Returns the [Oid] for the submodule in the current HEAD tree or
|
/// Returns the [Oid] for the submodule in the current HEAD tree or
|
||||||
/// null if submodule is not in the HEAD.
|
/// null if submodule is not in the HEAD.
|
||||||
Oid? get headId {
|
Oid? get headOid {
|
||||||
final result = bindings.headId(_submodulePointer);
|
final result = bindings.headId(_submodulePointer);
|
||||||
return result == null ? null : Oid(result);
|
return result == null ? null : Oid(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the [Oid] for the submodule in the index or null if submodule
|
/// Returns the [Oid] for the submodule in the index or null if submodule
|
||||||
/// is not in the index.
|
/// is not in the index.
|
||||||
Oid? get indexId {
|
Oid? get indexOid {
|
||||||
final result = bindings.indexId(_submodulePointer);
|
final result = bindings.indexId(_submodulePointer);
|
||||||
return result == null ? null : Oid(result);
|
return result == null ? null : Oid(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the OID for the submodule in the current working directory or null if
|
/// Returns the [Oid] for the submodule in the current working directory or null if
|
||||||
/// submodule is not checked out.
|
/// submodule is not checked out.
|
||||||
///
|
///
|
||||||
/// This returns the OID that corresponds to looking up `HEAD` in the checked out
|
/// This returns the [Oid] that corresponds to looking up `HEAD` in the checked out
|
||||||
/// submodule. If there are pending changes in the index or anything else, this
|
/// submodule. If there are pending changes in the index or anything else, this
|
||||||
/// won't notice that. You should call [status] for a more complete picture about
|
/// won't notice that. You should call [status] for a more complete picture about
|
||||||
/// the state of the working directory.
|
/// the state of the working directory.
|
||||||
Oid? get workdirId {
|
Oid? get workdirOid {
|
||||||
final result = bindings.workdirId(_submodulePointer);
|
final result = bindings.workdirId(_submodulePointer);
|
||||||
return result == null ? null : Oid(result);
|
return result == null ? null : Oid(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,13 @@ class Tag {
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Tag(this._tagPointer);
|
Tag(this._tagPointer);
|
||||||
|
|
||||||
/// Lookups tag object for provided [id] in a [repo]sitory.
|
/// Lookups tag object for provided [oid] in a [repo]sitory.
|
||||||
///
|
///
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Tag.lookup({required Repository repo, required Oid id}) {
|
Tag.lookup({required Repository repo, required Oid oid}) {
|
||||||
_tagPointer = bindings.lookup(
|
_tagPointer = bindings.lookup(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
oidPointer: id.pointer,
|
oidPointer: oid.pointer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +112,8 @@ class Tag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the id of a tag.
|
/// Returns the [Oid] of a tag.
|
||||||
Oid get id => Oid(bindings.id(_tagPointer));
|
Oid get oid => Oid(bindings.id(_tagPointer));
|
||||||
|
|
||||||
/// Returns the name of a tag.
|
/// Returns the name of a tag.
|
||||||
String get name => bindings.name(_tagPointer);
|
String get name => bindings.name(_tagPointer);
|
||||||
|
|
|
@ -11,13 +11,13 @@ class Tree {
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Tree(this._treePointer);
|
Tree(this._treePointer);
|
||||||
|
|
||||||
/// Lookups a tree object for provided [id] in a [repo]sitory.
|
/// Lookups a tree object for provided [oid] in a [repo]sitory.
|
||||||
///
|
///
|
||||||
/// Should be freed to release allocated memory.
|
/// Should be freed to release allocated memory.
|
||||||
Tree.lookup({required Repository repo, required Oid id}) {
|
Tree.lookup({required Repository repo, required Oid oid}) {
|
||||||
_treePointer = bindings.lookup(
|
_treePointer = bindings.lookup(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
oidPointer: id.pointer,
|
oidPointer: oid.pointer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ class Tree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the Oid of a tree.
|
/// Returns the [Oid] of a tree.
|
||||||
Oid get id => Oid(bindings.id(_treePointer));
|
Oid get oid => Oid(bindings.id(_treePointer));
|
||||||
|
|
||||||
/// Get the number of entries listed in a tree.
|
/// Get the number of entries listed in a tree.
|
||||||
int get length => bindings.entryCount(_treePointer);
|
int get length => bindings.entryCount(_treePointer);
|
||||||
|
@ -141,8 +141,8 @@ class TreeEntry {
|
||||||
/// Pointer to memory address for allocated tree entry object.
|
/// Pointer to memory address for allocated tree entry object.
|
||||||
final Pointer<git_tree_entry> _treeEntryPointer;
|
final Pointer<git_tree_entry> _treeEntryPointer;
|
||||||
|
|
||||||
/// Returns the Oid of the object pointed by the entry.
|
/// Returns the [Oid] of the object pointed by the entry.
|
||||||
Oid get id => Oid(bindings.entryId(_treeEntryPointer));
|
Oid get oid => Oid(bindings.entryId(_treeEntryPointer));
|
||||||
|
|
||||||
/// Returns the filename of a tree entry.
|
/// Returns the filename of a tree entry.
|
||||||
String get name => bindings.entryName(_treeEntryPointer);
|
String get name => bindings.entryName(_treeEntryPointer);
|
||||||
|
@ -201,5 +201,5 @@ class TreeEntry {
|
||||||
void free() => bindings.entryFree(_treeEntryPointer);
|
void free() => bindings.entryFree(_treeEntryPointer);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'TreeEntry{id: $id, name: $name}';
|
String toString() => 'TreeEntry{oid: $oid, name: $name}';
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,19 +28,19 @@ void main() {
|
||||||
|
|
||||||
hunks = [
|
hunks = [
|
||||||
{
|
{
|
||||||
'finalCommitId': 'fc38877b2552ab554752d9a77e1f48f738cca79b',
|
'finalCommitOid': 'fc38877b2552ab554752d9a77e1f48f738cca79b',
|
||||||
'finalStartLineNumber': 1,
|
'finalStartLineNumber': 1,
|
||||||
'finalCommitter': sig1,
|
'finalCommitter': sig1,
|
||||||
'originCommitId': 'fc38877b2552ab554752d9a77e1f48f738cca79b',
|
'originCommitOid': 'fc38877b2552ab554752d9a77e1f48f738cca79b',
|
||||||
'originStartLineNumber': 1,
|
'originStartLineNumber': 1,
|
||||||
'originCommitter': sig1,
|
'originCommitter': sig1,
|
||||||
'isBoundary': false,
|
'isBoundary': false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'finalCommitId': 'a07a01e325c2c04e05d2450ad37785fbfe0a0014',
|
'finalCommitOid': 'a07a01e325c2c04e05d2450ad37785fbfe0a0014',
|
||||||
'finalStartLineNumber': 2,
|
'finalStartLineNumber': 2,
|
||||||
'finalCommitter': sig2,
|
'finalCommitter': sig2,
|
||||||
'originCommitId': 'a07a01e325c2c04e05d2450ad37785fbfe0a0014',
|
'originCommitOid': 'a07a01e325c2c04e05d2450ad37785fbfe0a0014',
|
||||||
'originStartLineNumber': 2,
|
'originStartLineNumber': 2,
|
||||||
'originCommitter': sig2,
|
'originCommitter': sig2,
|
||||||
'isBoundary': false,
|
'isBoundary': false,
|
||||||
|
@ -63,10 +63,10 @@ void main() {
|
||||||
|
|
||||||
for (var i = 0; i < blame.length; i++) {
|
for (var i = 0; i < blame.length; i++) {
|
||||||
expect(blame[i].linesCount, 1);
|
expect(blame[i].linesCount, 1);
|
||||||
expect(blame[i].finalCommitId.sha, hunks[i]['finalCommitId']);
|
expect(blame[i].finalCommitOid.sha, hunks[i]['finalCommitOid']);
|
||||||
expect(blame[i].finalStartLineNumber, hunks[i]['finalStartLineNumber']);
|
expect(blame[i].finalStartLineNumber, hunks[i]['finalStartLineNumber']);
|
||||||
expect(blame[i].finalCommitter, hunks[i]['finalCommitter']);
|
expect(blame[i].finalCommitter, hunks[i]['finalCommitter']);
|
||||||
expect(blame[i].originCommitId.sha, hunks[i]['originCommitId']);
|
expect(blame[i].originCommitOid.sha, hunks[i]['originCommitOid']);
|
||||||
expect(
|
expect(
|
||||||
blame[i].originStartLineNumber,
|
blame[i].originStartLineNumber,
|
||||||
hunks[i]['originStartLineNumber'],
|
hunks[i]['originStartLineNumber'],
|
||||||
|
@ -85,10 +85,10 @@ void main() {
|
||||||
final hunk = blame.forLine(1);
|
final hunk = blame.forLine(1);
|
||||||
|
|
||||||
expect(hunk.linesCount, 1);
|
expect(hunk.linesCount, 1);
|
||||||
expect(hunk.finalCommitId.sha, hunks[0]['finalCommitId']);
|
expect(hunk.finalCommitOid.sha, hunks[0]['finalCommitOid']);
|
||||||
expect(hunk.finalStartLineNumber, hunks[0]['finalStartLineNumber']);
|
expect(hunk.finalStartLineNumber, hunks[0]['finalStartLineNumber']);
|
||||||
expect(hunk.finalCommitter, hunks[0]['finalCommitter']);
|
expect(hunk.finalCommitter, hunks[0]['finalCommitter']);
|
||||||
expect(hunk.originCommitId.sha, hunks[0]['originCommitId']);
|
expect(hunk.originCommitOid.sha, hunks[0]['originCommitOid']);
|
||||||
expect(
|
expect(
|
||||||
hunk.originStartLineNumber,
|
hunk.originStartLineNumber,
|
||||||
hunks[0]['originStartLineNumber'],
|
hunks[0]['originStartLineNumber'],
|
||||||
|
@ -117,13 +117,9 @@ void main() {
|
||||||
test(
|
test(
|
||||||
'successfully gets the blame for provided file with newestCommit argument',
|
'successfully gets the blame for provided file with newestCommit argument',
|
||||||
() {
|
() {
|
||||||
final newestCommit = Oid.fromSHA(
|
|
||||||
repo: repo,
|
|
||||||
sha: 'fc38877b2552ab554752d9a77e1f48f738cca79b',
|
|
||||||
);
|
|
||||||
final blame = repo.blame(
|
final blame = repo.blame(
|
||||||
path: 'feature_file',
|
path: 'feature_file',
|
||||||
newestCommit: newestCommit,
|
newestCommit: repo['fc38877b2552ab554752d9a77e1f48f738cca79b'],
|
||||||
flags: {GitBlameFlag.ignoreWhitespace},
|
flags: {GitBlameFlag.ignoreWhitespace},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -132,10 +128,10 @@ void main() {
|
||||||
final hunk = blame.first;
|
final hunk = blame.first;
|
||||||
|
|
||||||
expect(hunk.linesCount, 1);
|
expect(hunk.linesCount, 1);
|
||||||
expect(hunk.finalCommitId.sha, hunks[0]['finalCommitId']);
|
expect(hunk.finalCommitOid.sha, hunks[0]['finalCommitOid']);
|
||||||
expect(hunk.finalStartLineNumber, hunks[0]['finalStartLineNumber']);
|
expect(hunk.finalStartLineNumber, hunks[0]['finalStartLineNumber']);
|
||||||
expect(hunk.finalCommitter, hunks[0]['finalCommitter']);
|
expect(hunk.finalCommitter, hunks[0]['finalCommitter']);
|
||||||
expect(hunk.originCommitId.sha, hunks[0]['originCommitId']);
|
expect(hunk.originCommitOid.sha, hunks[0]['originCommitOid']);
|
||||||
expect(
|
expect(
|
||||||
hunk.originStartLineNumber,
|
hunk.originStartLineNumber,
|
||||||
hunks[0]['originStartLineNumber'],
|
hunks[0]['originStartLineNumber'],
|
||||||
|
|
|
@ -29,7 +29,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns correct values', () {
|
test('returns correct values', () {
|
||||||
expect(blob.id.sha, blobSHA);
|
expect(blob.oid.sha, blobSHA);
|
||||||
expect(blob.isBinary, false);
|
expect(blob.isBinary, false);
|
||||||
expect(blob.size, 13);
|
expect(blob.size, 13);
|
||||||
expect(blob.content, blobContent);
|
expect(blob.content, blobContent);
|
||||||
|
@ -39,7 +39,7 @@ void main() {
|
||||||
final oid = repo.createBlob(newBlobContent);
|
final oid = repo.createBlob(newBlobContent);
|
||||||
final newBlob = repo.lookupBlob(oid);
|
final newBlob = repo.lookupBlob(oid);
|
||||||
|
|
||||||
expect(newBlob.id.sha, '18fdaeef018e57a92bcad2d4a35b577f34089af6');
|
expect(newBlob.oid.sha, '18fdaeef018e57a92bcad2d4a35b577f34089af6');
|
||||||
expect(newBlob.isBinary, false);
|
expect(newBlob.isBinary, false);
|
||||||
expect(newBlob.size, 9);
|
expect(newBlob.size, 9);
|
||||||
expect(newBlob.content, newBlobContent);
|
expect(newBlob.content, newBlobContent);
|
||||||
|
@ -52,7 +52,7 @@ void main() {
|
||||||
final oid = repo.createBlobFromWorkdir('feature_file');
|
final oid = repo.createBlobFromWorkdir('feature_file');
|
||||||
final newBlob = repo.lookupBlob(oid);
|
final newBlob = repo.lookupBlob(oid);
|
||||||
|
|
||||||
expect(newBlob.id.sha, blobSHA);
|
expect(newBlob.oid.sha, blobSHA);
|
||||||
expect(newBlob.isBinary, false);
|
expect(newBlob.isBinary, false);
|
||||||
expect(newBlob.size, 13);
|
expect(newBlob.size, 13);
|
||||||
expect(newBlob.content, blobContent);
|
expect(newBlob.content, blobContent);
|
||||||
|
|
|
@ -54,7 +54,7 @@ void main() {
|
||||||
);
|
);
|
||||||
final featureTree = featureHead.tree;
|
final featureTree = featureHead.tree;
|
||||||
final repoHead = repo.head;
|
final repoHead = repo.head;
|
||||||
expect(repoHead.target.sha, featureHead.id.sha);
|
expect(repoHead.target, featureHead.oid);
|
||||||
expect(repo.status, isEmpty);
|
expect(repo.status, isEmpty);
|
||||||
expect(
|
expect(
|
||||||
featureTree.entries.any((e) => e.name == 'another_feature_file'),
|
featureTree.entries.any((e) => e.name == 'another_feature_file'),
|
||||||
|
|
|
@ -28,7 +28,7 @@ void main() {
|
||||||
mergeCommit = repo['78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8'];
|
mergeCommit = repo['78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8'];
|
||||||
tree = Tree.lookup(
|
tree = Tree.lookup(
|
||||||
repo: repo,
|
repo: repo,
|
||||||
id: repo['7796359a96eb722939c24bafdb1afe9f07f2f628'],
|
oid: repo['7796359a96eb722939c24bafdb1afe9f07f2f628'],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -78,13 +78,13 @@ void main() {
|
||||||
|
|
||||||
final commit = repo.lookupCommit(oid);
|
final commit = repo.lookupCommit(oid);
|
||||||
|
|
||||||
expect(commit.id.sha, oid.sha);
|
expect(commit.oid, oid);
|
||||||
expect(commit.message, message);
|
expect(commit.message, message);
|
||||||
expect(commit.messageEncoding, 'utf-8');
|
expect(commit.messageEncoding, 'utf-8');
|
||||||
expect(commit.author, author);
|
expect(commit.author, author);
|
||||||
expect(commit.committer, commiter);
|
expect(commit.committer, commiter);
|
||||||
expect(commit.time, 124);
|
expect(commit.time, 124);
|
||||||
expect(commit.tree.id, tree.id);
|
expect(commit.tree.oid, tree.oid);
|
||||||
expect(commit.parents.length, 1);
|
expect(commit.parents.length, 1);
|
||||||
expect(commit.parents[0], mergeCommit);
|
expect(commit.parents[0], mergeCommit);
|
||||||
|
|
||||||
|
@ -103,13 +103,13 @@ void main() {
|
||||||
|
|
||||||
final commit = repo.lookupCommit(oid);
|
final commit = repo.lookupCommit(oid);
|
||||||
|
|
||||||
expect(commit.id.sha, oid.sha);
|
expect(commit.oid, oid);
|
||||||
expect(commit.message, message);
|
expect(commit.message, message);
|
||||||
expect(commit.messageEncoding, 'utf-8');
|
expect(commit.messageEncoding, 'utf-8');
|
||||||
expect(commit.author, author);
|
expect(commit.author, author);
|
||||||
expect(commit.committer, commiter);
|
expect(commit.committer, commiter);
|
||||||
expect(commit.time, 124);
|
expect(commit.time, 124);
|
||||||
expect(commit.tree.id, tree.id);
|
expect(commit.tree.oid, tree.oid);
|
||||||
expect(commit.parents.length, 0);
|
expect(commit.parents.length, 0);
|
||||||
|
|
||||||
commit.free();
|
commit.free();
|
||||||
|
@ -132,16 +132,16 @@ void main() {
|
||||||
|
|
||||||
final commit = repo.lookupCommit(oid);
|
final commit = repo.lookupCommit(oid);
|
||||||
|
|
||||||
expect(commit.id.sha, oid.sha);
|
expect(commit.oid, oid);
|
||||||
expect(commit.message, message);
|
expect(commit.message, message);
|
||||||
expect(commit.messageEncoding, 'utf-8');
|
expect(commit.messageEncoding, 'utf-8');
|
||||||
expect(commit.author, author);
|
expect(commit.author, author);
|
||||||
expect(commit.committer, commiter);
|
expect(commit.committer, commiter);
|
||||||
expect(commit.time, 124);
|
expect(commit.time, 124);
|
||||||
expect(commit.tree.id, tree.id);
|
expect(commit.tree.oid, tree.oid);
|
||||||
expect(commit.parents.length, 2);
|
expect(commit.parents.length, 2);
|
||||||
expect(commit.parents[0], mergeCommit);
|
expect(commit.parents[0], mergeCommit);
|
||||||
expect(commit.parents[1], parent2.id);
|
expect(commit.parents[1], parent2.oid);
|
||||||
|
|
||||||
parent1.free();
|
parent1.free();
|
||||||
parent2.free();
|
parent2.free();
|
||||||
|
|
|
@ -218,7 +218,7 @@ index e69de29..c217c63 100644
|
||||||
final file = File('${tmpDir.path}/subdir/modified_file');
|
final file = File('${tmpDir.path}/subdir/modified_file');
|
||||||
|
|
||||||
repo.reset(
|
repo.reset(
|
||||||
target: 'a763aa560953e7cfb87ccbc2f536d665aa4dff22',
|
oid: repo['a763aa560953e7cfb87ccbc2f536d665aa4dff22'],
|
||||||
resetType: GitReset.hard,
|
resetType: GitReset.hard,
|
||||||
);
|
);
|
||||||
expect(file.readAsStringSync(), '');
|
expect(file.readAsStringSync(), '');
|
||||||
|
@ -280,11 +280,11 @@ index e69de29..c217c63 100644
|
||||||
|
|
||||||
expect(diff.deltas[0].oldFile.path, indexToWorkdir[0]);
|
expect(diff.deltas[0].oldFile.path, indexToWorkdir[0]);
|
||||||
expect(
|
expect(
|
||||||
diff.deltas[0].oldFile.id.sha,
|
diff.deltas[0].oldFile.oid.sha,
|
||||||
'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391',
|
'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391',
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
diff.deltas[0].newFile.id.sha,
|
diff.deltas[0].newFile.oid.sha,
|
||||||
'0000000000000000000000000000000000000000',
|
'0000000000000000000000000000000000000000',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -54,15 +54,15 @@ void main() {
|
||||||
final entry = index['file'];
|
final entry = index['file'];
|
||||||
final otherEntry = index['feature_file'];
|
final otherEntry = index['feature_file'];
|
||||||
|
|
||||||
expect(entry.id == otherEntry.id, false);
|
expect(entry.oid == otherEntry.oid, false);
|
||||||
expect(entry.mode, isNot(GitFilemode.blobExecutable));
|
expect(entry.mode, isNot(GitFilemode.blobExecutable));
|
||||||
|
|
||||||
entry.path = 'some.txt';
|
entry.path = 'some.txt';
|
||||||
entry.id = otherEntry.id;
|
entry.oid = otherEntry.oid;
|
||||||
entry.mode = GitFilemode.blobExecutable;
|
entry.mode = GitFilemode.blobExecutable;
|
||||||
|
|
||||||
expect(entry.path, 'some.txt');
|
expect(entry.path, 'some.txt');
|
||||||
expect(entry.id == otherEntry.id, true);
|
expect(entry.oid == otherEntry.oid, true);
|
||||||
expect(entry.mode, GitFilemode.blobExecutable);
|
expect(entry.mode, GitFilemode.blobExecutable);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ void main() {
|
||||||
repo['c68ff54aabf660fcdd9a2838d401583fe31249e3'],
|
repo['c68ff54aabf660fcdd9a2838d401583fe31249e3'],
|
||||||
);
|
);
|
||||||
|
|
||||||
final result = repo.mergeAnalysis(theirHead: commit.id);
|
final result = repo.mergeAnalysis(theirHead: commit.oid);
|
||||||
expect(result, [
|
expect(result, [
|
||||||
{GitMergeAnalysis.upToDate},
|
{GitMergeAnalysis.upToDate},
|
||||||
GitMergePreference.none,
|
GitMergePreference.none,
|
||||||
|
@ -42,7 +42,7 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
final result = repo.mergeAnalysis(
|
final result = repo.mergeAnalysis(
|
||||||
theirHead: commit.id,
|
theirHead: commit.oid,
|
||||||
ourRef: 'refs/tags/v0.1',
|
ourRef: 'refs/tags/v0.1',
|
||||||
);
|
);
|
||||||
expect(result[0], {GitMergeAnalysis.upToDate});
|
expect(result[0], {GitMergeAnalysis.upToDate});
|
||||||
|
@ -64,7 +64,7 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
final result = repo.mergeAnalysis(
|
final result = repo.mergeAnalysis(
|
||||||
theirHead: theirHead.id,
|
theirHead: theirHead.oid,
|
||||||
ourRef: 'refs/heads/${ffBranch.name}',
|
ourRef: 'refs/heads/${ffBranch.name}',
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
|
@ -83,7 +83,7 @@ void main() {
|
||||||
repo['5aecfa0fb97eadaac050ccb99f03c3fb65460ad4'],
|
repo['5aecfa0fb97eadaac050ccb99f03c3fb65460ad4'],
|
||||||
);
|
);
|
||||||
|
|
||||||
final result = repo.mergeAnalysis(theirHead: commit.id);
|
final result = repo.mergeAnalysis(theirHead: commit.oid);
|
||||||
expect(result[0], {GitMergeAnalysis.normal});
|
expect(result[0], {GitMergeAnalysis.normal});
|
||||||
expect(repo.status, isEmpty);
|
expect(repo.status, isEmpty);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ conflict branch edit
|
||||||
expect(mergeIndex.conflicts, isEmpty);
|
expect(mergeIndex.conflicts, isEmpty);
|
||||||
final mergeCommitsTree = mergeIndex.writeTree(repo);
|
final mergeCommitsTree = mergeIndex.writeTree(repo);
|
||||||
|
|
||||||
repo.merge(theirCommit.id);
|
repo.merge(theirCommit.oid);
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
expect(index.conflicts, isEmpty);
|
expect(index.conflicts, isEmpty);
|
||||||
final mergeTree = index.writeTree();
|
final mergeTree = index.writeTree();
|
||||||
|
@ -263,7 +263,7 @@ conflict branch edit
|
||||||
repo['14905459d775f3f56a39ebc2ff081163f7da3529'],
|
repo['14905459d775f3f56a39ebc2ff081163f7da3529'],
|
||||||
);
|
);
|
||||||
final baseCommit = repo.lookupCommit(
|
final baseCommit = repo.lookupCommit(
|
||||||
repo.mergeBase(a: ourCommit.id.sha, b: theirCommit.id.sha),
|
repo.mergeBase(a: ourCommit.oid, b: theirCommit.oid),
|
||||||
);
|
);
|
||||||
final theirTree = theirCommit.tree;
|
final theirTree = theirCommit.tree;
|
||||||
final ourTree = ourCommit.tree;
|
final ourTree = ourCommit.tree;
|
||||||
|
@ -277,8 +277,8 @@ conflict branch edit
|
||||||
expect(mergeIndex.conflicts, isEmpty);
|
expect(mergeIndex.conflicts, isEmpty);
|
||||||
final mergeTreesTree = mergeIndex.writeTree(repo);
|
final mergeTreesTree = mergeIndex.writeTree(repo);
|
||||||
|
|
||||||
repo.setHead('14905459d775f3f56a39ebc2ff081163f7da3529');
|
repo.setHead(ourCommit.oid);
|
||||||
repo.merge(theirCommit.id);
|
repo.merge(theirCommit.oid);
|
||||||
final index = repo.index;
|
final index = repo.index;
|
||||||
expect(index.conflicts, isEmpty);
|
expect(index.conflicts, isEmpty);
|
||||||
final mergeTree = index.writeTree();
|
final mergeTree = index.writeTree();
|
||||||
|
@ -303,7 +303,7 @@ conflict branch edit
|
||||||
repo['14905459d775f3f56a39ebc2ff081163f7da3529'],
|
repo['14905459d775f3f56a39ebc2ff081163f7da3529'],
|
||||||
);
|
);
|
||||||
final baseCommit = repo.lookupCommit(
|
final baseCommit = repo.lookupCommit(
|
||||||
repo.mergeBase(a: ourCommit.id.sha, b: theirCommit.id.sha),
|
repo.mergeBase(a: ourCommit.oid, b: theirCommit.oid),
|
||||||
);
|
);
|
||||||
final theirTree = theirCommit.tree;
|
final theirTree = theirCommit.tree;
|
||||||
final ourTree = ourCommit.tree;
|
final ourTree = ourCommit.tree;
|
||||||
|
|
|
@ -8,14 +8,14 @@ void main() {
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
const notesExpected = [
|
const notesExpected = [
|
||||||
{
|
{
|
||||||
'id': 'd854ba919e1bb303f4d6bb4ca9a15c5cab2a2a50',
|
'oid': 'd854ba919e1bb303f4d6bb4ca9a15c5cab2a2a50',
|
||||||
'message': 'Another note\n',
|
'message': 'Another note\n',
|
||||||
'annotatedId': '78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8',
|
'annotatedOid': '78b8bf123e3952c970ae5c1ce0a3ea1d1336f6e8',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 'd2ffe6b06b11dd90c2ee3f15d2c6b62f018554ed',
|
'oid': 'd2ffe6b06b11dd90c2ee3f15d2c6b62f018554ed',
|
||||||
'message': 'Note for HEAD\n',
|
'message': 'Note for HEAD\n',
|
||||||
'annotatedId': '821ed6e80627b8769d170a293862f9fc60825226',
|
'annotatedOid': '821ed6e80627b8769d170a293862f9fc60825226',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -36,20 +36,20 @@ void main() {
|
||||||
expect(notes.length, 2);
|
expect(notes.length, 2);
|
||||||
|
|
||||||
for (var i = 0; i < notes.length; i++) {
|
for (var i = 0; i < notes.length; i++) {
|
||||||
expect(notes[i].id.sha, notesExpected[i]['id']);
|
expect(notes[i].oid.sha, notesExpected[i]['oid']);
|
||||||
expect(notes[i].message, notesExpected[i]['message']);
|
expect(notes[i].message, notesExpected[i]['message']);
|
||||||
expect(notes[i].annotatedId.sha, notesExpected[i]['annotatedId']);
|
expect(notes[i].annotatedOid.sha, notesExpected[i]['annotatedOid']);
|
||||||
notes[i].free();
|
notes[i].free();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('successfully lookups note', () {
|
test('successfully lookups note', () {
|
||||||
final head = repo.head;
|
final head = repo.head;
|
||||||
final note = repo.lookupNote(annotatedId: head.target);
|
final note = repo.lookupNote(annotatedOid: head.target);
|
||||||
|
|
||||||
expect(note.id.sha, notesExpected[1]['id']);
|
expect(note.oid.sha, notesExpected[1]['oid']);
|
||||||
expect(note.message, notesExpected[1]['message']);
|
expect(note.message, notesExpected[1]['message']);
|
||||||
expect(note.annotatedId.sha, notesExpected[1]['annotatedId']);
|
expect(note.annotatedOid.sha, notesExpected[1]['annotatedOid']);
|
||||||
|
|
||||||
note.free();
|
note.free();
|
||||||
head.free();
|
head.free();
|
||||||
|
@ -61,7 +61,7 @@ void main() {
|
||||||
final noteOid = repo.createNote(
|
final noteOid = repo.createNote(
|
||||||
author: signature,
|
author: signature,
|
||||||
committer: signature,
|
committer: signature,
|
||||||
annotatedId: head.target,
|
annotatedOid: head.target,
|
||||||
note: 'New note for HEAD',
|
note: 'New note for HEAD',
|
||||||
force: true,
|
force: true,
|
||||||
);
|
);
|
||||||
|
@ -80,13 +80,13 @@ void main() {
|
||||||
final head = repo.head;
|
final head = repo.head;
|
||||||
|
|
||||||
repo.deleteNote(
|
repo.deleteNote(
|
||||||
annotatedId: repo.head.target,
|
annotatedOid: repo.head.target,
|
||||||
author: signature,
|
author: signature,
|
||||||
committer: signature,
|
committer: signature,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
() => repo.lookupNote(annotatedId: head.target),
|
() => repo.lookupNote(annotatedOid: head.target),
|
||||||
throwsA(isA<LibGit2Error>()),
|
throwsA(isA<LibGit2Error>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ void main() {
|
||||||
final odb = repo.odb;
|
final odb = repo.odb;
|
||||||
final object = odb.read(oid);
|
final object = odb.read(oid);
|
||||||
|
|
||||||
expect(object.id, oid);
|
expect(object.oid, oid);
|
||||||
expect(object.type, GitObject.blob);
|
expect(object.type, GitObject.blob);
|
||||||
expect(object.data, blobContent);
|
expect(object.data, blobContent);
|
||||||
expect(object.size, 13);
|
expect(object.size, 13);
|
||||||
|
|
|
@ -89,8 +89,8 @@ void main() {
|
||||||
final branches = repo.branches;
|
final branches = repo.branches;
|
||||||
for (final branch in branches) {
|
for (final branch in branches) {
|
||||||
final ref = repo.lookupReference('refs/heads/${branch.name}');
|
final ref = repo.lookupReference('refs/heads/${branch.name}');
|
||||||
for (final commit in repo.log(sha: ref.target.sha)) {
|
for (final commit in repo.log(oid: ref.target)) {
|
||||||
packBuilder.addRecursively(commit.id);
|
packBuilder.addRecursively(commit.oid);
|
||||||
commit.free();
|
commit.free();
|
||||||
}
|
}
|
||||||
ref.free();
|
ref.free();
|
||||||
|
|
|
@ -43,7 +43,7 @@ void main() {
|
||||||
for (var i = 0; i < operationsCount; i++) {
|
for (var i = 0; i < operationsCount; i++) {
|
||||||
final operation = rebase.next();
|
final operation = rebase.next();
|
||||||
expect(operation.type, GitRebaseOperation.pick);
|
expect(operation.type, GitRebaseOperation.pick);
|
||||||
expect(operation.id.sha, shas[i]);
|
expect(operation.oid.sha, shas[i]);
|
||||||
expect(operation.exec, '');
|
expect(operation.exec, '');
|
||||||
|
|
||||||
rebase.commit(committer: signature);
|
rebase.commit(committer: signature);
|
||||||
|
@ -74,7 +74,7 @@ void main() {
|
||||||
repo: repo,
|
repo: repo,
|
||||||
branch: master.target,
|
branch: master.target,
|
||||||
onto: feature.target,
|
onto: feature.target,
|
||||||
upstream: startCommit.id,
|
upstream: startCommit.oid,
|
||||||
);
|
);
|
||||||
|
|
||||||
final operationsCount = rebase.operationsCount;
|
final operationsCount = rebase.operationsCount;
|
||||||
|
|
|
@ -343,23 +343,16 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
group('set target', () {
|
group('set target', () {
|
||||||
test('successfully sets with SHA hex', () {
|
test('successfully sets direct reference with provided Oid target', () {
|
||||||
final ref = repo.lookupReference('refs/heads/master');
|
final ref = repo.lookupReference('refs/heads/master');
|
||||||
ref.setTarget(target: newCommit);
|
ref.setTarget(target: repo[newCommit]);
|
||||||
expect(ref.target.sha, newCommit);
|
expect(ref.target.sha, newCommit);
|
||||||
|
|
||||||
ref.free();
|
ref.free();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('successfully sets target with short SHA hex', () {
|
test('successfully sets symbolic target with provided reference name',
|
||||||
final ref = repo.lookupReference('refs/heads/master');
|
() {
|
||||||
ref.setTarget(target: newCommit.substring(0, 5));
|
|
||||||
expect(ref.target.sha, newCommit);
|
|
||||||
|
|
||||||
ref.free();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('successfully sets symbolic target', () {
|
|
||||||
final ref = repo.lookupReference('HEAD');
|
final ref = repo.lookupReference('HEAD');
|
||||||
expect(ref.target.sha, lastCommit);
|
expect(ref.target.sha, lastCommit);
|
||||||
|
|
||||||
|
@ -474,7 +467,7 @@ void main() {
|
||||||
final commit = repo.lookupCommit(ref.target);
|
final commit = repo.lookupCommit(ref.target);
|
||||||
final peeled = ref.peel() as Commit;
|
final peeled = ref.peel() as Commit;
|
||||||
|
|
||||||
expect(peeled.id, commit.id);
|
expect(peeled.oid, commit.oid);
|
||||||
|
|
||||||
peeled.free();
|
peeled.free();
|
||||||
commit.free();
|
commit.free();
|
||||||
|
@ -488,8 +481,8 @@ void main() {
|
||||||
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;
|
||||||
|
|
||||||
expect(peeledCommit.id, commit.id);
|
expect(peeledCommit.oid, commit.oid);
|
||||||
expect(peeledTree.id, tree.id);
|
expect(peeledTree.oid, tree.oid);
|
||||||
|
|
||||||
peeledCommit.free();
|
peeledCommit.free();
|
||||||
commit.free();
|
commit.free();
|
||||||
|
|
|
@ -356,7 +356,7 @@ Total 69 (delta 0), reused 1 (delta 0), pack-reused 68
|
||||||
|
|
||||||
remote.push(refspecs: ['refs/heads/master'], callbacks: callbacks);
|
remote.push(refspecs: ['refs/heads/master'], callbacks: callbacks);
|
||||||
expect(
|
expect(
|
||||||
originRepo.lookupCommit(originRepo.head.target).id.sha,
|
originRepo.lookupCommit(originRepo.head.target).oid.sha,
|
||||||
'821ed6e80627b8769d170a293862f9fc60825226',
|
'821ed6e80627b8769d170a293862f9fc60825226',
|
||||||
);
|
);
|
||||||
expect(updateRefOutput, {'refs/heads/master': ''});
|
expect(updateRefOutput, {'refs/heads/master': ''});
|
||||||
|
|
|
@ -39,10 +39,10 @@ void main() {
|
||||||
'6cbc22e509d72758ab4c8d9f287ea846b90c448b',
|
'6cbc22e509d72758ab4c8d9f287ea846b90c448b',
|
||||||
'f17d0d48eae3aa08cecf29128a35e310c97b3521',
|
'f17d0d48eae3aa08cecf29128a35e310c97b3521',
|
||||||
];
|
];
|
||||||
final commits = repo.log(sha: lastCommit);
|
final commits = repo.log(oid: repo[lastCommit]);
|
||||||
|
|
||||||
for (var i = 0; i < commits.length; i++) {
|
for (var i = 0; i < commits.length; i++) {
|
||||||
expect(commits[i].id.sha, log[i]);
|
expect(commits[i].oid.sha, log[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final c in commits) {
|
for (final c in commits) {
|
||||||
|
@ -100,14 +100,7 @@ void main() {
|
||||||
|
|
||||||
test('successfully sets head when target is sha hex', () {
|
test('successfully sets head when target is sha hex', () {
|
||||||
expect(repo.head.target.sha, lastCommit);
|
expect(repo.head.target.sha, lastCommit);
|
||||||
repo.setHead(featureCommit);
|
repo.setHead(repo[featureCommit]);
|
||||||
expect(repo.head.target.sha, featureCommit);
|
|
||||||
expect(repo.isHeadDetached, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('successfully sets head when target is short sha hex', () {
|
|
||||||
expect(repo.head.target.sha, lastCommit);
|
|
||||||
repo.setHead(featureCommit.substring(0, 5));
|
|
||||||
expect(repo.head.target.sha, featureCommit);
|
expect(repo.head.target.sha, featureCommit);
|
||||||
expect(repo.isHeadDetached, true);
|
expect(repo.isHeadDetached, true);
|
||||||
});
|
});
|
||||||
|
@ -176,11 +169,11 @@ void main() {
|
||||||
final tagger = newTag.tagger;
|
final tagger = newTag.tagger;
|
||||||
final newTagTarget = newTag.target as Commit;
|
final newTagTarget = newTag.target as Commit;
|
||||||
|
|
||||||
expect(newTag.id.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42');
|
expect(newTag.oid.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42');
|
||||||
expect(newTag.name, tagName);
|
expect(newTag.name, tagName);
|
||||||
expect(newTag.message, message);
|
expect(newTag.message, message);
|
||||||
expect(tagger, signature);
|
expect(tagger, signature);
|
||||||
expect(newTagTarget.id, target);
|
expect(newTagTarget.oid, target);
|
||||||
|
|
||||||
newTag.free();
|
newTag.free();
|
||||||
newTagTarget.free();
|
newTagTarget.free();
|
||||||
|
@ -255,26 +248,15 @@ void main() {
|
||||||
final commit2 = repo.lookupCommit(repo['78b8bf12']);
|
final commit2 = repo.lookupCommit(repo['78b8bf12']);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
repo.descendantOf(
|
repo.descendantOf(commit: commit1.oid, ancestor: commit2.oid),
|
||||||
commitSHA: commit1.id.sha,
|
|
||||||
ancestorSHA: commit2.id.sha,
|
|
||||||
),
|
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
repo.descendantOf(
|
repo.descendantOf(commit: commit1.oid, ancestor: commit1.oid),
|
||||||
commitSHA: commit1.id.sha,
|
|
||||||
ancestorSHA: commit1.id.sha,
|
|
||||||
),
|
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
repo.descendantOf(
|
repo.descendantOf(commit: commit2.oid, ancestor: commit1.oid),
|
||||||
commitSHA: commit2.id.sha,
|
|
||||||
ancestorSHA: commit1.id.sha,
|
|
||||||
),
|
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -287,15 +269,15 @@ void main() {
|
||||||
final commit2 = repo.lookupCommit(repo['c68ff54a']);
|
final commit2 = repo.lookupCommit(repo['c68ff54a']);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
repo.aheadBehind(localSHA: commit1.id.sha, upstreamSHA: commit2.id.sha),
|
repo.aheadBehind(local: commit1.oid, upstream: commit2.oid),
|
||||||
[4, 0],
|
[4, 0],
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
repo.aheadBehind(localSHA: commit2.id.sha, upstreamSHA: commit1.id.sha),
|
repo.aheadBehind(local: commit2.oid, upstream: commit1.oid),
|
||||||
[0, 4],
|
[0, 4],
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
repo.aheadBehind(localSHA: commit1.id.sha, upstreamSHA: commit1.id.sha),
|
repo.aheadBehind(local: commit1.oid, upstream: commit1.oid),
|
||||||
[0, 0],
|
[0, 0],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ void main() {
|
||||||
var contents = file.readAsStringSync();
|
var contents = file.readAsStringSync();
|
||||||
expect(contents, 'Feature edit\n');
|
expect(contents, 'Feature edit\n');
|
||||||
|
|
||||||
repo.reset(target: sha, resetType: GitReset.hard);
|
repo.reset(oid: repo[sha], resetType: GitReset.hard);
|
||||||
contents = file.readAsStringSync();
|
contents = file.readAsStringSync();
|
||||||
expect(contents, isEmpty);
|
expect(contents, isEmpty);
|
||||||
});
|
});
|
||||||
|
@ -34,7 +34,7 @@ void main() {
|
||||||
var contents = file.readAsStringSync();
|
var contents = file.readAsStringSync();
|
||||||
expect(contents, 'Feature edit\n');
|
expect(contents, 'Feature edit\n');
|
||||||
|
|
||||||
repo.reset(target: sha, resetType: GitReset.soft);
|
repo.reset(oid: repo[sha], resetType: GitReset.soft);
|
||||||
contents = file.readAsStringSync();
|
contents = file.readAsStringSync();
|
||||||
expect(contents, 'Feature edit\n');
|
expect(contents, 'Feature edit\n');
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ void main() {
|
||||||
var contents = file.readAsStringSync();
|
var contents = file.readAsStringSync();
|
||||||
expect(contents, 'Feature edit\n');
|
expect(contents, 'Feature edit\n');
|
||||||
|
|
||||||
repo.reset(target: sha, resetType: GitReset.mixed);
|
repo.reset(oid: repo[sha], resetType: GitReset.mixed);
|
||||||
contents = file.readAsStringSync();
|
contents = file.readAsStringSync();
|
||||||
expect(contents, 'Feature edit\n');
|
expect(contents, 'Feature edit\n');
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,13 @@ void main() {
|
||||||
group('revParse', () {
|
group('revParse', () {
|
||||||
test('.single() returns commit with different spec strings', () {
|
test('.single() returns commit with different spec strings', () {
|
||||||
final headCommit = repo.revParseSingle('HEAD');
|
final headCommit = repo.revParseSingle('HEAD');
|
||||||
expect(headCommit.id.sha, headSHA);
|
expect(headCommit.oid.sha, headSHA);
|
||||||
|
|
||||||
final parentCommit = repo.revParseSingle('HEAD^');
|
final parentCommit = repo.revParseSingle('HEAD^');
|
||||||
expect(parentCommit.id.sha, parentSHA);
|
expect(parentCommit.oid.sha, parentSHA);
|
||||||
|
|
||||||
final initCommit = repo.revParseSingle('@{-1}');
|
final initCommit = repo.revParseSingle('@{-1}');
|
||||||
expect(initCommit.id.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
expect(initCommit.oid.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
||||||
|
|
||||||
headCommit.free();
|
headCommit.free();
|
||||||
parentCommit.free();
|
parentCommit.free();
|
||||||
|
@ -39,7 +39,7 @@ void main() {
|
||||||
final masterRef = repo.lookupReference('refs/heads/master');
|
final masterRef = repo.lookupReference('refs/heads/master');
|
||||||
var headParse = repo.revParseExt('master');
|
var headParse = repo.revParseExt('master');
|
||||||
|
|
||||||
expect(headParse.object.id.sha, headSHA);
|
expect(headParse.object.oid.sha, headSHA);
|
||||||
expect(headParse.reference, masterRef);
|
expect(headParse.reference, masterRef);
|
||||||
|
|
||||||
masterRef.free();
|
masterRef.free();
|
||||||
|
@ -50,7 +50,9 @@ void main() {
|
||||||
headParse = repo.revParseExt('feature');
|
headParse = repo.revParseExt('feature');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
headParse.object.id.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
headParse.object.oid.sha,
|
||||||
|
'5aecfa0fb97eadaac050ccb99f03c3fb65460ad4',
|
||||||
|
);
|
||||||
expect(headParse.reference, featureRef);
|
expect(headParse.reference, featureRef);
|
||||||
|
|
||||||
featureRef.free();
|
featureRef.free();
|
||||||
|
@ -61,7 +63,7 @@ void main() {
|
||||||
test('.ext() returns only commit when no intermidiate reference found', () {
|
test('.ext() returns only commit when no intermidiate reference found', () {
|
||||||
final headParse = repo.revParseExt('HEAD^');
|
final headParse = repo.revParseExt('HEAD^');
|
||||||
|
|
||||||
expect(headParse.object.id.sha, parentSHA);
|
expect(headParse.object.oid.sha, parentSHA);
|
||||||
expect(headParse.reference, isNull);
|
expect(headParse.reference, isNull);
|
||||||
|
|
||||||
headParse.object.free();
|
headParse.object.free();
|
||||||
|
@ -72,7 +74,7 @@ void main() {
|
||||||
() {
|
() {
|
||||||
var revspec = repo.revParse('master');
|
var revspec = repo.revParse('master');
|
||||||
|
|
||||||
expect(revspec.from.id.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});
|
||||||
|
|
||||||
|
@ -80,8 +82,8 @@ void main() {
|
||||||
|
|
||||||
revspec = repo.revParse('HEAD^1..5aecfa');
|
revspec = repo.revParse('HEAD^1..5aecfa');
|
||||||
|
|
||||||
expect(revspec.from.id.sha, parentSHA);
|
expect(revspec.from.oid.sha, parentSHA);
|
||||||
expect(revspec.to?.id.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
expect(revspec.to?.oid.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
||||||
expect(revspec.flags, {GitRevSpec.range});
|
expect(revspec.flags, {GitRevSpec.range});
|
||||||
|
|
||||||
revspec.from.free();
|
revspec.from.free();
|
||||||
|
@ -89,11 +91,11 @@ void main() {
|
||||||
|
|
||||||
revspec = repo.revParse('HEAD...feature');
|
revspec = repo.revParse('HEAD...feature');
|
||||||
|
|
||||||
expect(revspec.from.id.sha, headSHA);
|
expect(revspec.from.oid.sha, headSHA);
|
||||||
expect(revspec.to?.id.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
expect(revspec.to?.oid.sha, '5aecfa0fb97eadaac050ccb99f03c3fb65460ad4');
|
||||||
expect(revspec.flags, {GitRevSpec.range, GitRevSpec.mergeBase});
|
expect(revspec.flags, {GitRevSpec.range, GitRevSpec.mergeBase});
|
||||||
expect(
|
expect(
|
||||||
repo.mergeBase(a: revspec.from.id.sha, b: revspec.to!.id.sha),
|
repo.mergeBase(a: revspec.from.oid, b: revspec.to!.oid),
|
||||||
isA<Oid>(),
|
isA<Oid>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ void main() {
|
||||||
final commits = walker.walk();
|
final commits = walker.walk();
|
||||||
|
|
||||||
for (var i = 0; i < commits.length; i++) {
|
for (var i = 0; i < commits.length; i++) {
|
||||||
expect(commits[i].id.sha, log[i]);
|
expect(commits[i].oid.sha, log[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final c in commits) {
|
for (final c in commits) {
|
||||||
|
@ -51,7 +51,7 @@ void main() {
|
||||||
final commits = walker.walk();
|
final commits = walker.walk();
|
||||||
|
|
||||||
for (var i = 0; i < commits.length; i++) {
|
for (var i = 0; i < commits.length; i++) {
|
||||||
expect(commits[i].id.sha, log.reversed.toList()[i]);
|
expect(commits[i].oid.sha, log.reversed.toList()[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final c in commits) {
|
for (final c in commits) {
|
||||||
|
@ -68,13 +68,13 @@ void main() {
|
||||||
final timeSortedCommits = walker.walk();
|
final timeSortedCommits = walker.walk();
|
||||||
|
|
||||||
for (var i = 0; i < timeSortedCommits.length; i++) {
|
for (var i = 0; i < timeSortedCommits.length; i++) {
|
||||||
expect(timeSortedCommits[i].id.sha, log[i]);
|
expect(timeSortedCommits[i].oid.sha, log[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
walker.sorting({GitSort.time, GitSort.reverse});
|
walker.sorting({GitSort.time, GitSort.reverse});
|
||||||
final reverseSortedCommits = walker.walk();
|
final reverseSortedCommits = walker.walk();
|
||||||
for (var i = 0; i < reverseSortedCommits.length; i++) {
|
for (var i = 0; i < reverseSortedCommits.length; i++) {
|
||||||
expect(reverseSortedCommits[i].id.sha, log.reversed.toList()[i]);
|
expect(reverseSortedCommits[i].oid.sha, log.reversed.toList()[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final c in timeSortedCommits) {
|
for (final c in timeSortedCommits) {
|
||||||
|
|
|
@ -33,9 +33,9 @@ void main() {
|
||||||
expect(submodule.path, testSubmodule);
|
expect(submodule.path, testSubmodule);
|
||||||
expect(submodule.url, submoduleUrl);
|
expect(submodule.url, submoduleUrl);
|
||||||
expect(submodule.branch, '');
|
expect(submodule.branch, '');
|
||||||
expect(submodule.headId?.sha, submoduleHeadSha);
|
expect(submodule.headOid?.sha, submoduleHeadSha);
|
||||||
expect(submodule.indexId?.sha, submoduleHeadSha);
|
expect(submodule.indexOid?.sha, submoduleHeadSha);
|
||||||
expect(submodule.workdirId?.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);
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,13 @@ void main() {
|
||||||
late Repository repo;
|
late Repository repo;
|
||||||
late Tag tag;
|
late Tag tag;
|
||||||
late Directory tmpDir;
|
late Directory tmpDir;
|
||||||
late Oid tagID;
|
late Oid tagOid;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tmpDir = setupRepo(Directory('test/assets/testrepo/'));
|
tmpDir = setupRepo(Directory('test/assets/testrepo/'));
|
||||||
repo = Repository.open(tmpDir.path);
|
repo = Repository.open(tmpDir.path);
|
||||||
tagID = repo['f0fdbf506397e9f58c59b88dfdd72778ec06cc0c'];
|
tagOid = repo['f0fdbf506397e9f58c59b88dfdd72778ec06cc0c'];
|
||||||
tag = repo.lookupTag(tagID);
|
tag = repo.lookupTag(tagOid);
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
|
@ -37,7 +37,7 @@ void main() {
|
||||||
final target = tag.target as Commit;
|
final target = tag.target as Commit;
|
||||||
final tagger = tag.tagger;
|
final tagger = tag.tagger;
|
||||||
|
|
||||||
expect(tag.id, tagID);
|
expect(tag.oid, tagOid);
|
||||||
expect(tag.name, 'v0.2');
|
expect(tag.name, 'v0.2');
|
||||||
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');
|
||||||
|
@ -69,11 +69,11 @@ void main() {
|
||||||
final tagger = newTag.tagger;
|
final tagger = newTag.tagger;
|
||||||
final newTagTarget = newTag.target as Commit;
|
final newTagTarget = newTag.target as Commit;
|
||||||
|
|
||||||
expect(newTag.id.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42');
|
expect(newTag.oid.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42');
|
||||||
expect(newTag.name, tagName);
|
expect(newTag.name, tagName);
|
||||||
expect(newTag.message, message);
|
expect(newTag.message, message);
|
||||||
expect(tagger, signature);
|
expect(tagger, signature);
|
||||||
expect(newTagTarget.id, target);
|
expect(newTagTarget.oid, target);
|
||||||
|
|
||||||
newTag.free();
|
newTag.free();
|
||||||
newTagTarget.free();
|
newTagTarget.free();
|
||||||
|
|
|
@ -30,13 +30,13 @@ void main() {
|
||||||
|
|
||||||
test('returns correct values', () {
|
test('returns correct values', () {
|
||||||
expect(tree.length, 4);
|
expect(tree.length, 4);
|
||||||
expect(tree.entries.first.id.sha, fileSHA);
|
expect(tree.entries.first.oid.sha, fileSHA);
|
||||||
expect(tree.entries[0].name, '.gitignore');
|
expect(tree.entries[0].name, '.gitignore');
|
||||||
expect(tree.entries[0].filemode, GitFilemode.blob);
|
expect(tree.entries[0].filemode, GitFilemode.blob);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns tree entry with provided index position', () {
|
test('returns tree entry with provided index position', () {
|
||||||
expect(tree[0].id.sha, fileSHA);
|
expect(tree[0].oid.sha, fileSHA);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when provided index position is outside of valid range', () {
|
test('throws when provided index position is outside of valid range', () {
|
||||||
|
@ -45,7 +45,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns tree entry with provided filename', () {
|
test('returns tree entry with provided filename', () {
|
||||||
expect(tree['.gitignore'].id.sha, fileSHA);
|
expect(tree['.gitignore'].oid.sha, fileSHA);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when nothing found for provided filename', () {
|
test('throws when nothing found for provided filename', () {
|
||||||
|
@ -54,7 +54,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.id.sha, 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391');
|
expect(entry.oid.sha, 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391');
|
||||||
entry.free();
|
entry.free();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ void main() {
|
||||||
expect(newTree.length, 1);
|
expect(newTree.length, 1);
|
||||||
expect(entry.name, 'filename');
|
expect(entry.name, 'filename');
|
||||||
expect(entry.filemode, GitFilemode.blob);
|
expect(entry.filemode, GitFilemode.blob);
|
||||||
expect(entry.id, fileOid);
|
expect(entry.oid, fileOid);
|
||||||
|
|
||||||
builder.free();
|
builder.free();
|
||||||
entry.free();
|
entry.free();
|
||||||
|
|
|
@ -33,7 +33,7 @@ void main() {
|
||||||
|
|
||||||
expect(builder, isA<TreeBuilder>());
|
expect(builder, isA<TreeBuilder>());
|
||||||
expect(builder.length, tree.length);
|
expect(builder.length, tree.length);
|
||||||
expect(oid, tree.id);
|
expect(oid, tree.oid);
|
||||||
|
|
||||||
builder.free();
|
builder.free();
|
||||||
});
|
});
|
||||||
|
@ -56,7 +56,7 @@ void main() {
|
||||||
|
|
||||||
builder.add(
|
builder.add(
|
||||||
filename: entry.name,
|
filename: entry.name,
|
||||||
oid: entry.id,
|
oid: entry.oid,
|
||||||
filemode: entry.filemode,
|
filemode: entry.filemode,
|
||||||
);
|
);
|
||||||
expect(builder[entry.name].name, entry.name);
|
expect(builder[entry.name].name, entry.name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue