forked from conventional-changelog/commitlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread.ts
34 lines (29 loc) · 747 Bytes
/
read.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import minimist from 'minimist';
import type {GitOptions} from 'git-raw-commits';
import {getHistoryCommits} from './get-history-commits';
import {getEditCommit} from './get-edit-commit';
interface GetCommitMessageOptions {
cwd?: string;
from?: string;
to?: string;
edit?: boolean | string;
gitLogArgs?: string;
}
// Get commit messages
export default async function getCommitMessages(
settings: GetCommitMessageOptions
): Promise<string[]> {
const {cwd, from, to, edit, gitLogArgs} = settings;
if (edit) {
return getEditCommit(cwd, edit);
}
let gitOptions: GitOptions = {from, to};
if (gitLogArgs) {
gitOptions = {
...minimist(gitLogArgs.split(' ')),
from,
to,
};
}
return getHistoryCommits(gitOptions, {cwd});
}