Skip to content
Open
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
16 changes: 16 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ open = "5"
regex = "1"
walkdir = "2"
tauri-plugin-single-instance = "2"
tauri-plugin-window-state = "2"
chrono = "0.4"
3 changes: 2 additions & 1 deletion src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dialog:allow-open",
"core:menu:default",
"clipboard-manager:allow-write-text",
"updater:default"
"updater:default",
"window-state:default"
]
}
70 changes: 50 additions & 20 deletions src-tauri/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct GitStatus {
pub has_upstream: bool, // Whether the current branch tracks an upstream
pub remote_url: Option<String>, // URL of the 'origin' remote
pub changed_count: usize,
pub ahead_count: i32, // -1 if no upstream tracking
pub ahead_count: i32, // -1 if no upstream tracking
pub behind_count: i32, // -1 if no upstream tracking
pub current_branch: Option<String>,
pub error: Option<String>,
Expand Down Expand Up @@ -97,13 +97,9 @@ pub fn get_status(path: &Path) -> GitStatus {
}

// Check for remote
if let Ok(output) = git_cmd()
.args(["remote"])
.current_dir(path)
.output()
{
status.has_remote = output.status.success()
&& !String::from_utf8_lossy(&output.stdout).trim().is_empty();
if let Ok(output) = git_cmd().args(["remote"]).current_dir(path).output() {
status.has_remote =
output.status.success() && !String::from_utf8_lossy(&output.stdout).trim().is_empty();

// Get remote URL if remote exists
if status.has_remote {
Expand Down Expand Up @@ -164,11 +160,7 @@ pub fn get_status(path: &Path) -> GitStatus {
/// Stage all changes and commit
pub fn commit_all(path: &Path, message: &str) -> GitResult {
// Stage all changes
let stage_output = match git_cmd()
.args(["add", "-A"])
.current_dir(path)
.output()
{
let stage_output = match git_cmd().args(["add", "-A"]).current_dir(path).output() {
Ok(output) => output,
Err(e) => {
return GitResult {
Expand All @@ -189,7 +181,11 @@ pub fn commit_all(path: &Path, message: &str) -> GitResult {
error: Some(format!(
"Failed to stage changes: {}{}",
stderr,
if stdout.is_empty() { String::new() } else { format!("\n{}", stdout) }
if stdout.is_empty() {
String::new()
} else {
format!("\n{}", stdout)
}
)),
};
}
Expand Down Expand Up @@ -237,7 +233,13 @@ pub fn commit_all(path: &Path, message: &str) -> GitResult {
/// Push to remote
pub fn push(path: &Path) -> GitResult {
let output = git_cmd()
.args(["-c", "http.lowSpeedLimit=1000", "-c", "http.lowSpeedTime=10", "push"])
.args([
"-c",
"http.lowSpeedLimit=1000",
"-c",
"http.lowSpeedTime=10",
"push",
])
.env("GIT_SSH_COMMAND", "ssh -o ConnectTimeout=10")
.current_dir(path)
.output();
Expand Down Expand Up @@ -269,7 +271,14 @@ pub fn push(path: &Path) -> GitResult {
/// Fetch from remote to update tracking refs
pub fn fetch(path: &Path) -> GitResult {
let output = git_cmd()
.args(["-c", "http.lowSpeedLimit=1000", "-c", "http.lowSpeedTime=10", "fetch", "--quiet"])
.args([
"-c",
"http.lowSpeedLimit=1000",
"-c",
"http.lowSpeedTime=10",
"fetch",
"--quiet",
])
.env("GIT_SSH_COMMAND", "ssh -o ConnectTimeout=10")
.current_dir(path)
.output();
Expand Down Expand Up @@ -301,7 +310,15 @@ pub fn fetch(path: &Path) -> GitResult {
/// Pull from remote
pub fn pull(path: &Path) -> GitResult {
let output = git_cmd()
.args(["-c", "http.lowSpeedLimit=1000", "-c", "http.lowSpeedTime=10", "-c", "pull.rebase=false", "pull"])
.args([
"-c",
"http.lowSpeedLimit=1000",
"-c",
"http.lowSpeedTime=10",
"-c",
"pull.rebase=false",
"pull",
])
.env("GIT_SSH_COMMAND", "ssh -o ConnectTimeout=10")
.current_dir(path)
.output();
Expand Down Expand Up @@ -360,7 +377,10 @@ pub fn add_remote(path: &Path, url: &str) -> GitResult {
return GitResult {
success: false,
message: None,
error: Some("Invalid remote URL format. URL must start with https://, http://, or git@".to_string()),
error: Some(
"Invalid remote URL format. URL must start with https://, http://, or git@"
.to_string(),
),
};
}

Expand Down Expand Up @@ -406,7 +426,16 @@ pub fn add_remote(path: &Path, url: &str) -> GitResult {
/// Push to remote and set upstream tracking (git push -u origin <branch>)
pub fn push_with_upstream(path: &Path, branch: &str) -> GitResult {
let output = git_cmd()
.args(["-c", "http.lowSpeedLimit=1000", "-c", "http.lowSpeedTime=10", "push", "-u", "origin", branch])
.args([
"-c",
"http.lowSpeedLimit=1000",
"-c",
"http.lowSpeedTime=10",
"push",
"-u",
"origin",
branch,
])
.env("GIT_SSH_COMMAND", "ssh -o ConnectTimeout=10")
.current_dir(path)
.output();
Expand Down Expand Up @@ -464,7 +493,8 @@ fn parse_pull_error(stderr: &str) -> String {
} else if stderr.contains("CONFLICT") || stderr.contains("Merge conflict") {
"Pull failed due to merge conflicts. Resolve conflicts manually.".to_string()
} else if stderr.contains("not possible to fast-forward") {
"Pull failed: local and remote have diverged. Try pulling with rebase or merging manually.".to_string()
"Pull failed: local and remote have diverged. Try pulling with rebase or merging manually."
.to_string()
} else if stderr.contains("unrelated histories") {
"Pull failed: repositories have unrelated histories. Merge them manually or re-run with --allow-unrelated-histories.".to_string()
} else {
Expand Down
Loading
Loading