mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 12:49:08 -04:00
refactor!: use named arguments if there is more than one
This commit is contained in:
parent
ec80ad3dd4
commit
5f7fdf4bd3
66 changed files with 1920 additions and 1136 deletions
|
@ -10,19 +10,22 @@ class Oid {
|
|||
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
|
||||
/// in the ODB of [repo]sitory with provided hexadecimal [sha] string that is 40 characters
|
||||
/// long or shorter.
|
||||
///
|
||||
/// Throws [ArgumentError] if provided [sha] hex string is not valid.
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
Oid.fromSHA(Repository repository, String sha) {
|
||||
Oid.fromSHA({required Repository repo, required String sha}) {
|
||||
if (isValidShaHex(sha)) {
|
||||
if (sha.length == 40) {
|
||||
_oidPointer = bindings.fromSHA(sha);
|
||||
} else {
|
||||
final odb = repository.odb;
|
||||
_oidPointer = odb.existsPrefix(bindings.fromStrN(sha), sha.length);
|
||||
final odb = repo.odb;
|
||||
_oidPointer = odb.existsPrefix(
|
||||
shortOidPointer: bindings.fromStrN(sha),
|
||||
length: sha.length,
|
||||
);
|
||||
odb.free();
|
||||
}
|
||||
} else {
|
||||
|
@ -46,27 +49,32 @@ class Oid {
|
|||
@override
|
||||
bool operator ==(other) {
|
||||
return (other is Oid) &&
|
||||
(bindings.compare(_oidPointer, other._oidPointer) == 0);
|
||||
(bindings.compare(aPointer: _oidPointer, bPointer: other._oidPointer) ==
|
||||
0);
|
||||
}
|
||||
|
||||
bool operator <(other) {
|
||||
return (other is Oid) &&
|
||||
(bindings.compare(_oidPointer, other._oidPointer) == -1);
|
||||
(bindings.compare(aPointer: _oidPointer, bPointer: other._oidPointer) ==
|
||||
-1);
|
||||
}
|
||||
|
||||
bool operator <=(other) {
|
||||
return (other is Oid) &&
|
||||
(bindings.compare(_oidPointer, other._oidPointer) == -1);
|
||||
(bindings.compare(aPointer: _oidPointer, bPointer: other._oidPointer) ==
|
||||
-1);
|
||||
}
|
||||
|
||||
bool operator >(other) {
|
||||
return (other is Oid) &&
|
||||
(bindings.compare(_oidPointer, other._oidPointer) == 1);
|
||||
(bindings.compare(aPointer: _oidPointer, bPointer: other._oidPointer) ==
|
||||
1);
|
||||
}
|
||||
|
||||
bool operator >=(other) {
|
||||
return (other is Oid) &&
|
||||
(bindings.compare(_oidPointer, other._oidPointer) == 1);
|
||||
(bindings.compare(aPointer: _oidPointer, bPointer: other._oidPointer) ==
|
||||
1);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue