Skip to content
443 changes: 405 additions & 38 deletions src/diff_view.rs

Large diffs are not rendered by default.

153 changes: 153 additions & 0 deletions src/i18n_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2193,12 +2193,165 @@ pub const ID: &[(&str, &str)] = &[
("Inline", "Sebaris"),
("Full file", "Seluruh file"),
("Changes only", "Perubahan saja"),
("Checking for a Git repository…", "Memeriksa repository Git…"),
("Commit the staged changes (Enter)", "Commit perubahan yang sudah di-stage (Enter)"),
("Discard All", "Buang Semua"),
("Discard {n} files in {group}?", "Buang {n} file di {group}?"),
("Merge Conflicts", "Konflik Merge"),
(
"Remove these files from the index and working tree.",
"Hapus file ini dari index dan working tree.",
),
(
"Restore the index and working tree to the last commit.",
"Pulihkan index dan working tree ke commit terakhir.",
),
(
"Restore the original merge conflict in the working tree.",
"Pulihkan konflik merge semula di working tree.",
),
(
"Restore the working tree from the index.",
"Pulihkan working tree dari index.",
),
("Running Git…", "Menjalankan Git…"),
(
"Save or close the modified editor before discarding.",
"Simpan atau tutup editor yang sudah diubah sebelum membuang.",
),
("Show {n} more files", "Tampilkan {n} file lainnya"),
(
"Switch to a branch before pushing or syncing.",
"Pindah ke branch sebelum push atau sync.",
),
("Untracked Files", "File Untracked"),
("Untracked files will be deleted.", "File untracked akan dihapus."),
("Previous change", "Perubahan sebelumnya"),
("Next change", "Perubahan berikutnya"),
(
"No textual changes to compare (binary file or unchanged content).",
"Tidak ada perubahan teks untuk dibandingkan (file biner atau isinya sama).",
),
("Commit", "Commit"),
("Commit All", "Commit Semua"),
("Commit (Sign Off)", "Commit (Sign Off)"),
("Stage everything and commit", "Stage semua dan commit"),
("Enter a commit message.", "Masukkan pesan commit."),
(
"Resolve the merge conflicts before committing.",
"Selesaikan konflik merge sebelum commit.",
),
("There is no commit to amend.", "Tidak ada commit untuk di-amend."),
(
"Stage changes or enter a new commit message to amend.",
"Stage perubahan atau masukkan pesan commit baru untuk amend.",
),
("Stage changes before committing.", "Stage perubahan sebelum commit."),
("There are no changes to commit.", "Tidak ada perubahan untuk di-commit."),
("Index", "Index"),
("Conflict", "Konflik"),
("Working Tree", "Working Tree"),
("List", "Daftar"),
("View as List", "Lihat sebagai Daftar"),
("View as Tree", "Lihat sebagai Pohon"),
("No commits yet.", "Belum ada commit."),
("View full diff", "Lihat diff penuh"),
("No changed files.", "Tidak ada file berubah."),
("No changes.", "Tidak ada perubahan."),
("Publish Branch", "Publikasikan Branch"),
("Upstream unavailable", "Upstream tidak tersedia"),
("Hunk {n}/{total}", "Hunk {n}/{total}"),
("Previous hunk", "Hunk sebelumnya"),
("Next hunk", "Hunk berikutnya"),
("Hunk updated.", "Hunk diperbarui."),
("Stage Hunk", "Stage Hunk"),
("Unstage Hunk", "Unstage Hunk"),
("Save Resolution", "Simpan Resolusi"),
(
"Choose a resolution for every conflict first.",
"Pilih resolusi untuk setiap konflik dulu.",
),
(
"Conflict resolution saved and staged.",
"Resolusi konflik disimpan dan di-stage.",
),
(
"Save unsaved editors before changing Git branches or files.",
"Simpan editor yang belum tersimpan sebelum mengganti branch atau file Git.",
),
("The diff is too large to preview.", "Diff terlalu besar untuk ditampilkan."),
(
"Git helper failed. Refresh to check the result: {error}",
"Helper Git gagal. Refresh untuk memeriksa hasilnya: {error}",
),
(
"The untracked file is too large to preview.",
"File untracked terlalu besar untuk ditampilkan.",
),
(
"The diff changed. Reopen it before staging or unstaging a hunk.",
"Diff berubah. Buka ulang sebelum stage atau unstage hunk.",
),
(
"The conflict changed. Reopen it before saving the resolution.",
"Konflik berubah. Buka ulang sebelum menyimpan resolusi.",
),
(
"Conflict resolution was saved, but staging failed: {error}",
"Resolusi konflik sudah disimpan, tetapi gagal di-stage: {error}",
),
(
"The selected files changed. Review Source Control and try again.",
"File terpilih berubah. Periksa Source Control lalu coba lagi.",
),
(
"Discard untracked files individually inside nested repositories.",
"Buang file untracked satu per satu di dalam repositori bersarang.",
),
(
"Discard or stage the working tree changes to these files first.",
"Buang atau stage perubahan working tree pada file ini dulu.",
),
(
"Configure Git user.name and user.email before committing.",
"Atur user.name dan user.email Git sebelum commit.",
),
(
"The remote branch has new commits. Pull or Sync before pushing again.",
"Branch remote punya commit baru. Pull atau Sync sebelum push lagi.",
),
(
"Check Git credentials or your SSH connection in a terminal, then retry.",
"Periksa kredensial Git atau koneksi SSH di terminal, lalu coba lagi.",
),
(
"No Git remote is configured. Add a remote before fetching, pulling, or pushing.",
"Belum ada remote Git terpasang. Tambahkan remote sebelum fetch, pull, atau push.",
),
(
"Switch to a branch before pulling, pushing, or syncing.",
"Pindah ke sebuah branch sebelum pull, push, atau sync.",
),
(
"Resolve and finish the merge, or abort it before using the remote.",
"Selesaikan dan akhiri merge, atau batalkan sebelum menggunakan remote.",
),
(
"This branch has no upstream. Set one or publish the branch before pulling.",
"Branch ini belum punya upstream. Atur upstream atau publikasikan branch sebelum pull.",
),
(
"Pull left unresolved conflicts. Resolve them before continuing.",
"Pull meninggalkan konflik yang belum selesai. Selesaikan dulu sebelum lanjut.",
),
(
"Create a commit before publishing this branch.",
"Buat commit sebelum mempublikasikan branch ini.",
),
(
"No origin remote is configured. Set the branch upstream before pushing.",
"Remote origin belum diatur. Atur upstream branch sebelum push.",
),
("Fetching preview…", "Memuat pratinjau…"),
("Copy link", "Salin tautan"),
("Open link", "Buka tautan"),
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mod remote;
mod scene;
mod scene_art;
mod scm;
mod scm_git;
mod scm_incoming;
mod search;
mod settings;
Expand Down
93 changes: 88 additions & 5 deletions src/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ fn mono_kind(k: LineKind) -> bool {
| LineKind::Dim
| LineKind::Success
| LineKind::Frame
| LineKind::Hunk
| LineKind::Code
| LineKind::Caret
| LineKind::Blank
Expand All @@ -286,7 +285,7 @@ pub(crate) struct Problem {
pub message: String,
}

fn same_path(a: &Path, b: &Path) -> bool {
pub(crate) fn same_path(a: &Path, b: &Path) -> bool {
let n = |p: &Path| {
p.to_string_lossy()
.replace('/', "\\")
Expand All @@ -300,6 +299,65 @@ fn same_path(a: &Path, b: &Path) -> bool {
}
}

fn clean_path_parts(path: &Path) -> Vec<String> {
let raw = path.to_string_lossy();
let trimmed = if cfg!(windows) {
if let Some(unc) = raw.strip_prefix(r"\\?\UNC\") {
format!(r"\\{unc}")
} else {
raw.strip_prefix(r"\\?\").unwrap_or(&raw).to_string()
}
} else {
raw.into_owned()
};
let unified = trimmed.replace('\\', "/");
unified
.split('/')
.filter(|part| !part.is_empty() && *part != ".")
.map(|part| {
if cfg!(windows) {
part.to_ascii_lowercase()
} else {
part.to_string()
}
})
.collect()
}

pub(crate) fn repo_rel_path(repo: &Path, path: &Path) -> Option<String> {
let base = clean_path_parts(repo);
let raw = path.to_string_lossy();
let trimmed = if cfg!(windows) {
if let Some(unc) = raw.strip_prefix(r"\\?\UNC\") {
format!(r"\\{unc}")
} else {
raw.strip_prefix(r"\\?\").unwrap_or(&raw).to_string()
}
} else {
raw.into_owned()
};
let unified = trimmed.replace('\\', "/");
let parts: Vec<&str> = unified
.split('/')
.filter(|part| !part.is_empty() && *part != ".")
.collect();
if base.is_empty() || parts.len() <= base.len() {
return None;
}
let matches = parts.iter().zip(&base).all(|(a, b)| {
if cfg!(windows) {
a.eq_ignore_ascii_case(b)
} else {
*a == b
}
});
matches.then(|| parts[base.len()..].join("/"))
}

pub(crate) fn path_in_repo(repo: &Path, path: &Path) -> bool {
same_path(repo, path) || repo_rel_path(repo, path).is_some()
}

impl Workbench {
pub(crate) fn on_toggle_panel(
&mut self,
Expand Down Expand Up @@ -1786,7 +1844,6 @@ impl Workbench {
let col = match k {
LineKind::Err | LineKind::Caret => theme::DANGER,
LineKind::Warn => theme::WARN,
LineKind::Hunk => theme::BLUE,
LineKind::Dim => theme::FG_DIM,
LineKind::Success => theme::GREEN,
LineKind::Code => theme::FG_STRONG,
Expand Down Expand Up @@ -1973,8 +2030,7 @@ impl Workbench {
| LineKind::Warn
| LineKind::Dim
| LineKind::Success
| LineKind::Frame
| LineKind::Hunk => (cols.mono, 2),
| LineKind::Frame => (cols.mono, 2),
LineKind::Code if !marked => (cols.mono, 2),
LineKind::CardMsg | LineKind::CardHint => (cols.card, 0),
LineKind::Result if l.err => (cols.result, 0),
Expand Down Expand Up @@ -3939,4 +3995,31 @@ mod tests {
));
let _ = std::fs::remove_dir_all(&tmp);
}

#[test]
fn repo_rel_path_handles_slashes_and_windows_unc_prefixes() {
let repo = Path::new(r"\\?\D:\App\Repo");
let file = Path::new("d:/app/repo/src/scm_git.rs");
if cfg!(windows) {
assert_eq!(
super::repo_rel_path(repo, file).as_deref(),
Some("src/scm_git.rs")
);
assert!(super::path_in_repo(repo, file));
assert!(!super::path_in_repo(
repo,
Path::new(r"D:\Other\src\scm_git.rs")
));
} else {
let u_repo = Path::new("/work/repo");
assert_eq!(
super::repo_rel_path(u_repo, Path::new("/work/repo/src/lib.rs")).as_deref(),
Some("src/lib.rs")
);
assert!(!super::path_in_repo(
u_repo,
Path::new("/work/repo2/src/lib.rs")
));
}
}
}
8 changes: 4 additions & 4 deletions src/remote/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

mod client;
#[cfg(test)]
mod e2e;
Expand All @@ -7,8 +6,9 @@ mod proto;
mod server;
mod wsl;

pub use client::{drop_client, note_ui_thread, set_helper_enabled, warm, with_client, RemoteClient};
pub use client::{drop_client, note_ui_thread, set_helper_enabled, warm, with_client};
pub use paths::WslTarget;
pub use proto::GitWire;
pub use server::serve;
pub use wsl::{available, distros, home_dir, list_dirs, program_command, program_command_env, shell_command};
pub use wsl::{
available, distros, home_dir, list_dirs, program_command, program_command_env, shell_command,
};
Loading
Loading