Browse Source

Passes the container to commits

Moves formatting globals to the container
main
Eric Amodio 2 years ago
parent
commit
1a1540a202
20 changed files with 160 additions and 111 deletions
  1. +1
    -0
      src/annotations/gutterChangesAnnotationProvider.ts
  2. +53
    -0
      src/container.ts
  3. +8
    -5
      src/env/node/git/localGitProvider.ts
  4. +8
    -12
      src/git/gitProviderService.ts
  5. +2
    -12
      src/git/models/branch.ts
  6. +19
    -36
      src/git/models/commit.ts
  7. +4
    -13
      src/git/models/pullRequest.ts
  8. +3
    -3
      src/git/models/reflog.ts
  9. +5
    -1
      src/git/models/status.ts
  10. +3
    -12
      src/git/models/tag.ts
  11. +10
    -2
      src/git/parsers/blameParser.ts
  12. +14
    -1
      src/git/parsers/logParser.ts
  13. +10
    -3
      src/git/parsers/stashParser.ts
  14. +5
    -0
      src/premium/github/githubGitProvider.ts
  15. +2
    -2
      src/views/nodes/branchNode.ts
  16. +2
    -2
      src/views/nodes/fileHistoryNode.ts
  17. +1
    -1
      src/views/nodes/lineHistoryNode.ts
  18. +1
    -1
      src/views/nodes/statusFilesNode.ts
  19. +8
    -5
      src/views/nodes/tagNode.ts
  20. +1
    -0
      src/webviews/webviewBase.ts

+ 1
- 0
src/annotations/gutterChangesAnnotationProvider.ts View File

