Skip to content

Commit

Permalink
fix: report committers through day is inclusive to end of day
Browse files Browse the repository at this point in the history
  • Loading branch information
Brocco committed Jun 18, 2024
1 parent 29fb342 commit 789f637
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions libs/report/committers/src/lib/committers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { format, subMonths } from 'date-fns';
import { addHours, addMinutes, addSeconds, format, formatISO, subMonths } from 'date-fns';
import { reportCommittersCommand } from './committers';
import { runCommand } from '@herodevs/utility';
import { dateFormat } from './constants';
Expand Down Expand Up @@ -77,8 +77,10 @@ describe('reportCommittersCommand', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
reportCommittersCommand.handler(args as any);

const startDateEndOfDay = formatISO(addHours(addMinutes(addSeconds(startDate, 59), 59), 23));

expect(runCommandMock).toHaveBeenCalledWith(
`git log --since "${endDate}" --until "${startDate}" --pretty=format:"%hΓΓΓΓ%anΓΓΓΓ%ad" `
`git log --since "${endDate}" --until "${startDateEndOfDay}" --pretty=format:"%hΓΓΓΓ%anΓΓΓΓ%ad" `
);
});

Expand Down
8 changes: 6 additions & 2 deletions libs/report/committers/src/lib/committers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { format, subMonths } from 'date-fns';
import { addHours, addMinutes, addSeconds, format, formatISO, subMonths } from 'date-fns';
import { runCommand } from '@herodevs/utility';
import { parseDateFlags } from './parse-date-flags';
import { dateFormat, gitOutputFormat, monthsToSubtract } from './constants';
Expand Down Expand Up @@ -57,8 +57,12 @@ export const reportCommittersCommand: CommandModule<object, Options> = {

async function run(args: ArgumentsCamelCase<Options>): Promise<void> {
const { startDate, endDate } = parseDateFlags(dateFormat, args.startDate, args.endDate);
const startDateEndOfDay = formatISO(addHours(addMinutes(addSeconds(startDate, 59), 59), 23));

const ignores = args.exclude && args.exclude.length ? `-- . "!(${args.exclude.join('|')})"` : '';
const gitCommand = `git log --since "${endDate}" --until "${startDate}" --pretty=format:${gitOutputFormat} ${ignores}`;

const gitCommand = `git log --since "${endDate}" --until "${startDateEndOfDay}" --pretty=format:${gitOutputFormat} ${ignores}`;

const result = await runCommand(gitCommand);

const rawEntries = (result as string).split('\n');
Expand Down

0 comments on commit 789f637

Please sign in to comment.