Skip to content

Commit 8eb902a

Browse files
authored
Re-add support for revision hash or local/editing keyword as dependency description (#1667)
Re-add support for revision hash or local/editing keyword as dependency description
1 parent b50b447 commit 8eb902a

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Fix test explorer tests not updating on document modification ([#1663](https://github.com/swiftlang/vscode-swift/pull/1663))
88
- Fix improper parenting of tests w/ identical names in explorer ([#1664](https://github.com/swiftlang/vscode-swift/pull/1664))
99
- Ensure document symbols are provided for folders in multi-root workspaces ([#1668](https://github.com/swiftlang/vscode-swift/pull/1668))
10+
- Re-add support for revision hash or local/editing keyword in project panel dependency descriptions ([#1667](https://github.com/swiftlang/vscode-swift/pull/1667))
1011

1112
## 2.6.1 - 2025-06-27
1213

src/SwiftPackage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface ResolvedDependency extends Dependency {
6161
type: string;
6262
path: string;
6363
location: string;
64+
revision?: string;
6465
}
6566

6667
/** Swift Package.resolved file */
@@ -409,6 +410,7 @@ export class SwiftPackage {
409410
: "",
410411
type: workspaceStateDep ? this.dependencyType(workspaceStateDep) : "",
411412
location: workspaceStateDep ? workspaceStateDep.packageRef.location : "",
413+
revision: workspaceStateDep?.state.checkoutState?.revision ?? "",
412414
};
413415
}
414416

src/ui/ProjectPanelProvider.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class PackageNode {
119119
) {
120120
this.id =
121121
(this.parentId ? `${this.parentId}->` : "") +
122-
`${this.name}-${this.dependency.version ?? ""}`;
122+
`${this.name}-${(this.dependency.version || this.dependency.revision?.substring(0, 7)) ?? ""}`;
123123
}
124124

125125
get name(): string {
@@ -141,7 +141,7 @@ export class PackageNode {
141141
toTreeItem(): vscode.TreeItem {
142142
const item = new vscode.TreeItem(this.name, vscode.TreeItemCollapsibleState.Collapsed);
143143
item.id = this.id;
144-
item.description = this.dependency.version;
144+
item.description = this.getDescription();
145145
item.iconPath = new vscode.ThemeIcon(this.icon());
146146
item.contextValue = this.dependency.type;
147147
item.accessibilityInformation = { label: `Package ${this.name}` };
@@ -176,6 +176,20 @@ export class PackageNode {
176176
// Show dependencies first, then files.
177177
return [...childNodes, ...files];
178178
}
179+
180+
getDescription(): string {
181+
switch (this.type) {
182+
case "local":
183+
return "local";
184+
case "editing":
185+
return "editing";
186+
default:
187+
return (
188+
// show the version if used, otherwise show the partial commit hash
189+
(this.dependency.version || this.dependency.revision?.substring(0, 7)) ?? ""
190+
);
191+
}
192+
}
179193
}
180194

181195
/**

0 commit comments

Comments
 (0)