From 2b570641b103a643feda419568039dd81f1df8c9 Mon Sep 17 00:00:00 2001 From: Arseniy Terekhin Date: Fri, 26 May 2023 19:12:12 +0300 Subject: [PATCH] feat: add tags and checkout in status bar tooltip --- README.md | 4 ++-- src/openedRepository.ts | 14 ++++++++++++++ src/statusbar.ts | 10 +++++++--- src/test/suite/test_commands.ts | 6 +++++- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 70f80c7..0f21604 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,9 @@ about cloning from the extension. Use "Fossil log" from command palette and navigate the options till specific checkout. -* **Get current checkout hash?** +* **Get current checkout hash or tags?** - Not possible yet using UI. + Hover over current branch name in the status bar * **Close/reopen a branch?** diff --git a/src/openedRepository.ts b/src/openedRepository.ts index 294e3c9..b255416 100644 --- a/src/openedRepository.ts +++ b/src/openedRepository.ts @@ -119,6 +119,8 @@ export interface FossilStatus { readonly statuses: FileStatus[]; readonly isMerge: boolean; readonly info: Map; + readonly tags: string[]; // not FossilTag for a reason + readonly checkout: { checkin: FossilCheckin; date: string }; } export interface BranchDetails { @@ -627,6 +629,16 @@ export class OpenedRepository { info.set(key, value); } } + const checkoutStr = info.get('checkout')!; + const spaceIdx = checkoutStr.indexOf(' '); + const checkout = { + checkin: checkoutStr.slice(0, spaceIdx) as FossilCheckin, + date: checkoutStr.slice(spaceIdx + 1), + }; + const tags = info + .get('tags')! + .split(',') + .map(t => t.trim()); const isMerge = info.has('CHERRYPICK') || info.has('BACKOUT') || @@ -636,6 +648,8 @@ export class OpenedRepository { statuses, isMerge, info, + checkout, + tags, }; } diff --git a/src/statusbar.ts b/src/statusbar.ts index 525d7f5..2c47814 100644 --- a/src/statusbar.ts +++ b/src/statusbar.ts @@ -25,7 +25,7 @@ class ScopeStatusBar { private disposables: Disposable[] = []; constructor(private repository: Repository) { - repository.onDidChange( + repository.onDidChangeStatus( this._onDidChange.fire, this._onDidChange, this.disposables @@ -43,10 +43,14 @@ class ScopeStatusBar { ' ' + currentBranch + (this.repository.workingGroup.resourceStates.length ? '+' : ''); - return { command: 'fossil.branchChange', - tooltip: localize('branch change', 'Change Branch...'), + tooltip: localize( + 'branch change {0} {1}', + '\n{0}\nTags:\n \u2022 {1}\nChange Branch...', + fossilStatus?.checkout.checkin, + fossilStatus?.tags.join('\n \u2022 ') + ), title, arguments: [this.repository], }; diff --git a/src/test/suite/test_commands.ts b/src/test/suite/test_commands.ts index bad11fb..b957e2b 100644 --- a/src/test/suite/test_commands.ts +++ b/src/test/suite/test_commands.ts @@ -232,11 +232,15 @@ function fakeFossilStatus( execStub: T, status: string ) { + const header = + 'checkout: 0000000000000000000000000000000000000000 2023-05-26 12:43:56 UTC\n' + + 'parent: 0000000000000000000000000000000000000001 2023-05-26 12:43:56 UTC\n' + + 'tags: trunk, this is a test, custom tag\n'; const args = ['status', '--differ', '--merge'] as const; return execStub.withArgs(args).resolves({ fossilPath: '', exitCode: 0, - stdout: status, // fake_status.join('\n'), + stdout: header + status, // fake_status.join('\n'), stderr: '', args: args, cwd: '',