From aa77eac19b4d059f5893aeebc29009ed48081cf9 Mon Sep 17 00:00:00 2001 From: Sebastian Rath <12844423+seb-mtl@users.noreply.github.com> Date: Sat, 12 Mar 2022 18:30:19 -0500 Subject: [PATCH] Use strict-equals (Fixes #265) (#266) * Use strict-equals (Fixes #265) * Use list since tags is always a list * tags assignment not needed since its already set in constructor * Ensure 'tags' is always a list * Remove redundant code --- src/commit.ts | 7 +------ src/odb.ts | 8 ++++++++ src/reference.ts | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/commit.ts b/src/commit.ts index 0c79a747..ff6f5a6e 100644 --- a/src/commit.ts +++ b/src/commit.ts @@ -57,8 +57,7 @@ export class Commit { this.parent ? [...this.parent] : []); commit.hash = this.hash; - commit.tags = []; - if (this.tags != null) { + if (this.tags.length > 0) { commit.tags = [...this.tags]; } @@ -85,10 +84,6 @@ export class Commit { return; } - if (this.tags == null) { - this.tags = []; - } - if (this.tags.includes(tag)) { return; } diff --git a/src/odb.ts b/src/odb.ts index 40774031..24f819d3 100644 --- a/src/odb.ts +++ b/src/odb.ts @@ -135,6 +135,14 @@ export class Odb { return commits.map((commit: any) => { const tmpCommit = commit; + if (!tmpCommit.tags) { + tmpCommit.tags = []; + } + + if (!tmpCommit.userData) { + tmpCommit.userData = {}; + } + tmpCommit.date = new Date(tmpCommit.date); // convert number from JSON into date object const c: Commit = Object.setPrototypeOf(tmpCommit, Commit.prototype); c.repo = this.repo; diff --git a/src/reference.ts b/src/reference.ts index 92f96a39..4cf87979 100644 --- a/src/reference.ts +++ b/src/reference.ts @@ -63,7 +63,7 @@ export class Reference { }); ref.userData = {}; - if (this.userData != null) { + if (this.userData !== null) { ref.userData = { ...this.userData }; }