Skip to content

Commit

Permalink
Use strict-equals (Fixes #265) (#266)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sebastianrath authored Mar 12, 2022
1 parent 58ac16f commit aa77eac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand All @@ -85,10 +84,6 @@ export class Commit {
return;
}

if (this.tags == null) {
this.tags = [];
}

if (this.tags.includes(tag)) {
return;
}
Expand Down
8 changes: 8 additions & 0 deletions src/odb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class Reference {
});

ref.userData = {};
if (this.userData != null) {
if (this.userData !== null) {
ref.userData = { ...this.userData };
}

Expand Down

0 comments on commit aa77eac

Please sign in to comment.