mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 12:49:08 -04:00
refactor(repository)!: move descendantOf()
method into Commit (#43)
This commit is contained in:
parent
9918ab0905
commit
bad5e20581
4 changed files with 21 additions and 47 deletions
|
@ -2,6 +2,7 @@ import 'dart:ffi';
|
|||
|
||||
import 'package:libgit2dart/libgit2dart.dart';
|
||||
import 'package:libgit2dart/src/bindings/commit.dart' as bindings;
|
||||
import 'package:libgit2dart/src/bindings/graph.dart' as graph_bindings;
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
|
||||
class Commit {
|
||||
|
@ -309,6 +310,18 @@ class Commit {
|
|||
return Commit(bindings.nthGenAncestor(commitPointer: _commitPointer, n: n));
|
||||
}
|
||||
|
||||
/// Checks if commit is the descendant of another [ancestor] commit.
|
||||
///
|
||||
/// Note that a commit is not considered a descendant of itself, in contrast
|
||||
/// to `git merge-base --is-ancestor`.
|
||||
bool descendantOf(Commit ancestor) {
|
||||
return graph_bindings.descendantOf(
|
||||
repoPointer: bindings.owner(_commitPointer),
|
||||
commitPointer: bindings.id(_commitPointer),
|
||||
ancestorPointer: bindings.id(ancestor.pointer),
|
||||
);
|
||||
}
|
||||
|
||||
/// Creates an in-memory copy of a commit.
|
||||
///
|
||||
/// **IMPORTANT**: Should be freed to release allocated memory.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue