|
@ -9,7 +9,7 @@ import { |
|
|
window, |
|
|
window, |
|
|
} from 'vscode'; |
|
|
} from 'vscode'; |
|
|
import { CommitsViewConfig, configuration, ViewFilesLayout } from '../configuration'; |
|
|
import { CommitsViewConfig, configuration, ViewFilesLayout } from '../configuration'; |
|
|
import { GlyphChars } from '../constants'; |
|
|
|
|
|
|
|
|
import { CommandContext, GlyphChars, setCommandContext } from '../constants'; |
|
|
import { Container } from '../container'; |
|
|
import { Container } from '../container'; |
|
|
import { |
|
|
import { |
|
|
GitLogCommit, |
|
|
GitLogCommit, |
|
@ -55,11 +55,20 @@ export class CommitsRepositoryNode extends SubscribeableViewNode { |
|
|
const branch = await this.repo.getBranch(); |
|
|
const branch = await this.repo.getBranch(); |
|
|
if (branch == null) return [new MessageNode(this.view, this, 'No commits could be found.')]; |
|
|
if (branch == null) return [new MessageNode(this.view, this, 'No commits could be found.')]; |
|
|
|
|
|
|
|
|
|
|
|
let authors; |
|
|
|
|
|
if (this.view.state.myCommitsOnly) { |
|
|
|
|
|
const user = await Container.git.getCurrentUser(this.repo.path); |
|
|
|
|
|
if (user != null) { |
|
|
|
|
|
authors = [`^${user.name} <${user.email}>$`]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.children = [ |
|
|
this.children = [ |
|
|
new BranchNode(this.uri, this.view, this, branch, true, { |
|
|
new BranchNode(this.uri, this.view, this, branch, true, { |
|
|
expanded: true, |
|
|
expanded: true, |
|
|
showCurrent: false, |
|
|
showCurrent: false, |
|
|
showTracking: true, |
|
|
showTracking: true, |
|
|
|
|
|
authors: authors, |
|
|
}), |
|
|
}), |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
@ -205,6 +214,10 @@ export class CommitsViewNode extends ViewNode { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface CommitsViewState { |
|
|
|
|
|
myCommitsOnly?: boolean; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export class CommitsView extends ViewBase<CommitsViewNode, CommitsViewConfig> { |
|
|
export class CommitsView extends ViewBase<CommitsViewNode, CommitsViewConfig> { |
|
|
protected readonly configKey = 'commits'; |
|
|
protected readonly configKey = 'commits'; |
|
|
|
|
|
|
|
@ -212,6 +225,11 @@ export class CommitsView extends ViewBase { |
|
|
super('gitlens.views.commits', 'Commits'); |
|
|
super('gitlens.views.commits', 'Commits'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private readonly _state: CommitsViewState = {}; |
|
|
|
|
|
get state(): CommitsViewState { |
|
|
|
|
|
return this._state; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
getRoot() { |
|
|
getRoot() { |
|
|
return new CommitsViewNode(this); |
|
|
return new CommitsViewNode(this); |
|
|
} |
|
|
} |
|
@ -240,6 +258,16 @@ export class CommitsView extends ViewBase { |
|
|
() => this.setFilesLayout(ViewFilesLayout.Tree), |
|
|
() => this.setFilesLayout(ViewFilesLayout.Tree), |
|
|
this, |
|
|
this, |
|
|
); |
|
|
); |
|
|
|
|
|
commands.registerCommand( |
|
|
|
|
|
this.getQualifiedCommand('setMyCommitsOnlyOn'), |
|
|
|
|
|
() => this.setMyCommitsOnly(true), |
|
|
|
|
|
this, |
|
|
|
|
|
); |
|
|
|
|
|
commands.registerCommand( |
|
|
|
|
|
this.getQualifiedCommand('setMyCommitsOnlyOff'), |
|
|
|
|
|
() => this.setMyCommitsOnly(false), |
|
|
|
|
|
this, |
|
|
|
|
|
); |
|
|
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this); |
|
|
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOn'), () => this.setShowAvatars(true), this); |
|
|
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this); |
|
|
commands.registerCommand(this.getQualifiedCommand('setShowAvatarsOff'), () => this.setShowAvatars(false), this); |
|
|
} |
|
|
} |
|
@ -338,4 +366,10 @@ export class CommitsView extends ViewBase { |
|
|
private setShowAvatars(enabled: boolean) { |
|
|
private setShowAvatars(enabled: boolean) { |
|
|
return configuration.updateEffective('views', this.configKey, 'avatars', enabled); |
|
|
return configuration.updateEffective('views', this.configKey, 'avatars', enabled); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private setMyCommitsOnly(enabled: boolean) { |
|
|
|
|
|
void setCommandContext(CommandContext.ViewsCommitsMyCommitsOnly, enabled); |
|
|
|
|
|
this.state.myCommitsOnly = enabled; |
|
|
|
|
|
void this.refresh(true); |
|
|
|
|
|
} |
|
|
} |
|
|
} |