Simplify pushToGitea logic by removing dirty worktree check
This commit is contained in:
10
renderer.js
10
renderer.js
@@ -122,16 +122,8 @@ window.addEventListener('DOMContentLoaded', async () => {
|
|||||||
pushBtn.textContent = 'Pushing…';
|
pushBtn.textContent = 'Pushing…';
|
||||||
|
|
||||||
try {
|
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'
|
// 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) {
|
if (result.success) {
|
||||||
alert('✔ Pushed successfully to Gitea: ' + result.repoUrl);
|
alert('✔ Pushed successfully to Gitea: ' + result.repoUrl);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4886,7 +4886,6 @@ fn push_to_gitea(
|
|||||||
app: AppHandle,
|
app: AppHandle,
|
||||||
state: tauri::State<'_, AppState>,
|
state: tauri::State<'_, AppState>,
|
||||||
folder_path: String,
|
folder_path: String,
|
||||||
allow_dirty: bool,
|
|
||||||
) -> CommandResult<Value> {
|
) -> CommandResult<Value> {
|
||||||
let token = state
|
let token = state
|
||||||
.store
|
.store
|
||||||
@@ -4899,13 +4898,6 @@ fn push_to_gitea(
|
|||||||
json!({ "success": false, "error": "No Gitea API token configured – open Settings and enter it first" }),
|
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 result = (|| -> CommandResult<Value> {
|
||||||
let folder_name = Path::new(&folder_path)
|
let folder_name = Path::new(&folder_path)
|
||||||
.file_name()
|
.file_name()
|
||||||
|
|||||||
@@ -125,7 +125,7 @@
|
|||||||
hasReadme: folderPath => invoke('has_readme', { folderPath }),
|
hasReadme: folderPath => invoke('has_readme', { folderPath }),
|
||||||
generateReadme: folderPath => invoke('generate_readme', { folderPath }),
|
generateReadme: folderPath => invoke('generate_readme', { folderPath }),
|
||||||
squashCommits: folderPath => invoke('squash_commits', { 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 }),
|
initRepo: folderPath => invoke('init_repo', { folderPath }),
|
||||||
triggerRewriteNow: folderPath => invoke('trigger_rewrite_now', { folderPath }),
|
triggerRewriteNow: folderPath => invoke('trigger_rewrite_now', { folderPath }),
|
||||||
rewriteCommit: (folderPath, hash) => invoke('rewrite_commit', { folderPath, hash }),
|
rewriteCommit: (folderPath, hash) => invoke('rewrite_commit', { folderPath, hash }),
|
||||||
|
|||||||
Reference in New Issue
Block a user