{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).
This commit is contained in:
Cole Helbling 2020-04-08 14:55:07 -07:00
parent 83d748169c
commit db190207a2
No known key found for this signature in database
GPG key ID: B37E0F2371016A4C
2 changed files with 16 additions and 4 deletions

View file

@ -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 <commit> 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();

View file

@ -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<fs::File>,
@ -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();