From patchwork Fri Jul 20 11:57:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell Currey X-Patchwork-Id: 946844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41X8Xj2tXNz9s7c for ; Fri, 20 Jul 2018 21:58:13 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=russell.cc Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="IcC0IXNV"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41X8Xj0xGCzDqCs for ; Fri, 20 Jul 2018 21:58:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=russell.cc Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="IcC0IXNV"; dkim-atps=neutral X-Original-To: snowpatch@lists.ozlabs.org Delivered-To: snowpatch@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=russell.cc (client-ip=64.147.123.21; helo=wout5-smtp.messagingengine.com; envelope-from=ruscur@russell.cc; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=russell.cc Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="IcC0IXNV"; dkim-atps=neutral Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41X8XV3pRPzDqCM for ; Fri, 20 Jul 2018 21:58:01 +1000 (AEST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 457A63B2; Fri, 20 Jul 2018 07:57:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 20 Jul 2018 07:57:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=3e2//na2jc/aL0lQccI7s/Tv38wfEEWhLg8KmNWu2b0=; b=IcC0IXNV 66SVBq0qSrYNHGGm1wBAWfyhq/uVVmtIHzYl4UHuXvF3Qj6fPHmce0WCGCQgNjOr g9ky4uo/3ORHbE0J91GiiZgBmhlHzPWBGrbLKf0nx7jjPadtVl/JeVfzqBOnHZjp Zu914vjpjayKLhSw3ytxTAyd2dInFIVzOhMue8Fwy6IFt8hvkM9q9QtktNyskssw sOW4OdBJ1XtcvG5RRykRImuF9WpvrwCN91/YKD9e+DazVsz6QxjjAur0tP9zRGPE wUaYg4AOkWokMadCKr0VL3VpZfUGHk/TRbvgnDwOamRjSUqrnvirYqwWtAn0vGfh +iDik1V4zLPD5g== X-ME-Proxy: X-ME-Sender: Received: from snap.ozlabs.ibm.com (unknown [122.99.82.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 4037E1026A; Fri, 20 Jul 2018 07:57:55 -0400 (EDT) From: Russell Currey To: snowpatch@lists.ozlabs.org, andrew.donnellan@au1.ibm.com Date: Fri, 20 Jul 2018 21:57:23 +1000 Message-Id: <20180720115728.19312-3-ruscur@russell.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180720115728.19312-1-ruscur@russell.cc> References: <20180720115728.19312-1-ruscur@russell.cc> Subject: [snowpatch] [PATCH 3/8] Delete remote branch after tests are done X-BeenThere: snowpatch@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Continuous Integration for patch-based workflows List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell Currey MIME-Version: 1.0 Errors-To: snowpatch-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "snowpatch" This left a bunch of unused remote branches up, which makes everything slower because there's a bunch of git objects, so fix that. This led to a little cleanup of the push function. Signed-off-by: Russell Currey Reviewed-by: Andrew Donnellan --- src/git.rs | 13 ++++++++++--- src/main.rs | 5 ++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/git.rs b/src/git.rs index bc93009..d025d03 100644 --- a/src/git.rs +++ b/src/git.rs @@ -15,7 +15,7 @@ // use git2::build::CheckoutBuilder; -use git2::{Commit, Cred, Error, PushOptions, Remote, Repository}; +use git2::{Branch, Commit, Cred, Error, PushOptions, Remote, Repository}; use std::path::Path; use std::process::{Command, Output}; @@ -33,10 +33,17 @@ pub fn get_latest_commit(repo: &Repository) -> Commit { pub fn push_to_remote( remote: &mut Remote, - branch: &str, + branch: &Branch, + delete: bool, mut opts: &mut PushOptions, ) -> Result<(), Error> { - let refspecs: &[&str] = &[&format!("+{}/{}", GIT_REF_BASE, branch)]; + let action = if delete { ":" } else { "+" }; + let refspecs: &[&str] = &[&format!( + "{}{}/{}", + action, + GIT_REF_BASE, + branch.name().unwrap().unwrap() + )]; remote.push(refspecs, Some(&mut opts)) } diff --git a/src/main.rs b/src/main.rs index 5bf6187..027ceae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -205,7 +205,7 @@ fn test_patch( let output = git::apply_patch(&repo, path); if output.is_ok() { - git::push_to_remote(&mut remote, &tag, &mut push_opts).unwrap(); + git::push_to_remote(&mut remote, &branch, false, &mut push_opts).unwrap(); } git::checkout_branch(&repo, &branch_name); @@ -270,6 +270,9 @@ fn test_patch( .unwrap(); results.append(&mut test.join().unwrap()); + // Delete the remote branch now it's not needed any more + git::push_to_remote(&mut remote, &branch, true, &mut push_opts).unwrap(); + if !test_all_branches { break; }