https://github.com/ukyo/tiny-commit-walker
https://github.com/ukyo/tiny-commit-walker
git nodejs typescript
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ukyo/tiny-commit-walker
- Owner: ukyo
- License: mit
- Created: 2017-07-10T07:17:53.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-08T17:42:45.000Z (almost 9 years ago)
- Last Synced: 2025-08-04T04:51:33.561Z (11 months ago)
- Topics: git, nodejs, typescript
- Language: Shell
- Size: 5.52 MB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tiny commit walker
Tiny git commit walker has no native modules.
[](https://travis-ci.org/ukyo/tiny-commit-walker) [](https://ci.appveyor.com/project/ukyo/tiny-commit-walker/branch/master)
[](https://badge.fury.io/js/tiny-commit-walker)
# Install
```
$ npm install --save tiny-commit-walker
```
# Usage
```js
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