# file-util-git-history

> Get a file's git history

Latest version **3.1.0** (published 2021-06-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install file-util-git-history
pnpm add file-util-git-history
yarn add file-util-git-history
bun add file-util-git-history
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2021-06-17 |
| First published | 2018-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | ^10.0.0 \|\| ^12.0.0 \|\| ^14.0.0 |
| Dependencies | 2 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Christian Murphy |
| Maintainers | christianmurphy |
| Keywords | file, utility, git, history, source, commit, scm |

## Links

- npm: https://www.npmjs.com/package/file-util-git-history
- Repository: https://github.com/ChristianMurphy/file-util-git-history
- Homepage: https://github.com/ChristianMurphy/file-util-git-history#readme
- Issues: https://github.com/ChristianMurphy/file-util-git-history/issues
- npm.io page: https://npm.io/package/file-util-git-history

## Dependencies (2)

- [nodegit](https://npm.io/package/nodegit.md) ^0.27.0
- [@types/nodegit](https://npm.io/package/@types/nodegit.md) ^0.27.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 3.1.0 (latest) — 2021-06-17
- 3.0.1 — 2021-06-17
- 3.0.0 — 2020-09-02
- 2.2.0 — 2019-12-29
- 2.1.0 — 2019-08-12
- 2.0.0 — 2019-06-04
- 1.1.0 — 2018-11-06
- 1.0.2 — 2018-04-16
- 1.0.1 — 2018-03-14
- 1.0.0 — 2018-03-13

## 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 from

will 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/).

---
_Source: https://npm.io/package/file-util-git-history · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
