Skip to content

relizy / isAncestor

Function: isAncestor()

isAncestor(ancestor, descendant, cwd?): Promise<boolean>

Defined in: src/core/git-refs.ts:26

Returns true when ancestor is an ancestor of descendant (i.e. reachable from it). Uses git merge-base --is-ancestor, which exits 0 when true and non-zero otherwise. Any error (e.g. unknown ref) is treated as "not an ancestor".

Parameters

ancestor

string

descendant

string

cwd?

string

Returns

Promise<boolean>

Released under the MIT License.