Skip to content

Commit

Permalink
feat: add tags and checkout in status bar tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
senyai committed May 26, 2023
1 parent dd8a54f commit 2b57064
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?**

Expand Down
14 changes: 14 additions & 0 deletions src/openedRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ export interface FossilStatus {
readonly statuses: FileStatus[];
readonly isMerge: boolean;
readonly info: Map<string, string>;
readonly tags: string[]; // not FossilTag for a reason
readonly checkout: { checkin: FossilCheckin; date: string };
}

export interface BranchDetails {
Expand Down Expand Up @@ -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') ||
Expand All @@ -636,6 +648,8 @@ export class OpenedRepository {
statuses,
isMerge,
info,
checkout,
tags,
};
}

Expand Down
10 changes: 7 additions & 3 deletions src/statusbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ScopeStatusBar {
private disposables: Disposable[] = [];

constructor(private repository: Repository) {
repository.onDidChange(
repository.onDidChangeStatus(
this._onDidChange.fire,
this._onDidChange,
this.disposables
Expand All @@ -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],
};
Expand Down
6 changes: 5 additions & 1 deletion src/test/suite/test_commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,15 @@ function fakeFossilStatus<T extends sinon.SinonStub>(
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: '',
Expand Down

0 comments on commit 2b57064

Please sign in to comment.