Skip to content

Commit

Permalink
Merge pull request #81 from alefragnani/features/support-workspace-trust
Browse files Browse the repository at this point in the history
Add workspace trust support (limited) - Closes #66
  • Loading branch information
alefragnani committed Mar 19, 2022
2 parents 6b38d0b + 52b0b6f commit ad34fbb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"status",
"multi-root ready"
],
"capabilities": {
"untrustedWorkspaces": {
"supported": "limited",
"description": "Trust is required to be able to load settings from .jenkinsrc.js files."
}
},
"extensionKind": [
"ui",
"workspace"
Expand Down
9 changes: 9 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export async function activate(context: vscode.ExtensionContext) {
updateStatus()}
));

context.subscriptions.push(vscode.workspace.onDidGrantWorkspaceTrust(async () => {
updateStatus(false);
}));

const dispOpenInJenkins = vscode.commands.registerCommand("jenkins.openInJenkins", async () => {
if (!await hasJenkinsInAnyRoot()) {
vscode.window.showWarningMessage("The project is not enabled for Jenkins. Missing .jenkins file.");
Expand Down Expand Up @@ -163,6 +167,11 @@ export async function activate(context: vscode.ExtensionContext) {

async function readSettings(jenkinsSettingsPath: Uri): Promise<string> {
if (jenkinsSettingsPath.fsPath.endsWith(".jenkinsrc.js")) {
if (!vscode.workspace.isTrusted) {
vscode.window.showInformationMessage("The current workspace must be Trusted in order to load settings from .jenkinsrc.js files.");
return undefined;
}

if (isRemoteUri(jenkinsSettingsPath)) {
vscode.window.showInformationMessage("This workspace contains a `.jenkinsrc.js` file, which requires the Jenkins Status extension to be installed on the remote.");
return undefined;
Expand Down

0 comments on commit ad34fbb

Please sign in to comment.