mirror of
https://gitea.computerliebe.org/ComputerLiebe_ORG_private/Gitea-VSCode-Clone-Plugin.git
synced 2025-07-05 20:23:41 +00:00
Truncate commit title longer than 255 characters
* chore(gitea-git-clone): update changelog and package version * fix(gitea-git-clone): truncate commit titles and bodies longer than 255 and 65535 characters respectively * feat(gitea-git-clone): show warning messages when commit titles and bodies are truncated
This commit is contained in:
@ -122,19 +122,36 @@ async function createGiteaPullRequest() {
|
||||
// Den letzten Commit und den Branch abrufen
|
||||
const { title, body } = await getLastCommit(currentWorkspaceFolder);
|
||||
const branch = await getCurrentBranch(currentWorkspaceFolder);
|
||||
|
||||
|
||||
if (!branch) {
|
||||
vscode.window.showErrorMessage(localize('giteaClone.noBranch', 'Could not determine the branch.'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Base-Branch über die Gitea API ermitteln
|
||||
const baseBranch = await getDefaultBranch(instanceUrl, owner, repo, token);
|
||||
|
||||
|
||||
// Titel und Body auf maximale Länge beschränken
|
||||
const maxTitleLength = 255;
|
||||
const maxBodyLength = 65535; // Beispielwert, kann je nach Gitea-Konfiguration variieren
|
||||
|
||||
let truncatedTitle = title;
|
||||
let truncatedBody = body;
|
||||
|
||||
if (title.length > maxTitleLength) {
|
||||
truncatedTitle = title.substring(0, maxTitleLength);
|
||||
vscode.window.showWarningMessage(localize('giteaClone.titleTruncated', 'The commit message was too long and has been truncated for the pull request title.'));
|
||||
}
|
||||
|
||||
if (body.length > maxBodyLength) {
|
||||
truncatedBody = body.substring(0, maxBodyLength);
|
||||
vscode.window.showWarningMessage(localize('giteaClone.bodyTruncated', 'The commit message body was too long and has been truncated for the pull request description.'));
|
||||
}
|
||||
|
||||
// API-Request-Daten vorbereiten
|
||||
const prData = {
|
||||
title: title, // Der letzte Commit als Titel
|
||||
body: body || '', // Commit-Kommentare als Body
|
||||
title: truncatedTitle, // Der getrunkierte Titel
|
||||
body: truncatedBody || '', // Der getrunkierte Body
|
||||
head: branch, // Der aktuelle Branch als "head"
|
||||
base: baseBranch // Der ermittelte base-Branch
|
||||
};
|
||||
|
Reference in New Issue
Block a user