Merge pull request #458 from cole-h/logging

{checkout,clone}: redirect output to /dev/null
This commit is contained in:
Graham Christensen 2020-04-09 17:23:20 -04:00 committed by GitHub
commit a095c36668
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 7 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();

View file

@ -544,13 +544,13 @@ pub fn update_labels(issueref: &hubcaps::issues::IssueRef, add: &[String], remov
info!(
"Labeling issue #{}: + {:?} , - {:?}, = {:?}",
issue.id, to_add, to_remove, existing
issue.number, to_add, to_remove, existing
);
l.add(to_add.clone()).unwrap_or_else(|e| {
panic!(
"Failed to add labels {:?} to issue #{}: {:?}",
to_add, issue.id, e
to_add, issue.number, e
)
});
@ -558,7 +558,7 @@ pub fn update_labels(issueref: &hubcaps::issues::IssueRef, add: &[String], remov
l.remove(&label).unwrap_or_else(|e| {
panic!(
"Failed to remove label {:?} from issue #{}: {:?}",
label, issue.id, e
label, issue.number, e
)
});
}