tiny-commit-walker
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

Tiny commit walker

Tiny git commit walker has no native modules.

Build Status Build status npm version

Install

$ npm install --save tiny-commit-walker

Usage

import { Repository } from 'tiny-commit-walker';
 
(async () => {
  const repo = new Repository('path/to/repo/.git');
  // const repo = new Repository(await Repository.findGitDir('path/to/repo'));
  const branches = await repo.readBranches();
  const tags = await repo.readTags();
  const branch = await repo.readCommitByBranch('master');
  console.log(branch.name); // master
  let commit = branch.commit;
  while (commit.hasParents) {
    console.log(commit.hash);
    commit = await commit.walk(); // default parameter of commit.walk is base parent hash.
  }
})();
 
// or
 
const repo = new Repository('path/to/repo/.git');
const branches = repo.readBranchesSync();
const tags = repo.readTagsSync();
const branch = repo.readCommitByBranchSync('master');
console.log(branch.name); // master
let commit = branch.commit;
while (commit.hasParents) {
  console.log(commit.hash);
  commit = commit.walkSync();
}

Documentation

https://ukyo.github.io/tiny-commit-walker

Readme

Keywords

Package Sidebar

Install

npm i tiny-commit-walker

Weekly Downloads

57,018

Version

1.2.1

License

MIT

Last publish

Collaborators

  • ukyo