Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"core:window:allow-show",
"core:window:allow-close",
"dialog:allow-open",
"dialog:allow-save",
"dialog:allow-ask",
"os:default",
"core:menu:allow-popup",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/gen/schemas/capabilities.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"default":{"identifier":"default","description":"Default capability for invoking app commands","local":true,"windows":["main","settings","clone-repository","result-log","about","attributions"],"permissions":["core:default","core:webview:allow-create-webview-window","core:window:allow-create","core:window:allow-set-focus","core:window:allow-set-title","core:window:allow-show","core:window:allow-close","dialog:allow-open","dialog:allow-ask","os:default","core:menu:allow-popup","core:menu:allow-new","core:menu:allow-append","core:menu:allow-remove","core:window:allow-cursor-position","core:window:allow-outer-position","updater:default","shell:allow-open",{"identifier":"opener:allow-open-path","allow":[{"path":"$APPCONFIG"},{"path":"$HOME/**"},{"path":"$DESKTOP/**"},{"path":"$DOCUMENT/**"},{"path":"$DOWNLOAD/**"}]}]}}
{"default":{"identifier":"default","description":"Default capability for invoking app commands","local":true,"windows":["main","settings","clone-repository","result-log","about","attributions"],"permissions":["core:default","core:webview:allow-create-webview-window","core:window:allow-create","core:window:allow-set-focus","core:window:allow-set-title","core:window:allow-show","core:window:allow-close","dialog:allow-open","dialog:allow-save","dialog:allow-ask","os:default","core:menu:allow-popup","core:menu:allow-new","core:menu:allow-append","core:menu:allow-remove","core:window:allow-cursor-position","core:window:allow-outer-position","updater:default","shell:allow-open",{"identifier":"opener:allow-open-path","allow":[{"path":"$APPCONFIG"},{"path":"$HOME/**"},{"path":"$DESKTOP/**"},{"path":"$DOCUMENT/**"},{"path":"$DOWNLOAD/**"}]}]}}
63 changes: 49 additions & 14 deletions src-tauri/src/commands/repo.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::git::types::{
CloneRequest, CommitDetails, CommitDetailsRequest, CommitFileItem, CommitFilesRequest,
CommitMarkers, CommitRequest, DiffRequest, ExternalDiffRequest, FetchRequest, FileDiff,
FileRequest, GitIdentity, HunkStageRequest, IdentityRequest, NumstatRequest, NumstatResult,
OperationResult, PullAnalysis, PullStrategyRequest, PushRequest, PushResult, RepoRequest,
RepoStatus, SetIdentityRequest, StageFilesRequest, StashEntry, StashPushRequest, StashRequest,
SubmoduleActionRequest,
CommitMarkers, CommitRequest, DiffRequest, ExportPatchRequest, ExternalDiffRequest,
FetchRequest, FileDiff, FileRequest, GitIdentity, HunkStageRequest, IdentityRequest,
ImportPatchRequest, NumstatRequest, NumstatResult, OperationResult, PullAnalysis,
PullStrategyRequest, PushRequest, PushResult, RepoRequest, RepoStatus, SetIdentityRequest,
StageFilesRequest, StashEntry, StashPushRequest, StashRequest, SubmoduleActionRequest,
};
use crate::{AppState, CloneCancelFlag, configure_command};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -290,7 +290,9 @@ pub async fn get_commit_markers(
app: tauri::AppHandle,
) -> Result<CommitMarkers, String> {
tauri::async_runtime::spawn_blocking(move || {
app.state::<AppState>().git_service.get_commit_markers(request)
app.state::<AppState>()
.git_service
.get_commit_markers(request)
})
.await
.map_err(|e| e.to_string())?
Expand All @@ -303,7 +305,9 @@ pub async fn get_commit_files(
app: tauri::AppHandle,
) -> Result<Vec<CommitFileItem>, String> {
tauri::async_runtime::spawn_blocking(move || {
app.state::<AppState>().git_service.get_commit_files(request)
app.state::<AppState>()
.git_service
.get_commit_files(request)
})
.await
.map_err(|e| e.to_string())?
Expand All @@ -316,7 +320,9 @@ pub async fn get_commit_details(
app: tauri::AppHandle,
) -> Result<CommitDetails, String> {
tauri::async_runtime::spawn_blocking(move || {
app.state::<AppState>().git_service.get_commit_details(request)
app.state::<AppState>()
.git_service
.get_commit_details(request)
})
.await
.map_err(|e| e.to_string())?
Expand Down Expand Up @@ -522,8 +528,7 @@ pub fn get_default_clone_dir() -> String {
.or_else(|_| std::env::var("HOME"))
.unwrap_or_else(|_| ".".to_string());
#[cfg(not(windows))]
let home = std::env::var("HOME")
.unwrap_or_else(|_| ".".to_string());
let home = std::env::var("HOME").unwrap_or_else(|_| ".".to_string());
std::path::PathBuf::from(home)
.join("GitmunProjects")
.to_string_lossy()
Expand Down Expand Up @@ -552,6 +557,39 @@ pub fn open_working_tree_diff(
.map_err(|error| error.to_string())
}

#[tauri::command]
pub fn check_patch_file(
request: ImportPatchRequest,
state: tauri::State<'_, AppState>,
) -> Result<OperationResult, String> {
state
.git_service
.check_patch_file(request)
.map_err(|error| error.to_string())
}

#[tauri::command]
pub fn import_patch_file(
request: ImportPatchRequest,
state: tauri::State<'_, AppState>,
) -> Result<OperationResult, String> {
state
.git_service
.import_patch_file(request)
.map_err(|error| error.to_string())
}

#[tauri::command]
pub fn export_patch_file(
request: ExportPatchRequest,
state: tauri::State<'_, AppState>,
) -> Result<OperationResult, String> {
state
.git_service
.export_patch_file(request)
.map_err(|error| error.to_string())
}

#[tauri::command]
pub fn get_repo_diff_tool(
request: RepoRequest,
Expand Down Expand Up @@ -651,10 +689,7 @@ pub fn commit_changes(
}

#[tauri::command]
pub async fn get_diff(
request: DiffRequest,
app: tauri::AppHandle,
) -> Result<FileDiff, String> {
pub async fn get_diff(request: DiffRequest, app: tauri::AppHandle) -> Result<FileDiff, String> {
tauri::async_runtime::spawn_blocking(move || {
app.state::<AppState>().git_service.get_diff(request)
})
Expand Down
Loading
Loading