Skip to content

Commit 08a9ff1

Browse files
committed
Uses modern syntax
1 parent 8c4407c commit 08a9ff1

File tree

1 file changed

+29
-43
lines changed

1 file changed

+29
-43
lines changed

src/git/parsers/logParser.ts

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,21 @@ let _contributorsParser: ContributorsParserMaybeWithStats | undefined;
108108
let _contributorsParserWithStats: ContributorsParserMaybeWithStats | undefined;
109109
export function getContributorsParser(stats?: boolean): ContributorsParserMaybeWithStats {
110110
if (stats) {
111-
if (_contributorsParserWithStats == null) {
112-
_contributorsParserWithStats = createLogParserWithStats({
113-
sha: '%H',
114-
author: '%aN',
115-
email: '%aE',
116-
date: '%at',
117-
});
118-
}
119-
return _contributorsParserWithStats;
120-
}
121-
122-
if (_contributorsParser == null) {
123-
_contributorsParser = createLogParser({
111+
_contributorsParserWithStats ??= createLogParserWithStats({
124112
sha: '%H',
125113
author: '%aN',
126114
email: '%aE',
127115
date: '%at',
128116
});
117+
return _contributorsParserWithStats;
129118
}
119+
120+
_contributorsParser ??= createLogParser({
121+
sha: '%H',
122+
author: '%aN',
123+
email: '%aE',
124+
date: '%at',
125+
});
130126
return _contributorsParser;
131127
}
132128

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

147143
export function getGraphParser(stats?: boolean): GraphParserMaybeWithStats {
148144
if (stats) {
149-
if (_graphParserWithStats == null) {
150-
_graphParserWithStats = createLogParserWithStats({
151-
sha: '%H',
152-
author: '%aN',
153-
authorEmail: '%aE',
154-
authorDate: '%at',
155-
committerDate: '%ct',
156-
parents: '%P',
157-
tips: '%D',
158-
message: '%B',
159-
});
160-
}
161-
return _graphParserWithStats;
162-
}
163-
164-
if (_graphParser == null) {
165-
_graphParser = createLogParser({
145+
_graphParserWithStats ??= createLogParserWithStats({
166146
sha: '%H',
167147
author: '%aN',
168148
authorEmail: '%aE',
@@ -172,40 +152,46 @@ export function getGraphParser(stats?: boolean): GraphParserMaybeWithStats {
172152
tips: '%D',
173153
message: '%B',
174154
});
155+
return _graphParserWithStats;
175156
}
157+
158+
_graphParser ??= createLogParser({
159+
sha: '%H',
160+
author: '%aN',
161+
authorEmail: '%aE',
162+
authorDate: '%at',
163+
committerDate: '%ct',
164+
parents: '%P',
165+
tips: '%D',
166+
message: '%B',
167+
});
176168
return _graphParser;
177169
}
178170

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

181173
export function getGraphStatsParser(): ParserWithStats<{ sha: string }> {
182-
if (_graphStatsParser == null) {
183-
_graphStatsParser = createLogParserWithStats({ sha: '%H' });
184-
}
174+
_graphStatsParser ??= createLogParserWithStats({ sha: '%H' });
185175
return _graphStatsParser;
186176
}
187177

188178
type RefParser = Parser<string>;
189179

190180
let _refParser: RefParser | undefined;
191181
export function getRefParser(): RefParser {
192-
if (_refParser == null) {
193-
_refParser = createLogParserSingle('%H');
194-
}
182+
_refParser ??= createLogParserSingle('%H');
195183
return _refParser;
196184
}
197185

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

200188
let _refAndDateParser: RefAndDateParser | undefined;
201189
export function getRefAndDateParser(): RefAndDateParser {
202-
if (_refAndDateParser == null) {
203-
_refAndDateParser = createLogParser({
204-
sha: '%H',
205-
authorDate: '%at',
206-
committerDate: '%ct',
207-
});
208-
}
190+
_refAndDateParser ??= createLogParser({
191+
sha: '%H',
192+
authorDate: '%at',
193+
committerDate: '%ct',
194+
});
209195
return _refAndDateParser;
210196
}
211197

0 commit comments

Comments
 (0)