|
|
@ -9,7 +9,7 @@ import { |
|
|
|
window, |
|
|
|
} from 'vscode'; |
|
|
|
import { CommitsViewConfig, configuration, ViewFilesLayout } from '../configuration'; |
|
|
|
import { GlyphChars } from '../constants'; |
|
|
|
import { CommandContext, GlyphChars, setCommandContext } from '../constants'; |
|
|
|
import { Container } from '../container'; |
|
|
|
import { |
|
|
|
GitLogCommit, |
|
|
@ -55,11 +55,20 @@ export class CommitsRepositoryNode extends SubscribeableViewNode { |
|
|
|
const branch = await this.repo.getBranch(); |
|
|
|
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 = [ |
|
|
|
new BranchNode(this.uri, this.view, this, branch, true, { |
|
|
|
expanded: true, |
|
|
|
showCurrent: false, |
|
|
|
showTracking: true, |
|
|
|
authors: authors, |
|
|
|
}), |
|
|
|
]; |
|
|
|
|
|
|
@ -205,6 +214,10 @@ export class CommitsViewNode extends ViewNode { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
interface CommitsViewState { |
|
|
|
myCommitsOnly?: boolean; |
|
|
|
} |
|
|
|
|
|
|
|
export class CommitsView extends ViewBase<CommitsViewNode, CommitsViewConfig> { |
|
|
|
protected readonly configKey = 'commits'; |
|
|
|
|
|
|
@ -212,6 +225,11 @@ export class CommitsView extends ViewBase { |
|
|
|
super('gitlens.views.commits', 'Commits'); |
|
|
|
} |
|
|
|
|
|
|
|
private readonly _state: CommitsViewState = {}; |
|
|
|
get state(): CommitsViewState { |
|
|
|
return this._state; |
|
|
|
} |
|
|
|
|
|
|
|
getRoot() { |
|
|
|
return new CommitsViewNode(this); |
|
|
|
} |
|
|
@ -240,6 +258,16 @@ export class CommitsView extends ViewBase { |
|
|
|
() => this.setFilesLayout(ViewFilesLayout.Tree), |
|
|
|
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('setShowAvatarsOff'), () => this.setShowAvatars(false), this); |
|
|
|
} |
|
|
@ -338,4 +366,10 @@ export class CommitsView extends ViewBase { |
|
|
|
private setShowAvatars(enabled: boolean) { |
|
|
|
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); |
|
|
|
} |
|
|
|
} |