@ -104,6 +104,7 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase
this.trackedDocument.uri.fsPath,
);
const commits = status?.getPseudoCommits(
this.container,
await this.container.git.getCurrentUser(this.trackedDocument.uri.repoPath!),
);
if (commits?.length) {

+ 53
- 0
src/container.ts View File

@ -12,6 +12,8 @@ import {
Config,
configuration,
ConfigurationWillChangeEvent,
DateSource,
DateStyle,
FileAnnotationType,
} from './configuration';
import { GitFileSystemProvider } from './git/fsProvider';
@ -73,6 +75,57 @@ export class Container {
return this._onReady.event;
}
readonly BranchDateFormatting = {
dateFormat: undefined! as string | null,
dateStyle: undefined! as DateStyle,
reset: () => {
this.BranchDateFormatting.dateFormat = configuration.get('defaultDateFormat');
this.BranchDateFormatting.dateStyle = configuration.get('defaultDateStyle');
},
};
readonly CommitDateFormatting = {
dateFormat: null as string | null,
dateSource: DateSource.Authored,
dateStyle: DateStyle.Relative,
reset: () => {
this.CommitDateFormatting.dateFormat = configuration.get('defaultDateFormat');
this.CommitDateFormatting.dateSource = configuration.get('defaultDateSource');
this.CommitDateFormatting.dateStyle = configuration.get('defaultDateStyle');
},
};
readonly CommitShaFormatting = {
length: 7,
reset: () => {
// Don't allow shas to be shortened to less than 5 characters
this.CommitShaFormatting.length = Math.max(5, configuration.get('advanced.abbreviatedShaLength'));
},
};
readonly PullRequestDateFormatting = {
dateFormat: null as string | null,
dateStyle: DateStyle.Relative,
reset: () => {
this.PullRequestDateFormatting.dateFormat = configuration.get('defaultDateFormat');
this.PullRequestDateFormatting.dateStyle = configuration.get('defaultDateStyle');
},
};
readonly TagDateFormatting = {
dateFormat: null as string | null,
dateStyle: DateStyle.Relative,
reset: () => {
this.TagDateFormatting.dateFormat = configuration.get('defaultDateFormat');
this.TagDateFormatting.dateStyle = configuration.get('defaultDateStyle');
},
};
private _configsAffectedByMode: string[] | undefined;
private _applyModeConfigurationTransformBound:
| ((e: ConfigurationChangeEvent) => ConfigurationChangeEvent)

+ 8
- 5
src/env/node/git/localGitProvider.ts View File

@ -953,7 +953,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
args: this.container.config.advanced.blame.customArguments,
ignoreWhitespace: this.container.config.blame.ignoreWhitespace,
});
const blame = GitBlameParser.parse(data, root, await this.getCurrentUser(root));
const blame = GitBlameParser.parse(this.container, data, root, await this.getCurrentUser(root));
return blame;
} catch (ex) {
// Trap and cache expected blame errors
@ -1034,7 +1034,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
correlationKey: `:${key}`,
ignoreWhitespace: this.container.config.blame.ignoreWhitespace,
});
const blame = GitBlameParser.parse(data, root, await this.getCurrentUser(root));
const blame = GitBlameParser.parse(this.container, data, root, await this.getCurrentUser(root));
return blame;
} catch (ex) {
// Trap and cache expected blame errors
@ -1094,7 +1094,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
startLine: lineToBlame,
endLine: lineToBlame,
});
const blame = GitBlameParser.parse(data, root, await this.getCurrentUser(root));
const blame = GitBlameParser.parse(this.container, data, root, await this.getCurrentUser(root));
if (blame == null) return undefined;
return {
@ -1145,7 +1145,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
startLine: lineToBlame,
endLine: lineToBlame,
});
const blame = GitBlameParser.parse(data, root, await this.getCurrentUser(root));
const blame = GitBlameParser.parse(this.container, data, root, await this.getCurrentUser(root));
if (blame == null) return undefined;
return {
@ -1946,6 +1946,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
// }
const log = GitLogParser.parse(
this.container,
data,
LogType.Log,
repoPath,
@ -2166,6 +2167,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
useShow: useShow,
});
const log = GitLogParser.parse(
this.container,
data,
LogType.Log,
repoPath,
@ -2418,6 +2420,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
endLine: range == null ? undefined : range.end.line + 1,
});
const log = GitLogParser.parse(
this.container,
data,
// If this is the log of a folder, parse it as a normal log rather than a file log
isFolderGlob(file) ? LogType.Log : LogType.LogFile,
@ -3109,7 +3112,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const data = await this.git.stash__list(repoPath, {
similarityThreshold: this.container.config.advanced.similarityThreshold,
});
stash = GitStashParser.parse(data, repoPath);
stash = GitStashParser.parse(this.container, data, repoPath);
if (this.useCaching) {
this._stashesCache.set(repoPath, stash ?? null);

+ 8
- 12
src/git/gitProviderService.ts View File

@ -31,10 +31,7 @@ import { VisitedPathsTrie } from '../system/trie';
import { GitProvider, GitProviderDescriptor, GitProviderId, PagedResult, ScmRepository } from './gitProvider';
import { GitUri } from './gitUri';
import {
BranchDateFormatting,
BranchSortOptions,
CommitDateFormatting,
CommitShaFormatting,
GitBlame,
GitBlameLine,
GitBlameLines,
@ -61,7 +58,6 @@ import {
GitTreeEntry,
GitUser,
PullRequest,
PullRequestDateFormatting,
PullRequestState,
Repository,
RepositoryChange,
@ -147,10 +143,10 @@ export class GitProviderService implements Disposable {
}),
);
BranchDateFormatting.reset();
CommitDateFormatting.reset();
CommitShaFormatting.reset();
PullRequestDateFormatting.reset();
this.container.BranchDateFormatting.reset();
this.container.CommitDateFormatting.reset();
this.container.CommitShaFormatting.reset();
this.container.PullRequestDateFormatting.reset();
this.updateContext();
}
@ -174,13 +170,13 @@ export class GitProviderService implements Disposable {
configuration.changed(e, 'defaultDateSource') ||
configuration.changed(e, 'defaultDateStyle')
) {
BranchDateFormatting.reset();
CommitDateFormatting.reset();
PullRequestDateFormatting.reset();
this.container.BranchDateFormatting.reset();
this.container.CommitDateFormatting.reset();
this.container.PullRequestDateFormatting.reset();
}
if (configuration.changed(e, 'advanced.abbreviatedShaLength')) {
CommitShaFormatting.reset();
this.container.CommitShaFormatting.reset();
}
if (configuration.changed(e, 'views.contributors.showAllBranches')) {

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

@ -13,16 +13,6 @@ import { GitStatus } from './status';
const whitespaceRegex = /\s/;
const detachedHEADRegex = /^(?=.*\bHEAD\b)?(?=.*\bdetached\b).*$/;
export const BranchDateFormatting = {
dateFormat: undefined! as string | null,
dateStyle: undefined! as DateStyle,
reset: () => {
BranchDateFormatting.dateFormat = configuration.get('defaultDateFormat');
BranchDateFormatting.dateStyle = configuration.get('defaultDateStyle');
},
};
export interface GitTrackingState {
ahead: number;
behind: number;
@ -146,8 +136,8 @@ export class GitBranch implements GitBranchReference {
}
get formattedDate(): string {
return BranchDateFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(BranchDateFormatting.dateFormat)
return Container.instance.BranchDateFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(Container.instance.BranchDateFormatting.dateFormat)
: this.formatDateFromNow();
}

+ 19
- 36
src/git/models/commit.ts View File

@ -1,6 +1,6 @@
import { Uri } from 'vscode';
import { getAvatarUri } from '../../avatars';
import { configuration, DateSource, DateStyle, GravatarDefaultStyle } from '../../configuration';
import { DateSource, DateStyle, GravatarDefaultStyle } from '../../configuration';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { formatDate, fromNow } from '../../system/date';
@ -15,27 +15,6 @@ import { GitReference, GitRevision, GitRevisionReference, GitStashReference } fr
const stashNumberRegex = /stash@{(\d+)}/;
export const CommitDateFormatting = {
dateFormat: null as string | null,
dateSource: DateSource.Authored,
dateStyle: DateStyle.Relative,
reset: () => {
CommitDateFormatting.dateFormat = configuration.get('defaultDateFormat');
CommitDateFormatting.dateSource = configuration.get('defaultDateSource');
CommitDateFormatting.dateStyle = configuration.get('defaultDateStyle');
},
};
export const CommitShaFormatting = {
length: 7,
reset: () => {
// Don't allow shas to be shortened to less than 5 characters
CommitShaFormatting.length = Math.max(5, Container.instance.config.advanced.abbreviatedShaLength);
},
};
export class GitCommit implements GitRevisionReference {
static is(commit: any): commit is GitCommit {
return commit instanceof GitCommit;
@ -70,6 +49,7 @@ export class GitCommit implements GitRevisionReference {
readonly number: string | undefined;
constructor(
private readonly container: Container,
public readonly repoPath: string,
public readonly sha: string,
public readonly author: GitCommitIdentity,
@ -84,7 +64,7 @@ export class GitCommit implements GitRevisionReference {
) {
this.ref = this.sha;
this.refType = stashName ? 'stash' : 'revision';
this.shortSha = this.sha.substring(0, CommitShaFormatting.length);
this.shortSha = this.sha.substring(0, this.container.CommitShaFormatting.length);
// Add an ellipsis to the summary if there is or might be more message
if (message != null) {
@ -141,7 +121,9 @@ export class GitCommit implements GitRevisionReference {
}
get date(): Date {
return CommitDateFormatting.dateSource === DateSource.Committed ? this.committer.date : this.author.date;
return this.container.CommitDateFormatting.dateSource === DateSource.Committed
? this.committer.date
: this.author.date;
}
private _file: GitFileChange | undefined;
@ -155,8 +137,8 @@ export class GitCommit implements GitRevisionReference {
}
get formattedDate(): string {
return CommitDateFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(CommitDateFormatting.dateFormat)
return this.container.CommitDateFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(this.container.CommitDateFormatting.dateFormat)
: this.formatDateFromNow();
}
@ -202,10 +184,10 @@ export class GitCommit implements GitRevisionReference {
if (this.isUncommitted || GitCommit.hasFullDetails(this)) return;
const [commitResult, untrackedResult] = await Promise.allSettled([
Container.instance.git.getCommit(this.repoPath, this.sha),
this.container.git.getCommit(this.repoPath, this.sha),
// Check for any untracked files -- since git doesn't return them via `git stash list` :(
// See https://stackoverflow.com/questions/12681529/
this.stashName ? Container.instance.git.getCommit(this.repoPath, `${this.stashName}^3`) : undefined,
this.stashName ? this.container.git.getCommit(this.repoPath, `${this.stashName}^3`) : undefined,
]);
if (commitResult.status !== 'fulfilled' || commitResult.value == null) return;
@ -285,18 +267,18 @@ export class GitCommit implements GitRevisionReference {
if (this._files == null) return undefined;
}
path = Container.instance.git.getRelativePath(path, this.repoPath);
path = this.container.git.getRelativePath(path, this.repoPath);
return this._files.find(f => f.path === path);
}
formatDate(format?: string | null) {
return CommitDateFormatting.dateSource === DateSource.Committed
return this.container.CommitDateFormatting.dateSource === DateSource.Committed
? this.committer.formatDate(format)
: this.author.formatDate(format);
}
formatDateFromNow(short?: boolean) {
return CommitDateFormatting.dateSource === DateSource.Committed
return this.container.CommitDateFormatting.dateSource === DateSource.Committed
? this.committer.fromNow(short)
: this.author.fromNow(short);
}
@ -377,10 +359,10 @@ export class GitCommit implements GitRevisionReference {
async getAssociatedPullRequest(options?: { timeout?: number }): Promise<PullRequest | undefined> {
if (this._pullRequest == null) {
async function getCore(this: GitCommit): Promise<PullRequest | undefined> {
const remote = await Container.instance.git.getRichRemoteProvider(this.repoPath);
const remote = await this.container.git.getRichRemoteProvider(this.repoPath);
if (remote?.provider == null) return undefined;
return Container.instance.git.getPullRequestForCommit(this.ref, remote, options);
return this.container.git.getPullRequestForCommit(this.ref, remote, options);
}
this._pullRequest = getCore.call(this);
}
@ -393,7 +375,7 @@ export class GitCommit implements GitRevisionReference {
}
async getCommitForFile(file: string | GitFile): Promise<GitCommit | undefined> {
const path = typeof file === 'string' ? Container.instance.git.getRelativePath(file, this.repoPath) : file.path;
const path = typeof file === 'string' ? this.container.git.getRelativePath(file, this.repoPath) : file.path;
const foundFile = await this.findFile(path);
if (foundFile == null) return undefined;
@ -413,7 +395,7 @@ export class GitCommit implements GitRevisionReference {
@memoize()
getGitUri(previous: boolean = false): GitUri {
const uri = this._file?.uri ?? Container.instance.git.getAbsoluteUri(this.repoPath, this.repoPath);
const uri = this._file?.uri ?? this.container.git.getAbsoluteUri(this.repoPath, this.repoPath);
if (!previous) return new GitUri(uri, this);
return new GitUri(this._file?.previousUri ?? uri, {
@ -425,7 +407,7 @@ export class GitCommit implements GitRevisionReference {
@memoize<GitCommit['getPreviousLineDiffUris']>((u, e, r) => `${u.toString()}|${e}|${r ?? ''}`)
getPreviousLineDiffUris(uri: Uri, editorLine: number, ref: string | undefined) {
return this.file?.path
? Container.instance.git.getPreviousLineDiffUris(this.repoPath, uri, editorLine, ref)
? this.container.git.getPreviousLineDiffUris(this.repoPath, uri, editorLine, ref)
: Promise.resolve(undefined);
}
@ -455,6 +437,7 @@ export class GitCommit implements GitRevisionReference {
}
return new GitCommit(
this.container,
this.repoPath,
changes.sha ?? this.sha,
this.author,

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

@ -1,20 +1,11 @@
import { ColorThemeKind, ThemeColor, ThemeIcon, window } from 'vscode';
import { configuration, DateStyle } from '../../configuration';
import { DateStyle } from '../../configuration';
import { Colors } from '../../constants';
import { Container } from '../../container';
import { formatDate, fromNow } from '../../system/date';
import { memoize } from '../../system/decorators/memoize';
import { RemoteProviderReference } from './remoteProvider';
export const PullRequestDateFormatting = {
dateFormat: undefined! as string | null,
dateStyle: undefined! as DateStyle,
reset: () => {
PullRequestDateFormatting.dateFormat = configuration.get('defaultDateFormat');
PullRequestDateFormatting.dateStyle = configuration.get('defaultDateStyle');
},
};
export const enum PullRequestState {
Open = 'Open',
Closed = 'Closed',
@ -75,8 +66,8 @@ export class PullRequest {
) {}
get formattedDate(): string {
return PullRequestDateFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(PullRequestDateFormatting.dateFormat)
return Container.instance.PullRequestDateFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(Container.instance.PullRequestDateFormatting.dateFormat)
: this.formatDateFromNow();
}

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

@ -1,7 +1,7 @@
import { DateStyle } from '../../config';
import { Container } from '../../container';
import { formatDate, fromNow } from '../../system/date';
import { memoize } from '../../system/decorators/memoize';
import { CommitDateFormatting } from './commit';
import { GitRevision } from './reference';
export interface GitReflog {
@ -38,8 +38,8 @@ export class GitReflogRecord {
}
get formattedDate(): string {
return CommitDateFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(CommitDateFormatting.dateFormat)
return Container.instance.CommitDateFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(Container.instance.CommitDateFormatting.dateFormat)
: this.formatDateFromNow();
}

+ 5
- 1
src/git/models/status.ts View File

@ -431,7 +431,7 @@ export class GitStatusFile implements GitFile {
return GitFile.getStatusText(this.status);
}
getPseudoCommits(user: GitUser | undefined): GitCommit[] {
getPseudoCommits(container: Container, user: GitUser | undefined): GitCommit[] {
const commits: GitCommit[] = [];
const now = new Date();
@ -439,6 +439,7 @@ export class GitStatusFile implements GitFile {
if (this.conflictStatus != null) {
commits.push(
new GitCommit(
container,
this.repoPath,
GitRevision.uncommitted,
new GitCommitIdentity('You', user?.email ?? undefined, now),
@ -469,6 +470,7 @@ export class GitStatusFile implements GitFile {
commits.push(
new GitCommit(
container,
this.repoPath,
GitRevision.uncommitted,
new GitCommitIdentity('You', user?.email ?? undefined, now),
@ -487,6 +489,7 @@ export class GitStatusFile implements GitFile {
[],
),
new GitCommit(
container,
this.repoPath,
GitRevision.uncommittedStaged,
new GitCommitIdentity('You', user?.email ?? undefined, older),
@ -502,6 +505,7 @@ export class GitStatusFile implements GitFile {
} else {
commits.push(
new GitCommit(
container,
this.repoPath,
this.workingTreeStatus != null ? GitRevision.uncommitted : GitRevision.uncommittedStaged,
new GitCommitIdentity('You', user?.email ?? undefined, now),

+ 3
- 12
src/git/models/tag.ts View File

@ -1,19 +1,10 @@
import { configuration, DateStyle, TagSorting } from '../../configuration';
import { Container } from '../../container';
import { formatDate, fromNow } from '../../system/date';
import { memoize } from '../../system/decorators/memoize';
import { sortCompare } from '../../system/string';
import { GitReference, GitTagReference } from './reference';
export const TagDateFormatting = {
dateFormat: undefined! as string | null,
dateStyle: undefined! as DateStyle,
reset: () => {
TagDateFormatting.dateFormat = configuration.get('defaultDateFormat');
TagDateFormatting.dateStyle = configuration.get('defaultDateStyle');
},
};
export interface TagSortOptions {
current?: boolean;
orderBy?: TagSorting;
@ -56,8 +47,8 @@ export class GitTag implements GitTagReference {
) {}
get formattedDate(): string {
return TagDateFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(TagDateFormatting.dateFormat)
return Container.instance.TagDateFormatting.dateStyle === DateStyle.Absolute
? this.formatDate(Container.instance.TagDateFormatting.dateFormat)
: this.formatDateFromNow();
}

+ 10
- 2
src/git/parsers/blameParser.ts View File

@ -1,3 +1,4 @@
import type { Container } from '../../container';
import { debug } from '../../system/decorators/log';
import { getLines } from '../../system/string';
import {
@ -39,7 +40,12 @@ interface BlameEntry {
export class GitBlameParser {
@debug({ args: false, singleLine: true })
static parse(data: string, repoPath: string, currentUser: GitUser | undefined): GitBlame | undefined {
static parse(
container: Container,
data: string,
repoPath: string,
currentUser: GitUser | undefined,
): GitBlame | undefined {
if (!data) return undefined;
const authors = new Map<string, GitBlameAuthor>();
@ -153,7 +159,7 @@ export class GitBlameParser {
entry.path = line.slice(key.length + 1);
// Since the filename marks the end of a commit, parse the entry and clear it for the next
GitBlameParser.parseEntry(entry, repoPath, commits, authors, lines, currentUser);
GitBlameParser.parseEntry(container, entry, repoPath, commits, authors, lines, currentUser);
entry = undefined;
break;
@ -184,6 +190,7 @@ export class GitBlameParser {
}
private static parseEntry(
container: Container,
entry: BlameEntry,
repoPath: string,
commits: Map<string, GitCommit>,
@ -217,6 +224,7 @@ export class GitBlameParser {
}
commit = new GitCommit(
container,
repoPath,
entry.sha,
new GitCommitIdentity(entry.author, entry.authorEmail, new Date((entry.authorDate as any) * 1000)),

+ 14
- 1
src/git/parsers/logParser.ts View File

@ -1,4 +1,5 @@
import { Range } from 'vscode';
import type { Container } from '../../container';
import { Arrays, debug } from '../../system';
import { normalizePath, relative } from '../../system/path';
import { getLines } from '../../system/string';
@ -270,6 +271,7 @@ export class GitLogParser {
@debug({ args: false })
static parse(
container: Container,
data: string,
type: LogType,
repoPath: string | undefined,
@ -550,7 +552,16 @@ export class GitLogParser {
truncationCount--;
}
GitLogParser.parseEntry(entry, commit, type, repoPath, relativeFileName, commits, currentUser);
GitLogParser.parseEntry(
container,
entry,
commit,
type,
repoPath,
relativeFileName,
commits,
currentUser,
);
break;
}
@ -570,6 +581,7 @@ export class GitLogParser {
}
private static parseEntry(
container: Container,
entry: LogEntry,
commit: GitCommit | undefined,
type: LogType,
@ -608,6 +620,7 @@ export class GitLogParser {
}
commit = new GitCommit(
container,
repoPath!,
entry.sha!,
new GitCommitIdentity(entry.author!, entry.authorEmail, new Date((entry.authorDate! as any) * 1000)),

+ 10
- 3
src/git/parsers/stashParser.ts View File

@ -1,3 +1,4 @@
import type { Container } from '../../container';
import { filterMap } from '../../system/array';
import { debug } from '../../system/decorators/log';
import { normalizePath } from '../../system/path';
@ -44,7 +45,7 @@ export class GitStashParser {
].join('%n');
@debug({ args: false, singleLine: true })
static parse(data: string, repoPath: string): GitStash | undefined {
static parse(container: Container, data: string, repoPath: string): GitStash | undefined {
if (!data) return undefined;
const lines = getLines(`${data}</f>`);
@ -155,7 +156,7 @@ export class GitStashParser {
}
}
GitStashParser.parseEntry(entry, repoPath, commits);
GitStashParser.parseEntry(container, entry, repoPath, commits);
entry = {};
}
}
@ -167,10 +168,16 @@ export class GitStashParser {
return stash;
}
private static parseEntry(entry: StashEntry, repoPath: string, commits: Map<string, GitStashCommit>) {
private static parseEntry(
container: Container,
entry: StashEntry,
repoPath: string,
commits: Map<string, GitStashCommit>,
) {
let commit = commits.get(entry.ref!);
if (commit == null) {
commit = new GitCommit(
container,
repoPath,
entry.ref!,
new GitCommitIdentity('You', undefined, new Date((entry.date! as any) * 1000)),

+ 5
- 0
src/premium/github/githubGitProvider.ts View File

@ -419,6 +419,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
let commit = commits.get(c.oid);
if (commit == null) {
commit = new GitCommit(
this.container,
uri.repoPath!,
c.oid,
new GitCommitIdentity(authorName, c.author.email, new Date(c.author.date), c.author.avatarUrl),
@ -716,6 +717,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
const committerName = viewer != null && commit.committer.name === viewer ? 'You' : commit.committer.name;
return new GitCommit(
this.container,
repoPath,
commit.oid,
new GitCommitIdentity(
@ -861,6 +863,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
const foundFile = files?.find(f => f.path === file);
return new GitCommit(
this.container,
repoPath,
commit.oid,
new GitCommitIdentity(
@ -1094,6 +1097,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
let c = commits.get(commit.oid);
if (c == null) {
c = new GitCommit(
this.container,
repoPath,
commit.oid,
new GitCommitIdentity(
@ -1488,6 +1492,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
new GitFileChange(repoPath, file, GitFileIndexStatus.Modified);
c = new GitCommit(
this.container,
repoPath,
commit.oid,
new GitCommitIdentity(

+ 2
- 2
src/views/nodes/branchNode.ts View File

@ -1,9 +1,9 @@
import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, window } from 'vscode';
import { ViewBranchesLayout, ViewShowBranchComparison } from '../../configuration';
import { Colors, GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitUri } from '../../git/gitUri';
import {
BranchDateFormatting,
GitBranch,
GitBranchReference,
GitLog,
@ -413,7 +413,7 @@ export class BranchNode
}`;
tooltip += `\n\nLast commit ${this.branch.formatDateFromNow()} (${this.branch.formatDate(
BranchDateFormatting.dateFormat,
Container.instance.BranchDateFormatting.dateFormat,
)})`;
}

+ 2
- 2
src/views/nodes/fileHistoryNode.ts View File

@ -81,7 +81,7 @@ export class FileHistoryNode extends SubscribeableViewNode impl
// Combine all the working/staged changes into single pseudo commits
const commits = map(
uniqueBy(
flatMap(fileStatuses, f => f.getPseudoCommits(currentUser)),
flatMap(fileStatuses, f => f.getPseudoCommits(this.view.container, currentUser)),
c => c.sha,
(original, c) => original.with({ files: { files: [...original.files!, ...c.files!] } }),
),
@ -90,7 +90,7 @@ export class FileHistoryNode extends SubscribeableViewNode impl
children.push(...commits);
} else {
const [file] = fileStatuses;
const commits = file.getPseudoCommits(currentUser);
const commits = file.getPseudoCommits(this.view.container, currentUser);
if (commits.length) {
children.push(
...commits.map(commit => new FileRevisionAsCommitNode(this.view, this, file, commit)),

+ 1
- 1
src/views/nodes/lineHistoryNode.ts View File

@ -116,7 +116,7 @@ export class LineHistoryNode
};
const currentUser = await this.view.container.git.getCurrentUser(this.uri.repoPath!);
const pseudoCommits = status?.getPseudoCommits(currentUser);
const pseudoCommits = status?.getPseudoCommits(this.view.container, currentUser);
if (pseudoCommits != null) {
for (const commit of pseudoCommits.reverse()) {
children.splice(

+ 1
- 1
src/views/nodes/statusFilesNode.ts View File

@ -71,7 +71,7 @@ export class StatusFilesNode extends ViewNode {
0,
0,
...flatMap(this.status.files, f =>
map(f.getPseudoCommits(undefined), c => this.getFileWithPseudoCommit(f, c)),
map(f.getPseudoCommits(this.view.container, undefined), c => this.getFileWithPseudoCommit(f, c)),
),
);
}

+ 8
- 5
src/views/nodes/tagNode.ts View File

@ -1,9 +1,10 @@
import { TreeItem, TreeItemCollapsibleState, window } from 'vscode';
import { ViewBranchesLayout } from '../../configuration';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { emojify } from '../../emojis';
import { GitUri } from '../../git/gitUri';
import { GitLog, GitRevision, GitTag, GitTagReference, TagDateFormatting } from '../../git/models';
import { GitLog, GitRevision, GitTag, GitTagReference } from '../../git/models';
import { debug, gate, Iterables, Strings } from '../../system';
import { RepositoriesView } from '../repositoriesView';
import { TagsView } from '../tagsView';
@ -74,11 +75,13 @@ export class TagNode extends ViewRefNode
item.description = emojify(this.tag.message);
item.tooltip = `${this.tag.name}${Strings.pad(GlyphChars.Dash, 2, 2)}${GitRevision.shorten(this.tag.sha, {
force: true,
})}\n${this.tag.formatDateFromNow()} (${this.tag.formatDate(TagDateFormatting.dateFormat)})\n\n${emojify(
this.tag.message,
)}${
})}\n${this.tag.formatDateFromNow()} (${this.tag.formatDate(
Container.instance.TagDateFormatting.dateFormat,
)})\n\n${emojify(this.tag.message)}${
this.tag.commitDate != null && this.tag.date !== this.tag.commitDate
? `\n${this.tag.formatCommitDateFromNow()} (${this.tag.formatCommitDate(TagDateFormatting.dateFormat)})`
? `\n${this.tag.formatCommitDateFromNow()} (${this.tag.formatCommitDate(
Container.instance.TagDateFormatting.dateFormat,
)})`
: ''
}`;

+ 1
- 0
src/webviews/webviewBase.ts View File

@ -203,6 +203,7 @@ export abstract class WebviewBase implements Disposable {
switch (params.type) {
case 'commit': {
const commit = new GitCommit(
this.container,
'~/code/eamodio/vscode-gitlens-demo',
'fe26af408293cba5b4bfd77306e1ac9ff7ccaef8',
new GitCommitIdentity('You', 'eamodio@gmail.com', new Date('2016-11-12T20:41:00.000Z')),

Loading…
Cancel
Save