我们正在尝试在prs中设置最大行更改,但注意到有一些元文件很容易超过这个限制,例如yarn.lock。
有人知道如何从添加和删除中排除文件吗?
// ...
const linesAdded = danger.github.pr.additions || 0;
const linesRemoved = danger.github.pr.deletions || 0;
// ...
if (linesAdded + linesRemoved > bigPRThreshold) {
fail(
`This PR size is too large (Over ${bigPRThreshold} lines. Please split into separate PRs to enable faster & easier review.`
);
}
// ...发布于 2021-02-05 06:48:09
我发现以下gitDSL函数可以访问单个文件中的信息
//This should make it really easy to do work when specific keypaths have changed inside a JSON file.
JSONDiffForFile(filename: string) => Promise
// Provides a JSON patch (rfc6902) between the two versions of a JSON file, returns null if you don't have any changes for the file in the diff.
// Note that if you are looking to just see changes like: before, after, added or removed - you should use `JSONDiffForFile` instead, as this can be a bit unwieldy for a Dangerfile.
JSONPatchForFile(filename: string) => Promise
// Offers the diff for a specific file
diffForFile(filename: string) => Promise
// Offers the overall lines of code added/removed in the diff
linesOfCode() => Promise
// Offers the structured diff for a specific file
structuredDiffForFile(filename: string) => Promise(有关这些函数的文档:https://danger.systems/js/reference.html#GitDSL)
使用danger.git.structuredDiffForFile,我可以计算出我想要排除的行
const file = 'yarn.lock';
const diff1 = await danger.git.structuredDiffForFile(file);
const excludedLines = diff1.chunks[0].changes.lengthhttps://stackoverflow.com/questions/65397239
复制相似问题