-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: update README.md * docs(README): upgrade supported node version
- Loading branch information
1 parent
ff7e09b
commit 0032eb4
Showing
1 changed file
with
52 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,92 @@ | ||
# Git-Parse | ||
Git-Parse | ||
========= | ||
|
||
`git-parse` is a utility which generates an array of javascript objects representing the current branch of a local git repository's commit history. | ||
[![NPM version](https://img.shields.io/npm/v/git-parse.svg)](https://www.npmjs.com/package/git-parse) | ||
[![NPM Downloads](https://img.shields.io/npm/dm/git-parse.svg?style=flat)](https://www.npmjs.org/package/git-parse) | ||
[![Bundlephobia](https://badgen.net/bundlephobia/minzip/git-parse)](https://bundlephobia.com/result?p=git-parse) | ||
|
||
## Getting Started | ||
> `git-parse` is a utility which generates an array of javascript objects representing the current branch of a local git repository's commit history. | ||
### Prerequisites | ||
### Details | ||
|
||
``` | ||
nodejs version 14 or higher | ||
``` | ||
- Support NodeJS >= 14 | ||
|
||
### Installation | ||
|
||
``` | ||
npm i git-parse | ||
```bash | ||
npm install git-parse | ||
``` | ||
|
||
### Usage | ||
|
||
``` | ||
```js | ||
const { gitToJs } = require('git-parse'); | ||
|
||
const commitsPromise = gitToJs('path/to/repo/'); | ||
|
||
commitsPromise.then(commits => console.log(JSON.stringify(commits, null, 2))); | ||
``` | ||
|
||
**Console Output:** | ||
|
||
``` | ||
[ | ||
{ | ||
"hash":"7cedc121ee163d859dfdb9911e627d4b5933cc6d", | ||
"authorName":"[email protected]", | ||
"authorEmail":"[email protected]", | ||
"date":"Wed, 10 Jan 2018 16:44:52 -0500", | ||
"message":"initial setup", | ||
"filesAdded":[ | ||
{ "path":"packages/raspberry-popsicle/index.js" }, | ||
{ "path":"packages/raspberry-popsicle/package-lock.json" }, | ||
{ "path":"packages/raspberry-popsicle/package.json" } | ||
], | ||
"filesDeleted":[ ], | ||
"filesModified":[ ], | ||
"filesRenamed":[ ] | ||
}, | ||
{ | ||
"hash": "226f032eb87ac1eb18b7212eeaf1356980a9ae03", | ||
"authorName": "[email protected]", | ||
"authorEmail": "[email protected]", | ||
"date": "Wed, 10 Jan 2018 15:25:16 -0500", | ||
"message": "add README", | ||
"filesAdded": [ | ||
{ "path": "README.md" } | ||
], | ||
"filesDeleted": [], | ||
"filesModified": [], | ||
"filesRenamed": [] | ||
} | ||
] | ||
``` | ||
<details> | ||
<summary><b>Console output:</b></summary> | ||
|
||
```json | ||
[ | ||
{ | ||
"hash": "7cedc121ee163d859dfdb9911e627d4b5933cc6d", | ||
"authorName": "[email protected]", | ||
"authorEmail": "[email protected]", | ||
"date": "Wed, 10 Jan 2018 16:44:52 -0500", | ||
"message": "initial setup", | ||
"filesAdded":[ | ||
{ "path": "packages/raspberry-popsicle/index.js" }, | ||
{ "path": "packages/raspberry-popsicle/package-lock.json" }, | ||
{ "path": "packages/raspberry-popsicle/package.json" } | ||
], | ||
"filesDeleted": [], | ||
"filesModified": [], | ||
"filesRenamed": [] | ||
}, | ||
{ | ||
"hash": "226f032eb87ac1eb18b7212eeaf1356980a9ae03", | ||
"authorName": "[email protected]", | ||
"authorEmail": "[email protected]", | ||
"date": "Wed, 10 Jan 2018 15:25:16 -0500", | ||
"message": "add README", | ||
"filesAdded": [ | ||
{ "path": "README.md" } | ||
], | ||
"filesDeleted": [], | ||
"filesModified": [], | ||
"filesRenamed": [] | ||
} | ||
] | ||
``` | ||
</details> | ||
|
||
## API | ||
|
||
### gitToJs(pathToRepo, [options]) | ||
### .gitToJs(pathToRepo, [options]) | ||
|
||
Returns a promise which resolves with a list of objects describing git commits on the current branch. `pathToRepo` is a string. `options` is an optional object with one property, `sinceCommit`, which is a commit hash. If `sinceCommit` is present, gitToJs will return logs for commits _after_ the commit specified. | ||
|
||
``` | ||
```js | ||
const { gitToJs } = require('git-parse'); | ||
|
||
const commitsPromise = gitToJs('path/to/repo/'); | ||
|
||
commitsPromise.then(commits => console.log(JSON.stringify(commits, null, 2))); | ||
``` | ||
|
||
### checkOutCommit(pathToRepo, commitHash, [options]) | ||
### .checkOutCommit(pathToRepo, commitHash, [options]) | ||
|
||
Checks a repository out to a given commit. `hash` is the commit hash. Options is an optional object with one property, `force`. `force` adds `--force` to the [underlying git checkout](https://git-scm.com/docs/git-checkout#git-checkout--f). Returns a promise. | ||
|
||
### gitPull(pathToRepo) | ||
### .gitPull(pathToRepo) | ||
|
||
Runs 'git pull' on the repository at the given path. Returns a promise. | ||
|
||
### gitDiff(pathToRepo, commitHash1, [commitHash2], [file]) | ||
### .gitDiff(pathToRepo, commitHash1, [commitHash2], [file]) | ||
|
||
Returns a git diff given a path to the repo, a commit, an optional second commit, and an optional file path. | ||
|
||
|