From db190207a246d0e00a5f6554b915b86ed08aba6e Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Wed, 8 Apr 2020 14:55:07 -0700 Subject: [PATCH] {checkout,clone}: redirect output to /dev/null It fills the logs with typically-useless information. We don't really care about the novels people write in their commit messages. The only `git` commands that were left unmodified are the ones where we use their output in some way (and thus, it isn't printed to stdout/err anyways). --- ofborg/src/checkout.rs | 9 +++++++-- ofborg/src/clone.rs | 11 +++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ofborg/src/checkout.rs b/ofborg/src/checkout.rs index a2e1510..10cd7de 100644 --- a/ofborg/src/checkout.rs +++ b/ofborg/src/checkout.rs @@ -4,7 +4,7 @@ use std::ffi::{OsStr, OsString}; use std::fs; use std::io::{Error, ErrorKind}; use std::path::{Path, PathBuf}; -use std::process::Command; +use std::process::{Command, Stdio}; pub struct CachedCloner { root: PathBuf, @@ -95,11 +95,13 @@ impl CachedProjectCo { pub fn fetch_pr(&self, pr_id: u64) -> Result<(), Error> { let mut lock = self.lock()?; + info!("Fetching PR #{}", pr_id); let result = Command::new("git") .arg("fetch") .arg("origin") .arg(format!("+refs/pull/{}/head:pr", pr_id)) .current_dir(self.clone_to()) + .stdout(Stdio::null()) .status()?; lock.unlock(); @@ -114,12 +116,13 @@ impl CachedProjectCo { pub fn commit_exists(&self, commit: &OsStr) -> bool { let mut lock = self.lock().expect("Failed to lock"); + info!("Checking if commit '{:?}' exists", commit); let result = Command::new("git") .arg("--no-pager") .arg("show") - .arg("--no-patch") .arg(commit) .current_dir(self.clone_to()) + .stdout(Stdio::null()) .status() .expect("git show failed"); @@ -131,6 +134,7 @@ impl CachedProjectCo { pub fn merge_commit(&self, commit: &OsStr) -> Result<(), Error> { let mut lock = self.lock()?; + info!("Merging commit '{:?}'", commit); let result = Command::new("git") .arg("merge") .arg("--no-gpg-sign") @@ -138,6 +142,7 @@ impl CachedProjectCo { .arg("Automatic merge for GrahamCOfBorg") .arg(commit) .current_dir(self.clone_to()) + .stdout(Stdio::null()) .status()?; lock.unlock(); diff --git a/ofborg/src/clone.rs b/ofborg/src/clone.rs index 8b762b0..cba44b6 100644 --- a/ofborg/src/clone.rs +++ b/ofborg/src/clone.rs @@ -4,7 +4,7 @@ use std::ffi::OsStr; use std::fs; use std::io::{Error, ErrorKind}; use std::path::PathBuf; -use std::process::Command; +use std::process::{Command, Stdio}; pub struct Lock { lock: Option, @@ -67,6 +67,7 @@ pub trait GitClonable { .args(self.extra_clone_args()) .arg(&self.clone_from()) .arg(&self.clone_to()) + .stdout(Stdio::null()) .status()?; lock.unlock(); @@ -93,6 +94,7 @@ pub trait GitClonable { .arg("fetch") .arg("origin") .current_dir(self.clone_to()) + .stdout(Stdio::null()) .status()?; lock.unlock(); @@ -112,6 +114,8 @@ pub trait GitClonable { .arg("am") .arg("--abort") .current_dir(self.clone_to()) + .stdout(Stdio::null()) + .stderr(Stdio::null()) .status()?; info!("git merge --abort"); @@ -119,6 +123,8 @@ pub trait GitClonable { .arg("merge") .arg("--abort") .current_dir(self.clone_to()) + .stdout(Stdio::null()) + .stderr(Stdio::null()) .status()?; info!("git reset --hard"); @@ -126,6 +132,7 @@ pub trait GitClonable { .arg("reset") .arg("--hard") .current_dir(self.clone_to()) + .stdout(Stdio::null()) .status()?; lock.unlock(); @@ -137,11 +144,11 @@ pub trait GitClonable { let mut lock = self.lock()?; debug!("git checkout {:?}", git_ref); - let result = Command::new("git") .arg("checkout") .arg(git_ref) .current_dir(self.clone_to()) + .stdout(Stdio::null()) .status()?; lock.unlock();