Browse Source

Simplifies format logging

main
Eric Amodio 2 years ago
parent
commit
15f5830735
5 changed files with 13 additions and 21 deletions
  1. +2
    -6
      src/git/models/branch.ts
  2. +4
    -8
      src/git/models/commit.ts
  3. +4
    -4
      src/git/models/pullRequest.ts
  4. +1
    -1
      src/git/models/reflog.ts
  5. +2
    -2
      src/git/models/tag.ts

+ 2
- 6
src/git/models/branch.ts View File

@ -155,13 +155,9 @@ export class GitBranch implements GitBranchReference {
return this.detached ? this.sha! : this.name;
}
@memoize<GitBranch['formatDate']>(format => (format == null ? 'MMMM Do, YYYY h:mma' : format))
@memoize<GitBranch['formatDate']>(format => format ?? 'MMMM Do, YYYY h:mma')
formatDate(format?: string | null): string {
if (format == null) {
format = 'MMMM Do, YYYY h:mma';
}
return this.date != null ? formatDate(this.date, format) : '';
return this.date != null ? formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma') : '';
}
formatDateFromNow(): string {

+ 4
- 8
src/git/models/commit.ts View File

@ -483,16 +483,12 @@ export class GitCommitIdentity {
private readonly avatarUrl?: string | undefined,
) {}
@memoize<GitCommitIdentity['formatDate']>(format => (format == null ? 'MMMM Do, YYYY h:mma' : format))
formatDate(format?: string | null) {
if (format == null) {
format = 'MMMM Do, YYYY h:mma';
}
return formatDate(this.date, format);
@memoize<GitCommitIdentity['formatDate']>(format => format ?? 'MMMM Do, YYYY h:mma')
formatDate(format?: string | null): string {
return formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma');
}
fromNow(short?: boolean) {
fromNow(short?: boolean): string {
return fromNow(this.date, short);
}

+ 4
- 4
src/git/models/pullRequest.ts View File

@ -80,7 +80,7 @@ export class PullRequest {
: this.formatDateFromNow();
}
@memoize<PullRequest['formatDate']>(format => (format == null ? 'MMMM Do, YYYY h:mma' : format))
@memoize<PullRequest['formatDate']>(format => format ?? 'MMMM Do, YYYY h:mma')
formatDate(format?: string | null) {
return formatDate(this.mergedDate ?? this.closedDate ?? this.date, format ?? 'MMMM Do, YYYY h:mma');
}
@ -89,7 +89,7 @@ export class PullRequest {
return fromNow(this.mergedDate ?? this.closedDate ?? this.date);
}
@memoize<PullRequest['formatClosedDate']>(format => (format == null ? 'MMMM Do, YYYY h:mma' : format))
@memoize<PullRequest['formatClosedDate']>(format => format ?? 'MMMM Do, YYYY h:mma')
formatClosedDate(format?: string | null) {
if (this.closedDate == null) return '';
return formatDate(this.closedDate, format ?? 'MMMM Do, YYYY h:mma');
@ -100,7 +100,7 @@ export class PullRequest {
return fromNow(this.closedDate);
}
@memoize<PullRequest['formatMergedDate']>(format => (format == null ? 'MMMM Do, YYYY h:mma' : format))
@memoize<PullRequest['formatMergedDate']>(format => format ?? 'MMMM Do, YYYY h:mma')
formatMergedDate(format?: string | null) {
if (this.mergedDate == null) return '';
return formatDate(this.mergedDate, format ?? 'MMMM Do, YYYY h:mma') ?? '';
@ -111,7 +111,7 @@ export class PullRequest {
return fromNow(this.mergedDate);
}
@memoize<PullRequest['formatUpdatedDate']>(format => (format == null ? 'MMMM Do, YYYY h:mma' : format))
@memoize<PullRequest['formatUpdatedDate']>(format => format ?? 'MMMM Do, YYYY h:mma')
formatUpdatedDate(format?: string | null) {
return formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma') ?? '';
}

+ 1
- 1
src/git/models/reflog.ts View File

@ -28,7 +28,7 @@ export class GitReflogRecord {
public readonly details: string | undefined,
) {}
@memoize<GitReflogRecord['formatDate']>(format => (format == null ? 'MMMM Do, YYYY h:mma' : format))
@memoize<GitReflogRecord['formatDate']>(format => format ?? 'MMMM Do, YYYY h:mma')
formatDate(format?: string | null) {
return formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma');
}

+ 2
- 2
src/git/models/tag.ts View File

@ -65,7 +65,7 @@ export class GitTag implements GitTagReference {
return this.name;
}
@memoize<GitTag['formatCommitDate']>(format => (format == null ? 'MMMM Do, YYYY h:mma' : format))
@memoize<GitTag['formatCommitDate']>(format => format ?? 'MMMM Do, YYYY h:mma')
formatCommitDate(format?: string | null) {
return this.commitDate != null ? formatDate(this.commitDate, format ?? 'MMMM Do, YYYY h:mma') : '';
}
@ -74,7 +74,7 @@ export class GitTag implements GitTagReference {
return this.commitDate != null ? fromNow(this.commitDate) : '';
}
@memoize<GitTag['formatDate']>(format => (format == null ? 'MMMM Do, YYYY h:mma' : format))
@memoize<GitTag['formatDate']>(format => format ?? 'MMMM Do, YYYY h:mma')
formatDate(format?: string | null) {
return formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma');
}

Loading…
Cancel
Save