Update Gitea-Sektion:

Branch-Auswahl
Dieser Commit ist enthalten in:
Claude Project Manager
2025-12-29 19:02:44 +00:00
Ursprung 8da6ad83f0
Commit 627beb1353
30 geänderte Dateien mit 3953 neuen und 56 gelöschten Zeilen

Datei anzeigen

@ -72,6 +72,13 @@ class GiteaManager {
// Commit Modal
$('#git-commit-form')?.addEventListener('submit', (e) => this.handleCommit(e));
// Push Modal
$('#git-push-form')?.addEventListener('submit', (e) => this.executePush(e));
// Branch umbenennen
$('#btn-rename-branch')?.addEventListener('click', () => this.openRenameBranchModal());
$('#git-rename-branch-form')?.addEventListener('submit', (e) => this.executeRenameBranch(e));
}
subscribeToStore() {
@ -406,27 +413,76 @@ class GiteaManager {
}
}
async handlePush() {
handlePush() {
// Öffne das Push-Modal zur Branch-Auswahl
this.openPushModal();
}
openPushModal() {
const modal = $('#git-push-modal');
if (!modal) return;
// Aktuellen lokalen Branch anzeigen
const currentBranch = $('#branch-select')?.value || this.gitStatus?.branch || 'unbekannt';
$('#push-local-branch').textContent = currentBranch;
// Ziel-Branch zurücksetzen (Standard: gleicher Name wie lokal)
$('#push-target-branch').value = '';
modal.classList.remove('hidden');
modal.classList.add('visible');
$('#modal-overlay')?.classList.remove('hidden');
store.openModal('git-push-modal');
}
async executePush(e) {
e.preventDefault();
const projectId = store.get('currentProjectId');
if (!projectId) return;
// Modal schließen
const modal = $('#git-push-modal');
modal?.classList.add('hidden');
modal?.classList.remove('visible');
$('#modal-overlay')?.classList.add('hidden');
store.closeModal();
this.setOperationLoading('push', true);
try {
const branch = $('#branch-select')?.value || 'main';
let result = await api.gitPush(projectId, branch);
const targetBranch = $('#push-target-branch')?.value || null;
const forcePush = $('#push-force')?.checked || false;
const localBranch = $('#branch-select')?.value || this.gitStatus?.branch || 'master';
// Falls Push wegen fehlendem Upstream/Remote fehlschlägt, versuche init-push
if (!result.success && result.error &&
(result.error.includes('No configured push destination') ||
result.error.includes('no upstream') ||
result.error.includes('Kein Remote'))) {
this.showToast('Kein Upstream konfiguriert, führe initialen Push durch...', 'info');
result = await api.gitInitPush(projectId, branch);
let result;
// Wenn ein anderer Target-Branch ausgewählt wurde oder Force-Push, verwende init-push
if ((targetBranch && targetBranch !== localBranch) || forcePush) {
const forceText = forcePush ? ' (Force)' : '';
const branchText = targetBranch && targetBranch !== localBranch
? `Push von "${localBranch}" nach "${targetBranch}"${forceText}...`
: `Push nach "${localBranch}"${forceText}...`;
this.showToast(branchText, 'info');
result = await api.gitInitPush(projectId, targetBranch, forcePush);
} else {
// Normaler Push (gleicher Branch-Name)
result = await api.gitPush(projectId, localBranch);
// Falls Push wegen fehlendem Upstream/Remote fehlschlägt, versuche init-push
if (!result.success && result.error &&
(result.error.includes('No configured push destination') ||
result.error.includes('no upstream') ||
result.error.includes('Kein Remote'))) {
this.showToast('Kein Upstream konfiguriert, führe initialen Push durch...', 'info');
result = await api.gitInitPush(projectId, targetBranch, false);
}
}
if (result.success) {
this.showToast('Push erfolgreich', 'success');
const pushedBranch = result.branch || targetBranch || localBranch;
this.showToast(`Push erfolgreich nach Branch "${pushedBranch}"`, 'success');
await this.loadGitData();
} else {
this.showToast(result.error || 'Push fehlgeschlagen', 'error');
@ -438,6 +494,64 @@ class GiteaManager {
}
}
openRenameBranchModal() {
const modal = $('#git-rename-branch-modal');
if (!modal) return;
const currentBranch = $('#branch-select')?.value || this.gitStatus?.branch || 'master';
$('#rename-current-branch').textContent = currentBranch;
$('#rename-new-branch').value = '';
modal.classList.remove('hidden');
modal.classList.add('visible');
$('#modal-overlay')?.classList.remove('hidden');
store.openModal('git-rename-branch-modal');
// Focus auf das Eingabefeld
setTimeout(() => $('#rename-new-branch')?.focus(), 100);
}
async executeRenameBranch(e) {
e.preventDefault();
const projectId = store.get('currentProjectId');
if (!projectId) return;
const oldName = $('#rename-current-branch')?.textContent;
const newName = $('#rename-new-branch')?.value.trim();
if (!newName) {
this.showToast('Bitte geben Sie einen neuen Branch-Namen ein', 'error');
return;
}
if (oldName === newName) {
this.showToast('Der neue Name ist identisch mit dem aktuellen', 'error');
return;
}
// Modal schließen
const modal = $('#git-rename-branch-modal');
modal?.classList.add('hidden');
modal?.classList.remove('visible');
$('#modal-overlay')?.classList.add('hidden');
store.closeModal();
try {
const result = await api.gitRenameBranch(projectId, oldName, newName);
if (result.success) {
this.showToast(`Branch umbenannt: "${oldName}" → "${newName}"`, 'success');
await this.loadGitData();
} else {
this.showToast(result.error || 'Umbenennen fehlgeschlagen', 'error');
}
} catch (error) {
this.showToast(error.message || 'Umbenennen fehlgeschlagen', 'error');
}
}
openCommitModal() {
const modal = $('#git-commit-modal');
if (!modal) return;
@ -610,13 +724,11 @@ class GiteaManager {
renderStatus() {
const statusBadge = $('#git-status-indicator');
const changesCount = $('#git-changes-count');
const aheadBehind = $('#git-ahead-behind');
if (!this.gitStatus) {
statusBadge.textContent = 'Fehler';
statusBadge.className = 'status-badge error';
changesCount.textContent = '-';
aheadBehind.textContent = '- / -';
return;
}
@ -630,9 +742,6 @@ class GiteaManager {
} else if (this.gitStatus.hasChanges) {
statusBadge.textContent = 'Geändert';
statusBadge.className = 'status-badge dirty';
} else if (this.gitStatus.ahead > 0) {
statusBadge.textContent = 'Voraus';
statusBadge.className = 'status-badge ahead';
} else {
statusBadge.textContent = 'OK';
statusBadge.className = 'status-badge clean';
@ -641,11 +750,6 @@ class GiteaManager {
// Änderungen
const changes = this.gitStatus.changes || [];
changesCount.textContent = changes.length;
// Ahead/Behind
const ahead = this.gitStatus.ahead || 0;
const behind = this.gitStatus.behind || 0;
aheadBehind.textContent = `${ahead} / ${behind}`;
}
renderBranches() {