提交 30f618d1 编写于 作者: K Krzysztof Cieslak

Show tag name instead of commit in GitStatusbar

上级 8911a6a6
...@@ -24,7 +24,7 @@ interface IState { ...@@ -24,7 +24,7 @@ interface IState {
isSyncing: boolean; isSyncing: boolean;
HEAD: IBranch; HEAD: IBranch;
remotes: IRemote[]; remotes: IRemote[];
ps1: string; label: string;
} }
const DisablementDelay = 500; const DisablementDelay = 500;
...@@ -73,7 +73,7 @@ export class GitStatusbarItem implements IStatusbarItem { ...@@ -73,7 +73,7 @@ export class GitStatusbarItem implements IStatusbarItem {
isSyncing: false, isSyncing: false,
HEAD: null, HEAD: null,
remotes: [], remotes: [],
ps1: '' label: ''
}; };
} }
...@@ -100,6 +100,9 @@ export class GitStatusbarItem implements IStatusbarItem { ...@@ -100,6 +100,9 @@ export class GitStatusbarItem implements IStatusbarItem {
private onGitServiceChange(): void { private onGitServiceChange(): void {
const model = this.gitService.getModel(); const model = this.gitService.getModel();
const ps1 = model.getPS1();
const tags = model.getRefs().filter(iref => iref.commit.substr(0,8) === ps1);
const name = tags.length > 0 ? tags[0].name : model.getPS1();
this.setState({ this.setState({
serviceState: this.gitService.getState(), serviceState: this.gitService.getState(),
...@@ -107,7 +110,7 @@ export class GitStatusbarItem implements IStatusbarItem { ...@@ -107,7 +110,7 @@ export class GitStatusbarItem implements IStatusbarItem {
isSyncing: this.gitService.getRunningOperations().some(op => op.id === ServiceOperations.SYNC), isSyncing: this.gitService.getRunningOperations().some(op => op.id === ServiceOperations.SYNC),
HEAD: model.getHEAD(), HEAD: model.getHEAD(),
remotes: model.getRemotes(), remotes: model.getRemotes(),
ps1: model.getPS1() label: name
}); });
} }
...@@ -136,14 +139,14 @@ export class GitStatusbarItem implements IStatusbarItem { ...@@ -136,14 +139,14 @@ export class GitStatusbarItem implements IStatusbarItem {
} }
if (!HEAD) { if (!HEAD) {
textContent = state.ps1; textContent = state.label;
} else if (!HEAD.name) { } else if (!HEAD.name) {
textContent = state.ps1; textContent = state.label;
className += ' headless'; className += ' headless';
} else if (!HEAD.commit || !HEAD.upstream || (!HEAD.ahead && !HEAD.behind)) { } else if (!HEAD.commit || !HEAD.upstream || (!HEAD.ahead && !HEAD.behind)) {
textContent = state.ps1; textContent = state.label;
} else { } else {
textContent = state.ps1; textContent = state.label;
aheadBehindLabel = strings.format('{0}↓ {1}↑', HEAD.behind, HEAD.ahead); aheadBehindLabel = strings.format('{0}↓ {1}↑', HEAD.behind, HEAD.ahead);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册