feat(tauri): add single instance plugin and improve code formatting
publish / publish-tauri (appimage, 1, ubuntu-22.04, linux-x86_64) (release) Successful in 19m14s
publish / publish-tauri (nsis, , windows-latest, windows-x86_64) (release) Successful in 26m5s

This update introduces the tauri-plugin-single-instance to ensure that
only one instance of the application can run at a time. Additionally,
the code has been reformatted for better readability, with consistent
line breaks and spacing.

- Added single instance plugin to prevent multiple app instances
- Improved code formatting for better readability and maintenance
- Updated dependencies in Cargo.toml for new plugin integration
This commit is contained in:
Christoph Brandau
2026-07-09 09:49:27 +02:00
parent c087171735
commit 0ba7169efd
4 changed files with 162 additions and 20 deletions
+20 -4
View File
@@ -681,7 +681,14 @@ pub fn create_tag(
Some(message) => {
run_git(
&repo,
["tag", "-a", name.as_str(), "-m", message.as_str(), target.as_str()],
[
"tag",
"-a",
name.as_str(),
"-m",
message.as_str(),
target.as_str(),
],
)?;
}
None => {
@@ -755,7 +762,11 @@ fn validate_existing_tag_name(repo: &Path, name: &str) -> Result<String, String>
fn validate_tag_ref_name(name: &str) -> Result<String, String> {
let output = git_command()
.args(["check-ref-format", "--allow-onelevel", &format!("refs/tags/{name}")])
.args([
"check-ref-format",
"--allow-onelevel",
&format!("refs/tags/{name}"),
])
.output()
.map_err(|err| format!("Could not start Git. Is Git installed? {err}"))?;
@@ -1096,7 +1107,11 @@ pub fn last_commit_message(path: String) -> Result<Option<String>, String> {
let output = run_git(&repo, ["log", "-1", "--format=%B", "HEAD"])?;
let message = String::from_utf8_lossy(&output).trim_end().to_string();
Ok(if message.is_empty() { None } else { Some(message) })
Ok(if message.is_empty() {
None
} else {
Some(message)
})
}
#[tauri::command]
@@ -5544,7 +5559,8 @@ mod tests {
fn get_file_blame_attributes_lines_to_the_commits_that_introduced_them() {
let repo = init_temp_repo("file_blame");
commit_initial_file(&repo.path);
fs::write(repo.path.join("old.txt"), "original\ntwo\n").expect("tracked file should change");
fs::write(repo.path.join("old.txt"), "original\ntwo\n")
.expect("tracked file should change");
run_git_test(&repo.path, ["add", "old.txt"]);
run_git_test(&repo.path, ["commit", "-q", "-m", "add second line"]);
+15 -7
View File
@@ -19,7 +19,7 @@ use git::{
restore_to_commit, search_code_introductions, stage_files, stash_apply, stash_drop, stash_pop,
stash_push, undo_last_commit, unstage_files,
};
use tauri::Manager;
use tauri::{Manager, AppHandle};
#[tauri::command]
fn close_splashscreen(app: tauri::AppHandle) -> Result<(), String> {
@@ -43,13 +43,21 @@ fn close_splashscreen(app: tauri::AppHandle) -> Result<(), String> {
#[tokio::main]
async fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_single_instance::init(|app, _, _| {
#[cfg(desktop)]
let _ = app.get_webview_window("main")
.expect("no main window")
.set_focus();
}))
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_aptabase::Builder::new("A-SH-1344793789").with_options(
tauri_plugin_aptabase::InitOptions {
host: Some("https://aptabase.cbsk-tech.de".to_string()),
flush_interval:None
}
).build())
.plugin(
tauri_plugin_aptabase::Builder::new("A-SH-1344793789")
.with_options(tauri_plugin_aptabase::InitOptions {
host: Some("https://aptabase.cbsk-tech.de".to_string()),
flush_interval: None,
})
.build(),
)
.manage(SearchCancellationState::default())
.manage(commit_ai::CommitAiEngine::new())
.plugin(tauri_plugin_dialog::init())