wrap-git
Version:
Wraps GitHub profile and provides summarized details about repos, commits and language coverages for a given profile.
23 lines (22 loc) • 786 B
JavaScript
import { getCommitsBetween } from "../api/commits.js";
import { throwError } from "../utils/error.js";
export const commitSummarizar = async (username, created_at, token) => {
const commitsPerYear = [];
let totalCommits = 0;
try {
const startYear = new Date(created_at).getFullYear();
const currentYear = new Date().getFullYear();
for (let year = startYear; year <= currentYear; year++) {
const yearlyCommits = await getCommitsBetween(username, year, token);
commitsPerYear.push({ year: year.toString(), count: yearlyCommits });
totalCommits += yearlyCommits;
}
return {
totalCommits,
commitsPerYear,
};
}
catch (error) {
throwError(error);
}
};