mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-10 03:30:59 +00:00
Remove dead is_tracked function from git module
No longer used after resolve_file_ref stopped checking git tracking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8f929a855c
commit
252453c81b
1 changed files with 0 additions and 56 deletions
|
|
@ -302,18 +302,6 @@ pub fn push_ref(repo: &Path, url: &str, refname: &str) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Check whether a file is tracked by git in the given repo.
|
||||
/// Returns `false` if the file is untracked or git is unavailable.
|
||||
pub fn is_tracked(repo: &Path, file: &Path) -> bool {
|
||||
git_cmd(repo)
|
||||
.args(["ls-files", "--error-unmatch"])
|
||||
.arg(file)
|
||||
.stdout(std::process::Stdio::null())
|
||||
.stderr(std::process::Stdio::null())
|
||||
.status()
|
||||
.is_ok_and(|s| s.success())
|
||||
}
|
||||
|
||||
/// Sanitize a string for use as a git ref component.
|
||||
/// Lowercases, replaces non-alphanumeric chars with dashes, collapses runs.
|
||||
pub fn sanitize_ref_component(s: &str) -> String {
|
||||
|
|
@ -1206,48 +1194,4 @@ mod tests {
|
|||
"remote should have test-push branch"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_tracked_returns_true_for_committed_file() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
init_repo(dir.path());
|
||||
let file = dir.path().join("tracked.txt");
|
||||
fs::write(&file, "hello").unwrap();
|
||||
Command::new("git")
|
||||
.args(["add", "tracked.txt"])
|
||||
.current_dir(dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
Command::new("git")
|
||||
.args([
|
||||
"-c",
|
||||
"user.name=test",
|
||||
"-c",
|
||||
"user.email=test@test",
|
||||
"commit",
|
||||
"-m",
|
||||
"add file",
|
||||
])
|
||||
.current_dir(dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(is_tracked(dir.path(), &file));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_tracked_returns_false_for_untracked_file() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
init_repo(dir.path());
|
||||
let file = dir.path().join("untracked.txt");
|
||||
fs::write(&file, "hello").unwrap();
|
||||
assert!(!is_tracked(dir.path(), &file));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_tracked_returns_false_for_non_repo_dir() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let file = dir.path().join("some.txt");
|
||||
fs::write(&file, "hello").unwrap();
|
||||
assert!(!is_tracked(dir.path(), &file));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue