summaryrefslogtreecommitdiffstats
path: root/src/git.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/git.rs')
-rw-r--r--src/git.rs42
1 files changed, 1 insertions, 41 deletions
diff --git a/src/git.rs b/src/git.rs
index a0e6489..5ee41dd 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -28,7 +28,7 @@ fn ok(out: Output, args: &[&str]) -> Result<String> {
Ok(String::from_utf8_lossy(&out.stdout).to_string())
}
-pub fn git_ok(cwd: Option<&Path>, args: &[&str]) -> bool {
+fn git_ok(cwd: Option<&Path>, args: &[&str]) -> bool {
git(cwd, args).is_ok()
}
@@ -47,18 +47,6 @@ pub fn ls_remote_head(url: &str) -> Result<Option<String>> {
}
}
-pub fn ls_remote_heads(url: &str) -> Result<Vec<(String, String)>> {
- let out = git(None, &["ls-remote", "--heads", url])?;
- let mut v = Vec::new();
- for line in out.lines() {
- let mut it = line.split_whitespace();
- if let (Some(sha), Some(name)) = (it.next(), it.next()) {
- v.push((name.to_string(), sha.to_string()));
- }
- }
- Ok(v)
-}
-
pub fn ls_remote_ref(url: &str, refname: &str) -> Result<Option<String>> {
match git(None, &["ls-remote", url, refname]) {
Ok(out) => Ok(out
@@ -239,40 +227,12 @@ pub fn materialize(mirror: &Path, commit: &str, dest: &Path) -> Result<()> {
Ok(())
}
-pub fn log_oneline(mirror: &Path, range: &str) -> Result<Vec<String>> {
- let out = git(Some(mirror), &["log", "--oneline", range])?;
- Ok(out.lines().map(|l| l.to_string()).collect())
-}
-
pub fn diff(mirror: &Path, range: &str, paths: &[&str]) -> Result<String> {
let mut args: Vec<&str> = vec!["diff", "--no-color", range, "--"];
args.extend(paths);
git(Some(mirror), &args)
}
-pub fn count_commits(mirror: &Path, range: &str) -> Result<usize> {
- let out = git(Some(mirror), &["rev-list", "--count", range])?;
- Ok(out.trim().parse().unwrap_or(0))
-}
-
-pub fn clone_source(url: &str, dest: &Path, depth: Option<usize>, branch: Option<&str>) -> Result<()> {
- if let Some(parent) = dest.parent() {
- std::fs::create_dir_all(parent)?;
- }
- let mut args: Vec<String> = vec!["clone".into(), "--quiet".into()];
- if let Some(d) = depth {
- args.push(format!("--depth={d}"));
- }
- if let Some(b) = branch {
- args.push(format!("--branch={b}"));
- }
- args.push(url.to_string());
- args.push(dest.display().to_string());
- let refs: Vec<&str> = args.iter().map(|s| s.as_str()).collect();
- git(None, &refs)?;
- Ok(())
-}
-
pub fn fetch_and_head(repo: &Path) -> Result<String> {
git(Some(repo), &["fetch", "--quiet", "--no-prune", "origin"])?;
head(repo)