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
5 changes: 5 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ windows = { version = "0.61.3", features = [
"Foundation_Collections",
"Services_Store",
"Win32_Foundation",
"Win32_System_Com",
"Win32_System_Com_StructuredStorage",
"Win32_System_Recovery",
"Win32_System_Variant",
"Win32_UI_Shell",
"Win32_UI_Shell_Common",
"Win32_UI_Shell_PropertiesSystem",
"Win32_UI_WindowsAndMessaging",
] }
windows-future = "0.2.1"
4 changes: 4 additions & 0 deletions src-tauri/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ commitMessageRecommendedLength = 72
# Whether to automatically push tags when pushing commits.
pushFollowTags = false

# Fetch remotes periodically while a repository window is focused.
# Use 0 to disable, or 5, 10, 30, or 60 minutes.
autoFetchIntervalMinutes = 0

# Whether to check for application updates on launch.
autoCheckForUpdatesOnLaunch = true

Expand Down
125 changes: 85 additions & 40 deletions src-tauri/src/commands/branches.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::AppState;
use crate::git::types::{
AddRemoteRequest, BranchInfo, BranchRequest, CreateBranchRequest, CreateTagRequest,
DeleteBranchRequest, DeleteRemoteBranchRequest, DeleteRemoteTagRequest, DeleteTagRequest,
OperationResult, PruneRemoteRequest, PushTagRequest, RemoteInfo, RemoveRemoteRequest,
RenameBranchRequest, RenameRemoteRequest, RepoRequest, SetBranchUpstreamRequest,
SetRemoteUrlRequest, TagInfo,
AddRemoteRequest, BranchInfo, BranchRequest, CommitProgressEvent, CreateBranchRequest,
CreateTagRequest, DeleteBranchRequest, DeleteRemoteBranchRequest, DeleteRemoteTagRequest,
DeleteTagRequest, GitHookAttemptResult, OperationResult, PruneRemoteRequest, PushTagRequest,
RemoteInfo, RemoveRemoteRequest, RenameBranchRequest, RenameRemoteRequest, RepoRequest,
SetBranchUpstreamRequest, SetRemoteUrlRequest, TagInfo,
};
use std::sync::Arc;
use tauri::Manager;

#[tauri::command]
Expand All @@ -22,14 +23,22 @@ pub async fn get_branches(
}

#[tauri::command]
pub fn switch_branch(
pub async fn switch_branch(
request: BranchRequest,
state: tauri::State<'_, AppState>,
) -> Result<OperationResult, String> {
state
.git_service
.switch_branch(request)
.map_err(|error| error.to_string())
on_progress: tauri::ipc::Channel<CommitProgressEvent>,
app: tauri::AppHandle,
) -> Result<GitHookAttemptResult<OperationResult>, String> {
tauri::async_runtime::spawn_blocking(move || {
app.state::<AppState>()
.git_service
.switch_branch_with_progress(
request,
Arc::new(move |event| drop(on_progress.send(event))),
)
})
.await
.map_err(|error| error.to_string())?
.map_err(|error| error.to_string())
}

#[tauri::command]
Expand All @@ -44,14 +53,22 @@ pub fn set_branch_upstream(
}

#[tauri::command]
pub fn create_branch(
pub async fn create_branch(
request: CreateBranchRequest,
state: tauri::State<'_, AppState>,
) -> Result<OperationResult, String> {
state
.git_service
.create_branch(request)
.map_err(|error| error.to_string())
on_progress: tauri::ipc::Channel<CommitProgressEvent>,
app: tauri::AppHandle,
) -> Result<GitHookAttemptResult<OperationResult>, String> {
tauri::async_runtime::spawn_blocking(move || {
app.state::<AppState>()
.git_service
.create_branch_with_progress(
request,
Arc::new(move |event| drop(on_progress.send(event))),
)
})
.await
.map_err(|error| error.to_string())?
.map_err(|error| error.to_string())
}

#[tauri::command]
Expand Down Expand Up @@ -109,36 +126,64 @@ pub fn create_tag(
}

#[tauri::command]
pub fn push_tag(
pub async fn push_tag(
request: PushTagRequest,
state: tauri::State<'_, AppState>,
) -> Result<OperationResult, String> {
state
.git_service
.push_tag(request)
.map_err(|e| e.to_string())
skip_hooks: bool,
on_progress: tauri::ipc::Channel<CommitProgressEvent>,
app: tauri::AppHandle,
) -> Result<GitHookAttemptResult<OperationResult>, String> {
tauri::async_runtime::spawn_blocking(move || {
app.state::<AppState>().git_service.push_tag_with_progress(
request,
skip_hooks,
Arc::new(move |event| drop(on_progress.send(event))),
)
})
.await
.map_err(|error| error.to_string())?
.map_err(|error| error.to_string())
}

#[tauri::command]
pub fn delete_remote_tag(
pub async fn delete_remote_tag(
request: DeleteRemoteTagRequest,
state: tauri::State<'_, AppState>,
) -> Result<OperationResult, String> {
state
.git_service
.delete_remote_tag(request)
.map_err(|error| error.to_string())
skip_hooks: bool,
on_progress: tauri::ipc::Channel<CommitProgressEvent>,
app: tauri::AppHandle,
) -> Result<GitHookAttemptResult<OperationResult>, String> {
tauri::async_runtime::spawn_blocking(move || {
app.state::<AppState>()
.git_service
.delete_remote_tag_with_progress(
request,
skip_hooks,
Arc::new(move |event| drop(on_progress.send(event))),
)
})
.await
.map_err(|error| error.to_string())?
.map_err(|error| error.to_string())
}

#[tauri::command]
pub fn delete_remote_branch(
pub async fn delete_remote_branch(
request: DeleteRemoteBranchRequest,
state: tauri::State<'_, AppState>,
) -> Result<OperationResult, String> {
state
.git_service
.delete_remote_branch(request)
.map_err(|error| error.to_string())
skip_hooks: bool,
on_progress: tauri::ipc::Channel<CommitProgressEvent>,
app: tauri::AppHandle,
) -> Result<GitHookAttemptResult<OperationResult>, String> {
tauri::async_runtime::spawn_blocking(move || {
app.state::<AppState>()
.git_service
.delete_remote_branch_with_progress(
request,
skip_hooks,
Arc::new(move |event| drop(on_progress.send(event))),
)
})
.await
.map_err(|error| error.to_string())?
.map_err(|error| error.to_string())
}

#[tauri::command]
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod branches;
pub mod history;
pub mod recent_repositories;
pub mod repo;
pub mod settings;
pub mod store_update;
Loading