mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
style: use conts for constructors
This commit is contained in:
parent
e0e16aea30
commit
7187d890d6
17 changed files with 39 additions and 69 deletions
|
@ -1,6 +1,7 @@
|
|||
import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import '../error.dart';
|
||||
import '../oid.dart';
|
||||
import '../stash.dart';
|
||||
import 'checkout.dart' as checkout_bindings;
|
||||
import 'libgit2_bindings.dart';
|
||||
|
@ -142,7 +143,7 @@ int _stashCb(
|
|||
_stashList.add(Stash(
|
||||
index: index,
|
||||
message: message.cast<Utf8>().toDartString(),
|
||||
oid: oid,
|
||||
oid: Oid(oid),
|
||||
));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import 'reference.dart';
|
|||
import 'repository.dart';
|
||||
import 'oid.dart';
|
||||
import 'git_types.dart';
|
||||
import 'util.dart';
|
||||
|
||||
class Branches {
|
||||
/// Initializes a new instance of the [Branches] class
|
||||
|
@ -81,12 +80,10 @@ class Branch {
|
|||
/// branch object in memory.
|
||||
///
|
||||
/// Should be freed with `free()` to release allocated memory.
|
||||
Branch(this._branchPointer) {
|
||||
libgit2.git_libgit2_init();
|
||||
}
|
||||
const Branch(this._branchPointer);
|
||||
|
||||
/// Pointer to memory address for allocated branch object.
|
||||
late final Pointer<git_reference> _branchPointer;
|
||||
final Pointer<git_reference> _branchPointer;
|
||||
|
||||
/// Returns the OID pointed to by a branch.
|
||||
///
|
||||
|
|
|
@ -144,11 +144,11 @@ class Config with IterableMixin<ConfigEntry> {
|
|||
|
||||
@override
|
||||
Iterator<ConfigEntry> get iterator =>
|
||||
ConfigIterator(bindings.iterator(_configPointer));
|
||||
_ConfigIterator(bindings.iterator(_configPointer));
|
||||
}
|
||||
|
||||
class ConfigEntry {
|
||||
ConfigEntry(this._configEntryPointer);
|
||||
const ConfigEntry(this._configEntryPointer);
|
||||
|
||||
/// Pointer to memory address for allocated config entry object.
|
||||
final Pointer<git_config_entry> _configEntryPointer;
|
||||
|
@ -183,8 +183,8 @@ class ConfigEntry {
|
|||
}
|
||||
}
|
||||
|
||||
class ConfigIterator implements Iterator<ConfigEntry> {
|
||||
ConfigIterator(this._iteratorPointer);
|
||||
class _ConfigIterator implements Iterator<ConfigEntry> {
|
||||
_ConfigIterator(this._iteratorPointer);
|
||||
|
||||
/// Pointer to memory address for allocated config iterator.
|
||||
final Pointer<git_config_iterator> _iteratorPointer;
|
||||
|
|
|
@ -122,7 +122,7 @@ class Diff {
|
|||
class DiffDelta {
|
||||
/// Initializes a new instance of [DiffDelta] class from provided
|
||||
/// pointer to diff delta object in memory.
|
||||
DiffDelta(this._diffDeltaPointer);
|
||||
const DiffDelta(this._diffDeltaPointer);
|
||||
|
||||
/// Pointer to memory address for allocated diff delta object.
|
||||
final Pointer<git_diff_delta> _diffDeltaPointer;
|
||||
|
@ -182,7 +182,7 @@ class DiffDelta {
|
|||
/// are tracking type changes or ignored/untracked directories).
|
||||
class DiffFile {
|
||||
/// Initializes a new instance of [DiffFile] class from provided diff file object.
|
||||
DiffFile(this._diffFile);
|
||||
const DiffFile(this._diffFile);
|
||||
|
||||
final git_diff_file _diffFile;
|
||||
|
||||
|
@ -223,7 +223,7 @@ class DiffFile {
|
|||
class DiffStats {
|
||||
/// Initializes a new instance of [DiffStats] class from provided
|
||||
/// pointer to diff stats object in memory.
|
||||
DiffStats(this._diffStatsPointer);
|
||||
const DiffStats(this._diffStatsPointer);
|
||||
|
||||
/// Pointer to memory address for allocated diff delta object.
|
||||
final Pointer<git_diff_stats> _diffStatsPointer;
|
||||
|
@ -255,7 +255,7 @@ class DiffStats {
|
|||
class DiffHunk {
|
||||
/// Initializes a new instance of [DiffHunk] class from provided
|
||||
/// pointers to patch object and diff hunk object in memory and number of lines in hunk.
|
||||
DiffHunk(
|
||||
const DiffHunk(
|
||||
this._patchPointer,
|
||||
this._diffHunkPointer,
|
||||
this.linesCount,
|
||||
|
@ -269,10 +269,10 @@ class DiffHunk {
|
|||
final Pointer<git_patch> _patchPointer;
|
||||
|
||||
/// Returns count of total lines in this hunk.
|
||||
late final int linesCount;
|
||||
final int linesCount;
|
||||
|
||||
/// Returns index of this hunk in the patch.
|
||||
late final int index;
|
||||
final int index;
|
||||
|
||||
/// Returns starting line number in 'old file'.
|
||||
int get oldStart => _diffHunkPointer.ref.old_start;
|
||||
|
@ -310,7 +310,7 @@ class DiffHunk {
|
|||
class DiffLine {
|
||||
/// Initializes a new instance of [DiffLine] class from provided
|
||||
/// pointer to diff line object in memory.
|
||||
DiffLine(this._diffLinePointer);
|
||||
const DiffLine(this._diffLinePointer);
|
||||
|
||||
/// Pointer to memory address for allocated diff line object.
|
||||
final Pointer<git_diff_line> _diffLinePointer;
|
||||
|
|
|
@ -9,18 +9,15 @@ import 'bindings/diff.dart' as diff_bindings;
|
|||
import 'oid.dart';
|
||||
import 'git_types.dart';
|
||||
import 'repository.dart';
|
||||
import 'util.dart';
|
||||
|
||||
class Index with IterableMixin<IndexEntry> {
|
||||
/// Initializes a new instance of [Index] class from provided
|
||||
/// pointer to index object in memory.
|
||||
///
|
||||
/// Should be freed with `free()` to release allocated memory.
|
||||
Index(this._indexPointer) {
|
||||
libgit2.git_libgit2_init();
|
||||
}
|
||||
const Index(this._indexPointer);
|
||||
|
||||
late final Pointer<git_index> _indexPointer;
|
||||
final Pointer<git_index> _indexPointer;
|
||||
|
||||
/// Pointer to memory address for allocated index object.
|
||||
Pointer<git_index> get pointer => _indexPointer;
|
||||
|
@ -237,10 +234,10 @@ class Index with IterableMixin<IndexEntry> {
|
|||
|
||||
class IndexEntry {
|
||||
/// Initializes a new instance of [IndexEntry] class.
|
||||
IndexEntry(this._indexEntryPointer);
|
||||
const IndexEntry(this._indexEntryPointer);
|
||||
|
||||
/// Pointer to memory address for allocated index entry object.
|
||||
late final Pointer<git_index_entry> _indexEntryPointer;
|
||||
final Pointer<git_index_entry> _indexEntryPointer;
|
||||
|
||||
/// Unique identity of the index entry.
|
||||
Oid get id => Oid.fromRaw(_indexEntryPointer.ref.id);
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
import 'dart:ffi';
|
||||
import 'bindings/libgit2_bindings.dart';
|
||||
import 'bindings/odb.dart' as bindings;
|
||||
import 'util.dart';
|
||||
|
||||
class Odb {
|
||||
/// Initializes a new instance of [Odb] class from provided
|
||||
/// pointer to Odb object in memory.
|
||||
Odb(this._odbPointer) {
|
||||
libgit2.git_libgit2_init();
|
||||
}
|
||||
const Odb(this._odbPointer);
|
||||
|
||||
late final Pointer<git_odb> _odbPointer;
|
||||
final Pointer<git_odb> _odbPointer;
|
||||
|
||||
/// Pointer to memory address for allocated oid object.
|
||||
Pointer<git_odb> get pointer => _odbPointer;
|
||||
|
|
|
@ -7,9 +7,7 @@ import 'util.dart';
|
|||
class Oid {
|
||||
/// Initializes a new instance of [Oid] class from provided
|
||||
/// pointer to Oid object in memory.
|
||||
Oid(this._oidPointer) {
|
||||
libgit2.git_libgit2_init();
|
||||
}
|
||||
Oid(this._oidPointer);
|
||||
|
||||
/// Initializes a new instance of [Oid] class by determining if an object can be found
|
||||
/// in the ODB of [repository] with provided hexadecimal [sha] string that is 40 characters
|
||||
|
@ -34,7 +32,6 @@ class Oid {
|
|||
|
||||
/// Initializes a new instance of [Oid] class from provided raw git_oid.
|
||||
Oid.fromRaw(git_oid raw) {
|
||||
libgit2.git_libgit2_init();
|
||||
_oidPointer = bindings.fromRaw(raw.id);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,16 +5,13 @@ import 'bindings/patch.dart' as bindings;
|
|||
import 'blob.dart';
|
||||
import 'diff.dart';
|
||||
import 'git_types.dart';
|
||||
import 'util.dart';
|
||||
|
||||
class Patch {
|
||||
/// Initializes a new instance of [Patch] class from provided
|
||||
/// pointer to patch object in memory and pointers to old and new blobs/buffers.
|
||||
///
|
||||
/// Should be freed with `free()` to release allocated memory.
|
||||
Patch(this._patchPointer, this._aPointer, this._bPointer) {
|
||||
libgit2.git_libgit2_init();
|
||||
}
|
||||
Patch(this._patchPointer, this._aPointer, this._bPointer);
|
||||
|
||||
/// Directly generates a patch from the difference between two blobs, buffers or
|
||||
/// blob and a buffer.
|
||||
|
|
|
@ -4,15 +4,12 @@ import 'bindings/libgit2_bindings.dart';
|
|||
import 'bindings/reflog.dart' as bindings;
|
||||
import 'reference.dart';
|
||||
import 'signature.dart';
|
||||
import 'util.dart';
|
||||
|
||||
class RefLog with IterableMixin<RefLogEntry> {
|
||||
/// Initializes a new instance of [RefLog] class from provided [Reference].
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
RefLog(Reference ref) {
|
||||
libgit2.git_libgit2_init();
|
||||
|
||||
final repo = ref.owner;
|
||||
final name = ref.name;
|
||||
_reflogPointer = bindings.read(repo.pointer, name);
|
||||
|
@ -38,10 +35,10 @@ class RefLog with IterableMixin<RefLogEntry> {
|
|||
|
||||
class RefLogEntry {
|
||||
/// Initializes a new instance of [RefLogEntry] class.
|
||||
RefLogEntry(this._entryPointer);
|
||||
const RefLogEntry(this._entryPointer);
|
||||
|
||||
/// Pointer to memory address for allocated reflog entry object.
|
||||
late final Pointer<git_reflog_entry> _entryPointer;
|
||||
final Pointer<git_reflog_entry> _entryPointer;
|
||||
|
||||
/// Returns the log message.
|
||||
String get message => bindings.entryMessage(_entryPointer);
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'git_types.dart';
|
|||
class Refspec {
|
||||
/// Initializes a new instance of the [Refspec] class
|
||||
/// from provided pointer to refspec object in memory.
|
||||
Refspec(this._refspecPointer);
|
||||
const Refspec(this._refspecPointer);
|
||||
|
||||
/// Pointer to memory address for allocated refspec object.
|
||||
final Pointer<git_refspec> _refspecPointer;
|
||||
|
|
|
@ -117,10 +117,10 @@ class Remotes {
|
|||
class Remote {
|
||||
/// Initializes a new instance of [Remote] class from provided pointer
|
||||
/// to remote object in memory.
|
||||
Remote(this._remotePointer);
|
||||
const Remote(this._remotePointer);
|
||||
|
||||
/// Pointer to memory address for allocated remote object.
|
||||
late final Pointer<git_remote> _remotePointer;
|
||||
final Pointer<git_remote> _remotePointer;
|
||||
|
||||
/// Returns the remote's name.
|
||||
String get name => bindings.name(_remotePointer);
|
||||
|
@ -198,7 +198,7 @@ class Remote {
|
|||
class TransferProgress {
|
||||
/// Initializes a new instance of [TransferProgress] class from provided pointer
|
||||
/// to transfer progress object in memory.
|
||||
TransferProgress(this._transferProgressPointer);
|
||||
const TransferProgress(this._transferProgressPointer);
|
||||
|
||||
/// Pointer to memory address for allocated transfer progress object.
|
||||
final Pointer<git_indexer_progress> _transferProgressPointer;
|
||||
|
|
|
@ -60,10 +60,10 @@ class RevParse {
|
|||
class RevSpec {
|
||||
/// Initializes a new instance of [RevSpec] class from provided
|
||||
/// pointer to revspec object in memory.
|
||||
RevSpec(this._revSpecPointer);
|
||||
const RevSpec(this._revSpecPointer);
|
||||
|
||||
/// Pointer to memory address for allocated revspec object.
|
||||
late final Pointer<git_revspec> _revSpecPointer;
|
||||
final Pointer<git_revspec> _revSpecPointer;
|
||||
|
||||
/// The left element of the revspec; must be freed by the user.
|
||||
Commit get from => Commit(_revSpecPointer.ref.from.cast());
|
||||
|
|
|
@ -10,9 +10,7 @@ class Signature {
|
|||
/// signature object in memory.
|
||||
///
|
||||
/// Should be freed with `free()` to release allocated memory.
|
||||
Signature(this._signaturePointer) {
|
||||
libgit2.git_libgit2_init();
|
||||
}
|
||||
Signature(this._signaturePointer);
|
||||
|
||||
/// Initializes a new instance of [Signature] class from provided [name], [email],
|
||||
/// and optional [time] in seconds from epoch and [offset] in minutes.
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
import 'dart:ffi';
|
||||
import 'bindings/libgit2_bindings.dart';
|
||||
import 'oid.dart';
|
||||
|
||||
class Stash {
|
||||
/// Initializes a new instance of [Stash] class.
|
||||
Stash({
|
||||
const Stash({
|
||||
required this.index,
|
||||
required this.message,
|
||||
required Pointer<git_oid> oid,
|
||||
}) {
|
||||
this.oid = Oid(oid);
|
||||
}
|
||||
required this.oid,
|
||||
});
|
||||
|
||||
/// The position within the stash list.
|
||||
final int index;
|
||||
|
@ -19,7 +15,7 @@ class Stash {
|
|||
final String message;
|
||||
|
||||
/// The commit oid of the stashed state.
|
||||
late final Oid oid;
|
||||
final Oid oid;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
|
|
@ -9,16 +9,13 @@ import 'repository.dart';
|
|||
import 'signature.dart';
|
||||
import 'git_types.dart';
|
||||
import 'tree.dart';
|
||||
import 'util.dart';
|
||||
|
||||
class Tag {
|
||||
/// Initializes a new instance of [Tag] class from provided pointer to
|
||||
/// tag object in memory.
|
||||
///
|
||||
/// Should be freed with `free()` to release allocated memory.
|
||||
Tag(this._tagPointer) {
|
||||
libgit2.git_libgit2_init();
|
||||
}
|
||||
Tag(this._tagPointer);
|
||||
|
||||
/// Initializes a new instance of [Tag] class from provided
|
||||
/// [Repository] object and [sha] hex string.
|
||||
|
|
|
@ -7,16 +7,13 @@ import 'index.dart';
|
|||
import 'repository.dart';
|
||||
import 'oid.dart';
|
||||
import 'git_types.dart';
|
||||
import 'util.dart';
|
||||
|
||||
class Tree {
|
||||
/// Initializes a new instance of [Tree] class from provided pointer to
|
||||
/// tree object in memory.
|
||||
///
|
||||
/// Should be freed with `free()` to release allocated memory.
|
||||
Tree(this._treePointer) {
|
||||
libgit2.git_libgit2_init();
|
||||
}
|
||||
Tree(this._treePointer);
|
||||
|
||||
/// Initializes a new instance of [Tree] class from provided
|
||||
/// [Repository] object and [sha] hex string.
|
||||
|
@ -142,7 +139,7 @@ class Tree {
|
|||
|
||||
class TreeEntry {
|
||||
/// Initializes a new instance of [TreeEntry] class.
|
||||
TreeEntry(this._treeEntryPointer);
|
||||
const TreeEntry(this._treeEntryPointer);
|
||||
|
||||
/// Pointer to memory address for allocated tree entry object.
|
||||
final Pointer<git_tree_entry> _treeEntryPointer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue