From 5960aca4fccdc55e011e941a311fd5c9c7dbe106 Mon Sep 17 00:00:00 2001 From: basokant Date: Tue, 7 Feb 2023 02:53:11 -0500 Subject: [PATCH] fix history panel not rendering when history is empty 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 --- src/components/GitCommitGraph.tsx | 19 +++++++++++++------ src/model.ts | 20 ++++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/components/GitCommitGraph.tsx b/src/components/GitCommitGraph.tsx index d7d24c2b5..1560e61d7 100644 --- a/src/components/GitCommitGraph.tsx +++ b/src/components/GitCommitGraph.tsx @@ -95,12 +95,19 @@ export class GitCommitGraph extends React.Component { } getHeight(): number { - return ( - this._graphData[this._graphData.length - 1].yOffset + - this.props.getNodeHeight( - this.props.commits[this.props.commits.length - 1].sha - ) - ); + // if this.props.commits.length = 0, just pass 0 + const numCommits = this.props.commits.length; + const lastNodeHeight = + numCommits === 0 + ? 0 + : this.props.getNodeHeight(this.props.commits[numCommits - 1].sha); + + const numGraphNodes = this._graphData.length; + const lastYOffset = + numGraphNodes === 0 + ? 0 + : this._graphData[this._graphData.length - 1].yOffset; + return lastYOffset + lastNodeHeight; } renderRouteNode(svgPathDataAttribute: string, branch: number): JSX.Element { diff --git a/src/model.ts b/src/model.ts index b16478b04..0c658f04d 100644 --- a/src/model.ts +++ b/src/model.ts @@ -919,14 +919,18 @@ export class GitExtension implements IGitExtension { return await this._taskHandler.execute( 'git:fetch:log', async () => { - return await requestAPI( - URLExt.join(path, 'log'), - 'POST', - { - history_count: count, - follow_path: this.selectedHistoryFile?.to - } - ); + try { + return await requestAPI( + URLExt.join(path, 'log'), + 'POST', + { + history_count: count, + follow_path: this.selectedHistoryFile?.to + } + ); + } catch (error) { + return { code: 1 }; + } } ); }