@commitlint/read
从指定范围或磁盘读取提交消息
¥Read commit messages from a specified range or disk
安装
¥Install
sh
npm install --save @commitlint/read
签名
¥Signature
ts
type Range = {
/* Lower end of the commit range to read */
from: string;
/* Upper end of the commit range to read */
to: string;
/* Whether (boolean) to read from ./.git/COMMIT_EDITMSG or where to read from (string) */
edit?: boolean | string;
};
read(range: Range) => Promise<string[]>
导入
¥Import
js
import read from "@commitlint/read";
示例
¥Examples
考虑使用包含两个提交的存储库:
¥Consider to have a repository with two commits:
初始提交
¥Initial commit
我做了一些事情
¥I did something
使用 edit: true
¥Using edit: true
js
const result = await read({ edit: true });
console.info(result);
// => ['I did something\n\n']
读取最近两次提交
¥Read last two commits
js
const result = await read({ from: "HEAD~2" });
console.info(result);
// => ['I did something\n\n', 'Initial commit\n\n']
读取一定范围内的提交
¥Read commits within a range
js
const result = await read({ from: "HEAD~2", to: "HEAD~1" });
console.info(result);
// => ['Initial commit\n\n']
从 git gui 文件读取提交信息
¥Read commit message from git gui file
js
const result = await read({ edit: "./git/GITGUI_EDITMESSAGE" });
console.info(result);
// => ['I did something via git gui\n\n']