Skip to content

Commit

Permalink
Added commitProjectsMap to associate plugins with commit-project matches
Browse files Browse the repository at this point in the history
  • Loading branch information
AvrAlexandra committed Oct 24, 2024
1 parent 6eded5e commit 11f0ee2
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/commands/history/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export async function analyseHistory(folders: string[], options: AnalyseOptions,
console.log('No folders provided to analyze.');
return;
}
const projectMap: Map<string, { commit: string, projects: DepinderProject[] }[]> = new Map();

const commitProjectsMap: Map<string, { commit: any, projects: DepinderProject[] }[]> = new Map();

for (const folder of folders) {
const commits = await getCommits(folder);
Expand All @@ -33,9 +34,11 @@ export async function analyseHistory(folders: string[], options: AnalyseOptions,
continue;
}
for (const commit of commits) {
await processCommitForPlugins(commit, folder, selectedPlugins, projectMap);
await processCommitForPlugins(commit, folder, selectedPlugins, commitProjectsMap);
}
}

console.log(commitProjectsMap);
}

// Function to fetch commits from a Git repository
Expand All @@ -52,7 +55,11 @@ async function getCommits(folder: string): Promise<any[]> {
}

// Function to process each commit and update the map by plugin
async function processCommitForPlugins(commit: any, folder: string, selectedPlugins: Plugin[], projectMap: Map<string, { commit: string, projects: DepinderProject[] }[]>
async function processCommitForPlugins(
commit: any,
folder: string,
selectedPlugins: Plugin[],
commitProjectsMap: Map<string, { commit: any, projects: DepinderProject[] }[]>
) {
const changes = await getChangedFiles(commit, folder);
await ensureDirectoryExists(depinderTempFolder);
Expand All @@ -71,9 +78,8 @@ async function processCommitForPlugins(commit: any, folder: string, selectedPlug
}
}

console.log('Filtered Files: ' + filteredFiles);

if (filteredFiles.length > 0) {
console.log('Filtered Files: ' + filteredFiles);
const tempFilePaths: string[] = [];
for (const file of filteredFiles) {
const tempFilePath = path.join(depinderTempFolder, `${commit.oid}-${path.basename(file)}`);
Expand All @@ -100,6 +106,11 @@ async function processCommitForPlugins(commit: any, folder: string, selectedPlug
});

await cleanupTempFiles(tempFilePaths);

if (!commitProjectsMap.has(plugin.name)) {
commitProjectsMap.set(plugin.name, []);
}
commitProjectsMap.get(plugin.name)!.push({ commit, projects });
}
}
}
Expand Down

0 comments on commit 11f0ee2

Please sign in to comment.