mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 12:49:08 -04:00
feat(repository): add ability to lookup different types of git objects with []
This commit is contained in:
parent
f19a34a768
commit
2cf974c624
14 changed files with 124 additions and 67 deletions
|
@ -15,14 +15,20 @@ class Oid {
|
|||
/// in the ODB of [repository] 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) {
|
||||
if (sha.length == 40) {
|
||||
_oidPointer = bindings.fromSHA(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);
|
||||
odb.free();
|
||||
}
|
||||
} else {
|
||||
final odb = repository.odb;
|
||||
_oidPointer = odb.existsPrefix(bindings.fromStrN(sha), sha.length);
|
||||
odb.free();
|
||||
throw ArgumentError.value('$sha is not a valid sha hex string');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue