Skip to content

Commit 23e6786

Browse files
fix history panel not rendering when history is empty (#1215)
catch error to handle the log return when there are no past commits in the current branch prettify and format correctly change handled return to simply a non-null, non-zero code rather than 0 with an empty list of commits Rebases to include changes from #13645 Update Playwright Snapshots Updates selection to selectionBackground, docs Update Playwright Snapshots Add renderer Fix UI test locator Fix linter Update Playwright Snapshots Buffer message while waiting for the terminal Update Playwright Snapshots Co-authored-by: Shawn Esquivel <[email protected]>
1 parent c7e7363 commit 23e6786

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

src/components/GitCommitGraph.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,19 @@ export class GitCommitGraph extends React.Component<IGitCommitGraphProps> {
9595
}
9696

9797
getHeight(): number {
98-
return (
99-
this._graphData[this._graphData.length - 1].yOffset +
100-
this.props.getNodeHeight(
101-
this.props.commits[this.props.commits.length - 1].sha
102-
)
103-
);
98+
// if this.props.commits.length = 0, just pass 0
99+
const numCommits = this.props.commits.length;
100+
const lastNodeHeight =
101+
numCommits === 0
102+
? 0
103+
: this.props.getNodeHeight(this.props.commits[numCommits - 1].sha);
104+
105+
const numGraphNodes = this._graphData.length;
106+
const lastYOffset =
107+
numGraphNodes === 0
108+
? 0
109+
: this._graphData[this._graphData.length - 1].yOffset;
110+
return lastYOffset + lastNodeHeight;
104111
}
105112

106113
renderRouteNode(svgPathDataAttribute: string, branch: number): JSX.Element {

src/model.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -919,14 +919,18 @@ export class GitExtension implements IGitExtension {
919919
return await this._taskHandler.execute<Git.ILogResult>(
920920
'git:fetch:log',
921921
async () => {
922-
return await requestAPI<Git.ILogResult>(
923-
URLExt.join(path, 'log'),
924-
'POST',
925-
{
926-
history_count: count,
927-
follow_path: this.selectedHistoryFile?.to
928-
}
929-
);
922+
try {
923+
return await requestAPI<Git.ILogResult>(
924+
URLExt.join(path, 'log'),
925+
'POST',
926+
{
927+
history_count: count,
928+
follow_path: this.selectedHistoryFile?.to
929+
}
930+
);
931+
} catch (error) {
932+
return { code: 1 };
933+
}
930934
}
931935
);
932936
}

0 commit comments

Comments
 (0)