mirror of
https://gitea.computerliebe.org/ComputerLiebe_ORG_private/Gitea-VSCode-Clone-Plugin.git
synced 2024-12-26 23:41:52 +00:00
Merge pull request 'fix-cloning-into-subpath' (#4) from fix-cloning-into-subpath into main
Reviewed-on: ComputerLiebe_ORG_private/Gitea-VSCode-Clone-Plugin#4
This commit is contained in:
commit
a200a23c3f
@ -10,6 +10,17 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
||||
- if working in PR show different Icon with hint
|
||||
- fix progress bar in notification
|
||||
|
||||
## 1.2.1
|
||||
|
||||
### Fixed
|
||||
|
||||
- cloning into existing subpath working again
|
||||
|
||||
### Added
|
||||
|
||||
- more verbose error handling
|
||||
|
||||
|
||||
## 1.2.0
|
||||
|
||||
### Added
|
||||
|
@ -4,18 +4,14 @@
|
||||
"giteaClone.noRemoteUrl": "Konnte die Git-Remote-URL nicht abrufen.",
|
||||
"giteaClone.noBranch": "Branch konnte nicht ermittelt werden.",
|
||||
"giteaClone.pullRequestCreated": "Pull-Request erfolgreich erstellt und im Browser geöffnet.",
|
||||
"giteaClone.pullRequestError": "Fehler beim Erstellen des Pull Requests: {0}",
|
||||
"giteaClone.commitError": "Fehler beim Abrufen des letzten Commits.",
|
||||
"giteaClone.branchError": "Fehler beim Abrufen des Branches.",
|
||||
"giteaClone.defaultBranchError": "Konnte den base-Branch nicht ermitteln. Standardmäßig wird \"main\" verwendet.",
|
||||
"giteaClone.createPullRequest": "Gitea PR erstellen",
|
||||
"giteaClone.createPullRequestTooltip": "Pull Request in Gitea erstellen",
|
||||
"giteaClone.authSuccess": "Authentifizierung erfolgreich: {0}",
|
||||
"giteaClone.authFailed": "Authentifizierung fehlgeschlagen.",
|
||||
"giteaClone.configUpdated": "Gitea-Konfiguration aktualisiert.",
|
||||
"giteaClone.enterInstanceUrl": "Gitea-Instanz-URL eingeben",
|
||||
"giteaClone.enterToken": "Gitea Personal Access Token eingeben",
|
||||
"giteaClone.repoError": "Fehler beim Abrufen der Repositories.",
|
||||
"giteaClone.apiError": "Fehler bei der Verbindung mit der Gitea API.",
|
||||
"giteaClone.noRepos": "Keine Repositories gefunden.",
|
||||
"giteaClone.selectRepo": "Wähle ein Repository zum Klonen aus",
|
||||
@ -32,7 +28,12 @@
|
||||
"giteaClone.noOpenPRs": "Keine offenen Pull Requests vorhanden.",
|
||||
"giteaClone.selectPullRequest": "Wähle einen Pull Request zum Anzeigen aus",
|
||||
"giteaClone.repoInfoError": "Konnte Repository-Informationen nicht abrufen.",
|
||||
"giteaClone.pullRequestsError": "Fehler beim Abrufen der Pull Requests.",
|
||||
"giteaClone.showOpenPullRequestsTooltip": "Offene Pull Requests anzeigen"
|
||||
"giteaClone.showOpenPullRequestsTooltip": "Offene Pull Requests anzeigen",
|
||||
"giteaClone.targetExists": "Das Zielverzeichnis \"{0}\" existiert bereits.",
|
||||
"giteaClone.pullRequestError": "Fehler beim Erstellen des Pull Requests: {0}",
|
||||
"giteaClone.defaultBranchError": "Fehler beim Abrufen des Basis-Branches: {0}",
|
||||
"giteaClone.repoError": "Fehler beim Abrufen der Repositories: {0}",
|
||||
"giteaClone.authFailed": "Authentifizierung fehlgeschlagen: {0}",
|
||||
"giteaClone.pullRequestsError": "Fehler beim Abrufen der Pull Requests: {0}"
|
||||
}
|
||||
|
@ -4,18 +4,14 @@
|
||||
"giteaClone.noRemoteUrl": "Could not retrieve Git remote URL.",
|
||||
"giteaClone.noBranch": "Could not determine the branch.",
|
||||
"giteaClone.pullRequestCreated": "Pull request created successfully and opened in the browser.",
|
||||
"giteaClone.pullRequestError": "Error creating pull request: {0}",
|
||||
"giteaClone.commitError": "Error retrieving the last commit.",
|
||||
"giteaClone.branchError": "Error retrieving the branch.",
|
||||
"giteaClone.defaultBranchError": "Could not determine the base branch. Defaulting to \"main\".",
|
||||
"giteaClone.createPullRequest": "Create Gitea PR",
|
||||
"giteaClone.createPullRequestTooltip": "Create a Pull Request in Gitea",
|
||||
"giteaClone.authSuccess": "Authentication successful: {0}",
|
||||
"giteaClone.authFailed": "Authentication failed.",
|
||||
"giteaClone.configUpdated": "Gitea configuration updated.",
|
||||
"giteaClone.enterInstanceUrl": "Enter Gitea instance URL",
|
||||
"giteaClone.enterToken": "Enter Gitea Personal Access Token",
|
||||
"giteaClone.repoError": "Error retrieving repositories.",
|
||||
"giteaClone.apiError": "Error connecting to Gitea API.",
|
||||
"giteaClone.noRepos": "No repositories found.",
|
||||
"giteaClone.selectRepo": "Select a repository to clone",
|
||||
@ -32,7 +28,12 @@
|
||||
"giteaClone.noOpenPRs": "There are no open pull requests.",
|
||||
"giteaClone.selectPullRequest": "Select a pull request to view",
|
||||
"giteaClone.repoInfoError": "Could not retrieve repository information.",
|
||||
"giteaClone.pullRequestsError": "Error retrieving pull requests.",
|
||||
"giteaClone.showOpenPullRequestsTooltip": "Show open pull requests"
|
||||
"giteaClone.showOpenPullRequestsTooltip": "Show open pull requests",
|
||||
"giteaClone.targetExists": "The target directory \"{0}\" already exists.",
|
||||
"giteaClone.pullRequestError": "Error creating pull request: {0}",
|
||||
"giteaClone.defaultBranchError": "Error retrieving the base branch: {0}",
|
||||
"giteaClone.repoError": "Error retrieving repositories: {0}",
|
||||
"giteaClone.authFailed": "Authentication failed: {0}",
|
||||
"giteaClone.pullRequestsError": "Error retrieving pull requests: {0}"
|
||||
}
|
||||
|
4
gitea-git-clone/package-lock.json
generated
4
gitea-git-clone/package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "gitea-workflow",
|
||||
"version": "1.0.2",
|
||||
"version": "1.2.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gitea-workflow",
|
||||
"version": "1.0.2",
|
||||
"version": "1.2.0",
|
||||
"dependencies": {
|
||||
"axios": "^1.7.7",
|
||||
"open": "^10.1.0",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "gitea-workflow",
|
||||
"displayName": "Gitea Workflow",
|
||||
"description": "Clone from Gitea instances; Create PRs",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"publisher": "computerliebe",
|
||||
"engines": {
|
||||
"vscode": "^1.94.0"
|
||||
|
@ -1,7 +1,24 @@
|
||||
import * as vscode from 'vscode';
|
||||
import axios from 'axios';
|
||||
import { AxiosError } from 'axios';
|
||||
import { exec } from 'child_process';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
//Interface
|
||||
interface GiteaErrorResponse {
|
||||
message?: string;
|
||||
url?: string;
|
||||
documentation_url?: string;
|
||||
errors?: Array<{
|
||||
resource?: string;
|
||||
field?: string;
|
||||
code?: string;
|
||||
message?: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
|
||||
// Initialisiere die Lokalisierung
|
||||
const localize = nls.config({ messageFormat: nls.MessageFormat.file })();
|
||||
@ -86,7 +103,33 @@ async function createGiteaPullRequest() {
|
||||
vscode.env.openExternal(vscode.Uri.parse(prUrl));
|
||||
vscode.window.showInformationMessage(localize('giteaClone.pullRequestCreated', 'Pull request created successfully and opened in the browser.'));
|
||||
} catch (err: any) {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.pullRequestError', `Error creating pull request: ${err.message}`));
|
||||
let errMessage = '';
|
||||
|
||||
if (axios.isAxiosError(err)) {
|
||||
const axiosError = err as AxiosError;
|
||||
if (axiosError.response && axiosError.response.data) {
|
||||
const data = axiosError.response.data as GiteaErrorResponse;
|
||||
if (typeof data === 'string') {
|
||||
errMessage = data;
|
||||
} else if (data.message) {
|
||||
errMessage = data.message;
|
||||
}
|
||||
|
||||
// Optional: Weitere Details aus 'errors' extrahieren
|
||||
if (data.errors && Array.isArray(data.errors)) {
|
||||
data.errors.forEach((errorItem: any) => {
|
||||
if (errorItem.message) {
|
||||
errMessage += ` ${errorItem.message}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errMessage = err.message;
|
||||
}
|
||||
|
||||
let errorMessage = localize('giteaClone.pullRequestError', `Error creating pull request: ${errMessage}`);
|
||||
vscode.window.showErrorMessage(errorMessage);
|
||||
console.error('Error creating PR:', err);
|
||||
}
|
||||
});
|
||||
@ -136,8 +179,25 @@ async function getDefaultBranch(instanceUrl: string, owner: string, repo: string
|
||||
vscode.window.showErrorMessage(localize('giteaClone.defaultBranchError', 'Could not determine the base branch. Defaulting to "main".'));
|
||||
return 'main';
|
||||
}
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.defaultBranchError', 'Error retrieving the base branch. Defaulting to "main".'));
|
||||
} catch (err: any) {
|
||||
let errMessage = '';
|
||||
|
||||
if (axios.isAxiosError(err)) {
|
||||
const axiosError = err as AxiosError;
|
||||
if (axiosError.response && axiosError.response.data) {
|
||||
const data = axiosError.response.data as GiteaErrorResponse;
|
||||
if (typeof data === 'string') {
|
||||
errMessage = data;
|
||||
} else if (data.message) {
|
||||
errMessage = data.message;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errMessage = err.message;
|
||||
}
|
||||
|
||||
let errorMessage = localize('giteaClone.defaultBranchError', `Error retrieving the base branch: ${errMessage}`);
|
||||
vscode.window.showErrorMessage(errorMessage);
|
||||
return 'main';
|
||||
}
|
||||
}
|
||||
@ -165,9 +225,26 @@ async function getGiteaRepositories(): Promise<any[]> {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.repoError', 'Error retrieving repositories.'));
|
||||
return [];
|
||||
}
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.apiError', 'Error connecting to Gitea API.'));
|
||||
console.error(error);
|
||||
} catch (err: any) {
|
||||
let errMessage = '';
|
||||
|
||||
if (axios.isAxiosError(err)) {
|
||||
const axiosError = err as AxiosError;
|
||||
if (axiosError.response && axiosError.response.data) {
|
||||
const data = axiosError.response.data as GiteaErrorResponse;
|
||||
if (typeof data === 'string') {
|
||||
errMessage = data;
|
||||
} else if (data.message) {
|
||||
errMessage = data.message;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errMessage = err.message;
|
||||
}
|
||||
|
||||
let errorMessage = localize('giteaClone.repoError', `Error retrieving repositories: ${errMessage}`);
|
||||
vscode.window.showErrorMessage(errorMessage);
|
||||
console.error(err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -203,6 +280,14 @@ async function cloneGiteaRepository() {
|
||||
|
||||
if (folderUri && folderUri[0]) {
|
||||
const folderPath = folderUri[0].fsPath;
|
||||
const repoName = repo.name;
|
||||
const targetPath = path.join(folderPath, repoName);
|
||||
|
||||
// Überprüfen, ob das Zielverzeichnis bereits existiert
|
||||
if (fs.existsSync(targetPath)) {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.targetExists', `The target directory "${targetPath}" already exists.`));
|
||||
return;
|
||||
}
|
||||
|
||||
vscode.window.withProgress({
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
@ -212,7 +297,7 @@ async function cloneGiteaRepository() {
|
||||
progress.report({ message: localize('giteaClone.cloningProgress', 'Cloning in progress...'), increment: 0 });
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
exec(`git clone ${repo.ssh_url} ${folderPath}`, (error, stdout, stderr) => {
|
||||
exec(`git clone ${repo.ssh_url} "${targetPath}"`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.cloneError', 'Error cloning the repository.'));
|
||||
console.error(stderr);
|
||||
@ -223,7 +308,7 @@ async function cloneGiteaRepository() {
|
||||
|
||||
// Öffne das geklonte Repository im VSCode
|
||||
try {
|
||||
vscode.commands.executeCommand('vscode.openFolder', vscode.Uri.file(folderPath), true)
|
||||
vscode.commands.executeCommand('vscode.openFolder', vscode.Uri.file(targetPath), true)
|
||||
.then(() => resolve());
|
||||
} catch (err: unknown) {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.openRepoError', 'Error opening the cloned repository.'));
|
||||
@ -272,9 +357,26 @@ async function authenticateGitea() {
|
||||
if (response.status === 200) {
|
||||
vscode.window.showInformationMessage(localize('giteaClone.authSuccess', `Authentication successful: ${response.data.username}`));
|
||||
}
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.authFailed', 'Authentication failed.'));
|
||||
console.error(error);
|
||||
} catch (err: any) {
|
||||
let errMessage = '';
|
||||
|
||||
if (axios.isAxiosError(err)) {
|
||||
const axiosError = err as AxiosError;
|
||||
if (axiosError.response && axiosError.response.data) {
|
||||
const data = axiosError.response.data as GiteaErrorResponse;
|
||||
if (typeof data === 'string') {
|
||||
errMessage = data;
|
||||
} else if (data.message) {
|
||||
errMessage = data.message;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errMessage = err.message;
|
||||
}
|
||||
|
||||
let errorMessage = localize('giteaClone.authFailed', `Authentication failed: ${errMessage}`);
|
||||
vscode.window.showErrorMessage(errorMessage);
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,9 +442,26 @@ async function getOpenPullRequests(): Promise<any[]> {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.pullRequestsError', 'Fehler beim Abrufen der Pull Requests.'));
|
||||
return [];
|
||||
}
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.apiError', 'Fehler bei der Verbindung zur Gitea API.'));
|
||||
console.error(error);
|
||||
} catch (err: any) {
|
||||
let errMessage = '';
|
||||
|
||||
if (axios.isAxiosError(err)) {
|
||||
const axiosError = err as AxiosError;
|
||||
if (axiosError.response && axiosError.response.data) {
|
||||
const data = axiosError.response.data as GiteaErrorResponse;
|
||||
if (typeof data === 'string') {
|
||||
errMessage = data;
|
||||
} else if (data.message) {
|
||||
errMessage = data.message;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errMessage = err.message;
|
||||
}
|
||||
|
||||
let errorMessage = localize('giteaClone.pullRequestsError', `Error retrieving pull requests: ${errMessage}`);
|
||||
vscode.window.showErrorMessage(errorMessage);
|
||||
console.error(err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -398,12 +517,9 @@ async function showOpenPullRequests() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let extensionContext: vscode.ExtensionContext;
|
||||
|
||||
// Funktion zum Aktualisieren des PR-Statusleisten-Icons
|
||||
let prStatusBarItem: vscode.StatusBarItem;
|
||||
|
||||
// Funktion zum Aktualisieren des PR-Statusleisten-Icons
|
||||
async function updatePRStatusBarItem(context: vscode.ExtensionContext) {
|
||||
try {
|
||||
const pullRequests = await getOpenPullRequests();
|
||||
@ -441,7 +557,6 @@ function startPRStatusBarItemUpdater(context: vscode.ExtensionContext) {
|
||||
setInterval(() => updatePRStatusBarItem(context), 300000); // 5 Minuten
|
||||
}
|
||||
|
||||
|
||||
// Aktivierungsfunktion des Plugins
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
// Registriert den Befehl zur Authentifizierung
|
||||
|
Loading…
Reference in New Issue
Block a user