# last-commit-log

> Node.js module to get the last git commit information - mostly to be used by CI/CD and building phase

Latest version **3.4.0** (published 2024-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install last-commit-log
pnpm add last-commit-log
yarn add last-commit-log
bun add last-commit-log
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.4.0 |
| Published | 2024-08-19 |
| First published | 2018-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 19 |
| Maintainers | zyhack, xudafeng |
| Keywords | git, commit, history, log |

## Links

- npm: https://www.npmjs.com/package/last-commit-log
- Repository: https://github.com/node-modules/last-commit-log
- Homepage: https://github.com/node-modules/last-commit-log#readme
- Issues: https://github.com/node-modules/last-commit-log/issues
- npm.io page: https://npm.io/package/last-commit-log

## Dependencies (2)

- [dotgitconfig](https://npm.io/package/dotgitconfig.md) 1
- [parse-git-config](https://npm.io/package/parse-git-config.md) ^3.0.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 3.4.0 (latest) — 2024-08-19
- 3.3.0 — 2023-05-01
- 3.2.0 — 2022-07-07
- 3.1.2 — 2022-04-01
- 3.1.1 — 2020-12-08
- 3.1.0 — 2020-12-08
- 3.0.4 — 2020-01-20
- 3.0.3 — 2020-01-16
- 3.0.2 — 2020-01-16
- 3.0.1 — 2020-01-16
- 3.0.0 — 2020-01-13
- 2.1.0 — 2019-01-12
- 2.0.0 — 2018-12-19
- 1.0.13 — 2018-09-07
- 1.0.12 — 2018-08-30
- … 13 more at https://npm.io/package/last-commit-log/versions

## README

# last-commit-log

---

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![node version][node-image]][node-url]
[![npm download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/last-commit-log.svg
[npm-url]: https://npmjs.org/package/last-commit-log
[travis-image]: https://img.shields.io/travis/node-modules/last-commit-log.svg
[travis-url]: https://travis-ci.org/node-modules/last-commit-log
[codecov-image]: https://img.shields.io/codecov/c/github/node-modules/last-commit-log.svg
[codecov-url]: https://codecov.io/gh/node-modules/last-commit-log/branch/master
[node-image]: https://img.shields.io/badge/node.js-%3E=_8-green.svg
[node-url]: http://nodejs.org/download/
[download-image]: https://img.shields.io/npm/dm/last-commit-log.svg
[download-url]: https://npmjs.org/package/last-commit-log

> Node.js module to get the last git commit information - mostly to be used by CI/CD and building phase.

## Who are using

- ⭐⭐⭐[Forward Email](//github.com/forwardemail)
- ⭐⭐⭐[Cabin](//github.com/cabinjs/cabin)
- ⭐⭐⭐[microsoft/BotFramework-WebChat](//github.com/microsoft/BotFramework-WebChat)

[For more](//github.com/node-modules/last-commit-log/network/dependents)

## Usage

```javascript
const LCL = require('last-commit-log');
const lcl = new LCL(); // or `new LCL(dir)` dir is process.cwd() by default
```

Asychronous use, using a Promise:

```javascript
lcl
  .getLastCommit()
  .then(commit => console.log(commit));
```

Synchronous use:

```javascript
const commit = lcl.getLastCommitSync();
```

[full examples](./examples)

commit information is an object like this:

```json
{
  "gitTag": "2.0.0",
  "gitBranch": "master",
  "gitRemote": "git@github.com:group/repo.git", // .git http or ssh
  "gitUrl": "http://github.com/group/repo",     // url only
  "shortHash": "42dc921",
  "hash": "42dc921d25a3e7e1607302d2acfdc3fd991c0c01",
  "subject": "chore: add lock",
  "sanitizedSubject": "chore-add-lock",
  "body": "",
  "committer": {
    "date": "1515240839",
    "relativeDate": "2 hours ago",
    "name": "Committer Fred",
    "email": "fred@fred.com"
  },
  "author": {
    "date": "1515240839",
    "relativeDate": "2 hours ago",
    "name": "Author Baz",
    "email": "baz@baz.com"
  }
}
```

Get map of line changed or added from `git diff`:

```javascript
const data = lcl.diff({
  currentBranch: 'gh-pages',
});

/**
{
  '/diff.js': [
    [
      1,
      46
    ]
  ],
  '/index.js': [
    [
      124,
      125
    ]
  ],
  '/package.json': [],
  '/test/diff.test.js': [
    [
      1,
      14
    ]
  ]
}
 */
console.log(data);
```

## Related Projects

- [macacajs/macaca-coverage](https://github.com/macacajs/macaca-coverage) code coverage tool

<!-- GITCONTRIBUTOR_START -->

## Contributors

|[<img src="https://avatars.githubusercontent.com/u/2139038?v=4" width="100px;"/><br/><sub><b>zhangyuheng</b></sub>](https://github.com/zhangyuheng)<br/>|[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/101466223?v=4" width="100px;"/><br/><sub><b>titanism</b></sub>](https://github.com/titanism)<br/>|[<img src="https://avatars.githubusercontent.com/u/20514752?v=4" width="100px;"/><br/><sub><b>atidyshirt</b></sub>](https://github.com/atidyshirt)<br/>|[<img src="https://avatars.githubusercontent.com/u/1001610?v=4" width="100px;"/><br/><sub><b>stared</b></sub>](https://github.com/stared)<br/>|[<img src="https://avatars.githubusercontent.com/u/10104168?v=4" width="100px;"/><br/><sub><b>yihuineng</b></sub>](https://github.com/yihuineng)<br/>|
| :---: | :---: | :---: | :---: | :---: | :---: |
[<img src="https://avatars.githubusercontent.com/u/197375?v=4" width="100px;"/><br/><sub><b>antife-yinyue</b></sub>](https://github.com/antife-yinyue)<br/>

This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sun May 21 2023 11:57:56 GMT+0800`.

<!-- GITCONTRIBUTOR_END -->

## License

The MIT License (MIT)

---
_Source: https://npm.io/package/last-commit-log · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
