Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/christianmurphy/file-util-git-history
Get a file's git history
https://github.com/christianmurphy/file-util-git-history
file git history javascript nodejs source-control utility
Last synced: 8 days ago
JSON representation
Get a file's git history
- Host: GitHub
- URL: https://github.com/christianmurphy/file-util-git-history
- Owner: ChristianMurphy
- License: mit
- Created: 2018-03-13T03:20:03.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T15:15:18.000Z (3 months ago)
- Last Synced: 2025-01-08T12:03:29.925Z (17 days ago)
- Topics: file, git, history, javascript, nodejs, source-control, utility
- Language: JavaScript
- Homepage:
- Size: 510 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# file-util-git-history
[![NPM Version](https://img.shields.io/npm/v/file-util-git-history.svg)](https://www.npmjs.com/package/file-util-git-history)
[![CI](https://github.com/ChristianMurphy/file-util-git-history/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/ChristianMurphy/file-util-git-history/actions/workflows/main.yml)## Installation
```shell
# npm installation
npm install file-util-git-history# yarn installation
yarn add file-util-git-history
```## Usage
```javascript
const { gitHistory } = require("file-util-git-history");// get history for current file
gitHistory(__filename)
// get the SHA hash for each commit
.then((history) => history.map(({ commit }) => commit.sha()))
// print out the SHAs
.then(console.log);
```git history can accept two parameters:
- `{string} filePath` path to file
- `{Object} [options]` optional configuration
- `{string} [gitPath]` - optional predetermined git folder to get history fromwill return a promise that resolves to a list of `{status, commit}`.
Where `status` is a git status code, and `commit` is a [nodegit `Commit` class](http://www.nodegit.org/api/commit/).