1
0

Compare commits

...

2 Commits

4 changed files with 23 additions and 30 deletions

View File

@@ -122,16 +122,8 @@ window.addEventListener('DOMContentLoaded', async () => {
pushBtn.textContent = 'Pushing…';
try {
const hasUncommittedFiles = await window.electronAPI.hasDiffs(selected);
if (hasUncommittedFiles) {
const confirmed = confirm(
'This repository contains uncommitted or untracked files.\n\n' +
'Only committed files will be pushed. Continue anyway?'
);
if (!confirmed) return;
}
// send the folder‐path to main via a new IPC channel 'push-to-gitea'
const result = await window.electronAPI.pushToGitea(selected.path, hasUncommittedFiles);
const result = await window.electronAPI.pushToGitea(selected.path);
if (result.success) {
alert('✔ Pushed successfully to Gitea: ' + result.repoUrl);
} else {

View File

@@ -223,36 +223,44 @@
// OK: alles final speichern
// OK: alles final speichern – eine fehlschlagende Einstellung darf die
// anderen nicht blockieren und das Fenster muss sich immer schließen.
ok.addEventListener('click', async () => {
await window.settingsAPI.setSkipPrompt(cbSkip.checked);
await window.settingsAPI.setAutostart(cbAutostart.checked);
await window.settingsAPI.setCloseToTray(cbCloseToTray.checked);
await window.settingsAPI.setTheme(themeSelect.value || fallbackTheme);
await window.settingsAPI.setRewordMode(rewordModeSelect.value || 'ask');
const errors = [];
const safe = async (name, promise) => {
try { await promise; } catch (e) { errors.push(`${name}: ${e}`); }
};
await safe('Skip-Prompt', window.settingsAPI.setSkipPrompt(cbSkip.checked));
await safe('Autostart', window.settingsAPI.setAutostart(cbAutostart.checked));
await safe('Close-to-Tray', window.settingsAPI.setCloseToTray(cbCloseToTray.checked));
await safe('Theme', window.settingsAPI.setTheme(themeSelect.value || fallbackTheme));
await safe('Reword-Mode', window.settingsAPI.setRewordMode(rewordModeSelect.value || 'ask'));
// Threshold speichern (immer Wert aus Feld nehmen!)
let threshold = parseInt(thresholdInput.value, 10);
if (isNaN(threshold)) threshold = 10;
if (threshold < 1) threshold = 1;
if (threshold > 1000) threshold = 1000;
await window.settingsAPI.setIntelligentCommitThreshold(threshold);
await safe('Commit-Threshold', window.settingsAPI.setIntelligentCommitThreshold(threshold));
let minutes = parseInt(minutesInput.value, 10);
if (isNaN(minutes)) minutes = 10;
if (minutes < 1) minutes = 1;
if (minutes > 1000) minutes = 60;
await window.settingsAPI.setMinutesCommitThreshold(minutes);
await safe('Minutes-Threshold', window.settingsAPI.setMinutesCommitThreshold(minutes));
// Dropdowns speichern
const commitSel = document.getElementById('commitModelSelect');
const readmeSel = document.getElementById('readmeModelSelect');
if (commitSel) await window.settingsAPI.setCommitModel(commitSel.value);
if (readmeSel) await window.settingsAPI.setReadmeModel(readmeSel.value);
await window.settingsAPI.setGiteaToken(giteaTokenInput.value.trim());
if (commitSel) await safe('Commit-Model', window.settingsAPI.setCommitModel(commitSel.value));
if (readmeSel) await safe('Readme-Model', window.settingsAPI.setReadmeModel(readmeSel.value));
await safe('Gitea-Token', window.settingsAPI.setGiteaToken(giteaTokenInput.value.trim()));
if (errors.length) {
alert('Nicht alle Einstellungen konnten gespeichert werden:\n\n' + errors.join('\n'));
}
window.settingsAPI.close();
});
// Cancel / Close: Theme zurücksetzen, dann schließen

View File

@@ -3557,6 +3557,7 @@ fn set_autostart(state: tauri::State<'_, AppState>, enabled: bool) -> CommandRes
let auto = auto_launch::AutoLaunchBuilder::new()
.set_app_name("Auto-Git")
.set_app_path(exe.to_string_lossy().as_ref())
.set_use_launch_agent(true)
.build()
.map_err(|e| e.to_string())?;
if enabled {
@@ -4886,7 +4887,6 @@ fn push_to_gitea(
app: AppHandle,
state: tauri::State<'_, AppState>,
folder_path: String,
allow_dirty: bool,
) -> CommandResult<Value> {
let token = state
.store
@@ -4899,13 +4899,6 @@ fn push_to_gitea(
json!({ "success": false, "error": "No Gitea API token configured – open Settings and enter it first" }),
);
}
if has_status_changes(&git_status(&folder_path)?) && !allow_dirty {
return Ok(json!({
"success": false,
"code": "DIRTY_WORKTREE",
"error": "The repository contains uncommitted or untracked files. Confirm the warning before pushing."
}));
}
let result = (|| -> CommandResult<Value> {
let folder_name = Path::new(&folder_path)
.file_name()

View File

@@ -125,7 +125,7 @@
hasReadme: folderPath => invoke('has_readme', { folderPath }),
generateReadme: folderPath => invoke('generate_readme', { folderPath }),
squashCommits: folderPath => invoke('squash_commits', { folderPath }),
pushToGitea: (folderPath, allowDirty = false) => invoke('push_to_gitea', { folderPath, allowDirty }),
pushToGitea: folderPath => invoke('push_to_gitea', { folderPath }),
initRepo: folderPath => invoke('init_repo', { folderPath }),
triggerRewriteNow: folderPath => invoke('trigger_rewrite_now', { folderPath }),
rewriteCommit: (folderPath, hash) => invoke('rewrite_commit', { folderPath, hash }),