Skip to content

Commit

Permalink
use simple git for repo detection
Browse files Browse the repository at this point in the history
  • Loading branch information
janthoXO committed Nov 22, 2024
1 parent 6eea9a4 commit 0877030
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 124 deletions.
Binary file added media/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions media/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/icon2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions media/icon2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Artemis - Scorpio",
"description": "",
"publisher": "tum-aet",
"icon": "media/artemis_logo.png",
"icon": "media/icon.png",
"version": "0.0.0",
"engines": {
"vscode": "^1.95.0"
Expand Down Expand Up @@ -38,14 +38,6 @@
"editPresentation": "singlelineText",
"default": "http://localhost:8080"
},
"scorpio.artemis.clientBaseUrl": {
"order": 2,
"markdownDescription": "The URL of the Artemis Client - probably the same as `#scorpio.artemis.apiBaseUrl#`",
"type": "string",
"format": "uri",
"editPresentation": "singlelineText",
"default": "http://localhost:9000"
},
"scorpio.defaults.repoPath": {
"order": 3,
"description": "The default to search for and clone repositories into - has to be an absolute path",
Expand All @@ -65,7 +57,7 @@
{
"id": "artemis-sidebar-view",
"title": "Artemis",
"icon": "media/artemis_logo.svg"
"icon": "media/icon.svg"
}
]
},
Expand All @@ -75,7 +67,7 @@
"type": "webview",
"id": "artemis-sidebar",
"name": "Scorpio",
"icon": "media/artemis_logo.svg",
"icon": "media/icon.svg",
"contextualTitle": "Artemis"
}
]
Expand Down
38 changes: 37 additions & 1 deletion src/authentication/authentication_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export async function authenticateToken(
username: string,
password: string
): Promise<{access_token: string}> {
var url = new URL(`${settings.base_url}/api/public/authenticate`);
const url = new URL(`${settings.base_url}/api/public/authenticate`);
url.searchParams.append("as-bearer", "true");
url.searchParams.append("tool", "SCORPIO");

Expand Down Expand Up @@ -36,3 +36,39 @@ export async function authenticateToken(
throw error;
});
}

export function retrieveVcsAccessToken(token: string, participationId: number,): Promise<string> {
return getVcsAccessToken(token, participationId, "GET").catch((error) => {
return getVcsAccessToken(token, participationId, "PUT");
});
}

function getVcsAccessToken(token: string, participationId: number, method: string): Promise<string> {
const url = new URL(`${settings.base_url}/api/account/participation-vcs-access-token`);
url.searchParams.append("participationId", participationId.toString());

return fetch(url, {
method: method,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
})
.then((response) => {
if (!response.ok) {
console.error(response)
throw new Error(
`HTTP error with status: ${response.status} ${response.statusText}`
);
}

return response.text();
})
.catch((error) => {
if (error instanceof TypeError) {
throw new Error(`Could not reach the server: ${error.message}`);
}

throw error;
});
}
6 changes: 1 addition & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ export function activate(context: vscode.ExtensionContext) {

listenToEvents();

(async () => {
// TODO make wait until everything else is initialized
await new Promise((resolve) => setTimeout(resolve, 2500));
vscode.commands.executeCommand("scorpio.workspace.detectRepo");
})();
vscode.commands.executeCommand("scorpio.workspace.detectRepo");
}

function initAuthentication(
Expand Down
Loading

0 comments on commit 0877030

Please sign in to comment.