Skip to content

Commit

Permalink
Uses modern syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Dec 21, 2024
1 parent 8c4407c commit 08a9ff1
Showing 1 changed file with 29 additions and 43 deletions.
72 changes: 29 additions & 43 deletions src/git/parsers/logParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,21 @@ let _contributorsParser: ContributorsParserMaybeWithStats | undefined;
let _contributorsParserWithStats: ContributorsParserMaybeWithStats | undefined;
export function getContributorsParser(stats?: boolean): ContributorsParserMaybeWithStats {
if (stats) {
if (_contributorsParserWithStats == null) {
_contributorsParserWithStats = createLogParserWithStats({
sha: '%H',
author: '%aN',
email: '%aE',
date: '%at',
});
}
return _contributorsParserWithStats;
}

if (_contributorsParser == null) {
_contributorsParser = createLogParser({
_contributorsParserWithStats ??= createLogParserWithStats({
sha: '%H',
author: '%aN',
email: '%aE',
date: '%at',
});
return _contributorsParserWithStats;
}

_contributorsParser ??= createLogParser({
sha: '%H',
author: '%aN',
email: '%aE',
date: '%at',
});
return _contributorsParser;
}

Expand All @@ -146,23 +142,7 @@ let _graphParserWithStats: GraphParserMaybeWithStats | undefined;

export function getGraphParser(stats?: boolean): GraphParserMaybeWithStats {
if (stats) {
if (_graphParserWithStats == null) {
_graphParserWithStats = createLogParserWithStats({
sha: '%H',
author: '%aN',
authorEmail: '%aE',
authorDate: '%at',
committerDate: '%ct',
parents: '%P',
tips: '%D',
message: '%B',
});
}
return _graphParserWithStats;
}

if (_graphParser == null) {
_graphParser = createLogParser({
_graphParserWithStats ??= createLogParserWithStats({
sha: '%H',
author: '%aN',
authorEmail: '%aE',
Expand All @@ -172,40 +152,46 @@ export function getGraphParser(stats?: boolean): GraphParserMaybeWithStats {
tips: '%D',
message: '%B',
});
return _graphParserWithStats;
}

_graphParser ??= createLogParser({
sha: '%H',
author: '%aN',
authorEmail: '%aE',
authorDate: '%at',
committerDate: '%ct',
parents: '%P',
tips: '%D',
message: '%B',
});
return _graphParser;
}

let _graphStatsParser: ParserWithStats<{ sha: string }> | undefined;

export function getGraphStatsParser(): ParserWithStats<{ sha: string }> {
if (_graphStatsParser == null) {
_graphStatsParser = createLogParserWithStats({ sha: '%H' });
}
_graphStatsParser ??= createLogParserWithStats({ sha: '%H' });
return _graphStatsParser;
}

type RefParser = Parser<string>;

let _refParser: RefParser | undefined;
export function getRefParser(): RefParser {
if (_refParser == null) {
_refParser = createLogParserSingle('%H');
}
_refParser ??= createLogParserSingle('%H');
return _refParser;
}

type RefAndDateParser = Parser<{ sha: string; authorDate: string; committerDate: string }>;

let _refAndDateParser: RefAndDateParser | undefined;
export function getRefAndDateParser(): RefAndDateParser {
if (_refAndDateParser == null) {
_refAndDateParser = createLogParser({
sha: '%H',
authorDate: '%at',
committerDate: '%ct',
});
}
_refAndDateParser ??= createLogParser({
sha: '%H',
authorDate: '%at',
committerDate: '%ct',
});
return _refAndDateParser;
}

Expand Down

0 comments on commit 08a9ff1

Please sign in to comment.