-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
57 additions
and
75 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,32 +1,44 @@ | ||
const gitRawCommits = require("git-raw-commits"); | ||
const splitLines = require("split-lines"); | ||
const { promisify } = require("util"); | ||
const gitSemverTags = require("git-semver-tags"); | ||
const through = require("through2"); | ||
const concat = require("concat-stream"); | ||
|
||
const gitRawCommits = require('git-raw-commits') | ||
const COMMIT_FORMAT = "%n%H%n%an%n%cI%n%s%n%b"; | ||
|
||
const { promisify } = require('util') | ||
const gitSemverTags = require('git-semver-tags') | ||
const through = require('through2') | ||
const concat = require('concat-stream') | ||
|
||
const COMMIT_FORMAT = '%n%H%n%an%n%cI%n%s%n%b' | ||
|
||
const { parseCommit } = require('./parser') | ||
function parseCommit(commit) { | ||
const lines = splitLines(commit); | ||
const [hash, author, date, subject, ...body] = lines.splice( | ||
1, | ||
lines.length - 2 | ||
); | ||
return { hash, author, date, subject, body }; | ||
} | ||
|
||
function getCommits(from, to) { | ||
return new Promise((resolve) => { | ||
return new Promise(resolve => { | ||
gitRawCommits({ | ||
format: COMMIT_FORMAT, | ||
from, | ||
to, | ||
}).pipe(through.obj((data, enc, next) => { | ||
next(null, parseCommit(data.toString())) | ||
})).pipe(concat(data => { | ||
resolve(data) | ||
})) | ||
}) | ||
to | ||
}) | ||
.pipe( | ||
through.obj((data, enc, next) => { | ||
next(null, parseCommit(data.toString())); | ||
}) | ||
) | ||
.pipe( | ||
concat(data => { | ||
resolve(data); | ||
}) | ||
); | ||
}); | ||
} | ||
|
||
const getTags = promisify(gitSemverTags) | ||
const getTags = promisify(gitSemverTags); | ||
|
||
module.exports = { | ||
getTags, | ||
getCommits, | ||
} | ||
getCommits | ||
}; |
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
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
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