mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-16 14:18:29 +00:00
fix: exclude renames from contributor generation (#1643)
* fix: exclude renames from contributor generation * fix: exclude renames from contributor generation
This commit is contained in:
@@ -9,6 +9,8 @@ const FETCH_DEPTH = process.env.FETCH_DEPTH || 1000;
|
||||
|
||||
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
|
||||
|
||||
const git = simpleGit();
|
||||
|
||||
const cache = new Map();
|
||||
|
||||
const getUserName = pMemoize(
|
||||
@@ -26,8 +28,19 @@ const getUserName = pMemoize(
|
||||
{ cacheKey: ([commit]) => commit.author_email, cache }
|
||||
);
|
||||
|
||||
// Check that a commit changes more than just the icon name
|
||||
const isCommitRelevant = async (hash, file) => {
|
||||
const summary = await git.diffSummary(['--diff-filter=AM', `${hash}~1`, hash]);
|
||||
return summary.files.some(({ file: name }) => name === file);
|
||||
};
|
||||
|
||||
const getContributors = async (file, includeCoAuthors) => {
|
||||
const { all: commits } = await simpleGit().log([`HEAD~${FETCH_DEPTH}..`, '--', file]);
|
||||
const { all } = await git.log([`HEAD~${FETCH_DEPTH}..`, '--', file]);
|
||||
const commits = file.endsWith('.svg')
|
||||
? (
|
||||
await Promise.all(all.map((commit) => isCommitRelevant(commit.hash, file) && commit))
|
||||
).filter(Boolean)
|
||||
: all;
|
||||
|
||||
const emails = new Map();
|
||||
for (let i = commits.length - 1; i >= 0; i -= 1) {
|
||||
|
||||
Reference in New Issue
Block a user