From dc510aa967bb9be5a10bdc53ec106f9968d407e1 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 24 Sep 2020 03:08:07 -0400 Subject: [PATCH] Removes duplication --- src/views/nodes/branchTrackingStatusNode.ts | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/views/nodes/branchTrackingStatusNode.ts b/src/views/nodes/branchTrackingStatusNode.ts index f05a2e2..69e4d54 100644 --- a/src/views/nodes/branchTrackingStatusNode.ts +++ b/src/views/nodes/branchTrackingStatusNode.ts @@ -64,10 +64,10 @@ export class BranchTrackingStatusNode extends ViewNode implement const log = await this.getLog(); if (log == null) return []; - let children; + let commits; if (this.upstreamType === 'ahead') { // Since the last commit when we are looking 'ahead' can have no previous (because of the range given) -- look it up - const commits = [...log.commits.values()]; + commits = [...log.commits.values()]; const commit = commits[commits.length - 1]; if (commit.previousSha == null) { const previousLog = await Container.git.getLog(this.uri.repoPath!, { limit: 2, ref: commit.sha }); @@ -75,24 +75,18 @@ export class BranchTrackingStatusNode extends ViewNode implement commits[commits.length - 1] = Iterables.first(previousLog.commits.values()); } } - - children = [ - ...insertDateMarkers( - Iterables.map(commits, c => new CommitNode(this.view, this, c, this.branch)), - this, - 1, - ), - ]; } else { - children = [ - ...insertDateMarkers( - Iterables.map(log.commits.values(), c => new CommitNode(this.view, this, c, this.branch)), - this, - 1, - ), - ]; + commits = log.commits.values(); } + const children = [ + ...insertDateMarkers( + Iterables.map(commits, c => new CommitNode(this.view, this, c, this.branch)), + this, + 1, + ), + ]; + if (log.hasMore) { children.push(new LoadMoreNode(this.view, this, children[children.length - 1])); }