Skip to content

setSorting

Set the order in which commits are visited.

Signature

ts
class Revwalk {
  setSorting(sort: number): this;
}

Parameters

  • sortrequired · number

    Orderings that may be specified for Revwalk iteration. - RevwalkSort.None : Sort the repository contents in no particular ordering. This sorting is arbitrary, implementation-specific, and subject to change at any time. This is the default sorting for new walkers. - RevwalkSort.Topological : Sort the repository contents in topological order (children before parents). This sorting mode can be combined with time sorting. - RevwalkSort.Time : Sort the repository contents by commit time. This sorting mode can be combined with topological sorting. - RevwalkSort.Reverse : Iterate through the repository contents in reverse order. This sorting mode can be combined with any others.

Examples

ts
import { openRepository, RevwalkSort } from 'es-git';

const repo = await openRepository('.');
const revwalk = repo.revwalk();
revwalk.setSorting(RevwalkSort.Time | RevwalkSort.Reverse);

Released under the MIT License.