diff --git a/Cargo.lock b/Cargo.lock index c794dca..95c476d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -326,27 +326,6 @@ dependencies = [ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "foxdie_actions 0.5.0", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "foxdie_actions" -version = "0.5.0" -dependencies = [ - "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "foxdie_services 0.5.0", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "foxdie_services" -version = "0.5.0" -dependencies = [ - "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 9f79026..8a5ac65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,5 @@ [workspace] members = [ "src/what_git", - "src/foxdie_services", - "src/foxdie_actions", "src/foxdie", ] diff --git a/README.md b/README.md index b798608..d9d8988 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # foxdie -_A super fast tool for taking stale branches and push requests and deleting and/or closing them_ +_A super-fast tool for taking stale branches and push requests and deleting and/or closing them_ [![Actions Status](https://github.com/wayfair/foxdie/workflows/CI/badge.svg?branch=master)](https://github.com/wayfair/foxdie/actions) diff --git a/src/foxdie/Cargo.toml b/src/foxdie/Cargo.toml index 4073d6e..e96a437 100644 --- a/src/foxdie/Cargo.toml +++ b/src/foxdie/Cargo.toml @@ -3,10 +3,21 @@ name = "foxdie" version = "0.5.0" authors = ["Aaron Sky "] edition = "2018" +description = "A super-fast tool for taking stale branches and push requests and deleting and/or closing them." +license = "BSD-2-Clause" +documentation = "https://docs.rs/foxdie" +homepage = "https://github.com/wayfair/foxdie" +repository = "https://github.com/wayfair/foxdie" [dependencies] +chrono = { version = "0.4", features = ["serde"] } clap = "2.33" -chrono = "0.4" env_logger = "0.6" +git2 = "0.9" +glob = "0.3" log = "0.4" -foxdie_actions = { version = "0.5.0", path = "../foxdie_actions" } +reqwest = "0.9" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +what_git = { version = "0.5.0", path = "../what_git" } +url = "1.7.2" diff --git a/src/foxdie_actions/src/actions/local.rs b/src/foxdie/src/actions/local.rs similarity index 96% rename from src/foxdie_actions/src/actions/local.rs rename to src/foxdie/src/actions/local.rs index 72cd450..f07eb33 100644 --- a/src/foxdie_actions/src/actions/local.rs +++ b/src/foxdie/src/actions/local.rs @@ -18,8 +18,10 @@ // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::error::FoxdieError; +use crate::services::{ + get_api_client_for_remote, git, ProtectedBranch, PushRequest, PushRequestState, +}; use chrono::{DateTime, FixedOffset}; -use foxdie_services::{get_api_client_for_remote, git, PushRequestState}; use log::{info, warn}; use std::env; use std::path::Path; @@ -99,8 +101,8 @@ fn is_branch_to_delete<'a>( current_branch: &'a git::Branch, since_date: &'a DateTime, repository: &'a git::Repository, - push_requests: &'a [foxdie_services::PushRequest], - protected_branches: &'a [foxdie_services::ProtectedBranch], + push_requests: &'a [PushRequest], + protected_branches: &'a [ProtectedBranch], ) -> impl FnMut(&git::Branch<'a>) -> bool { move |branch| { branch.name().into_iter().flatten().any(|branch_name| { diff --git a/src/foxdie_actions/src/actions/mod.rs b/src/foxdie/src/actions/mod.rs similarity index 100% rename from src/foxdie_actions/src/actions/mod.rs rename to src/foxdie/src/actions/mod.rs diff --git a/src/foxdie_actions/src/actions/push_requests.rs b/src/foxdie/src/actions/push_requests.rs similarity index 94% rename from src/foxdie_actions/src/actions/push_requests.rs rename to src/foxdie/src/actions/push_requests.rs index 17f8344..205dc76 100644 --- a/src/foxdie_actions/src/actions/push_requests.rs +++ b/src/foxdie/src/actions/push_requests.rs @@ -18,8 +18,8 @@ // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::error::FoxdieError; +use crate::services::{get_api_client_for_url, PushRequest, PushRequestState}; use chrono::{DateTime, FixedOffset}; -use foxdie_services::{get_api_client_for_url, PushRequestState}; use log::info; pub fn clean_push_requests( @@ -58,10 +58,7 @@ pub fn clean_push_requests( Ok(()) } -fn print_push_requests_to_close( - push_requests: &[foxdie_services::PushRequest], - all_push_requests_count: usize, -) { +fn print_push_requests_to_close(push_requests: &[PushRequest], all_push_requests_count: usize) { info!( "Found {} eligible push requests out of {} total{}", push_requests.len(), diff --git a/src/foxdie_actions/src/actions/report.rs b/src/foxdie/src/actions/report.rs similarity index 99% rename from src/foxdie_actions/src/actions/report.rs rename to src/foxdie/src/actions/report.rs index 44ec86d..98d01fa 100644 --- a/src/foxdie_actions/src/actions/report.rs +++ b/src/foxdie/src/actions/report.rs @@ -18,8 +18,8 @@ // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::error::FoxdieError; +use crate::services::{git, PushRequest}; use chrono::{DateTime, TimeZone, Utc}; -use foxdie_services::{git, PushRequest}; use log::info; use serde::Serialize; use serde_json; diff --git a/src/foxdie_actions/src/error.rs b/src/foxdie/src/error.rs similarity index 99% rename from src/foxdie_actions/src/error.rs rename to src/foxdie/src/error.rs index 4258471..ba96981 100644 --- a/src/foxdie_actions/src/error.rs +++ b/src/foxdie/src/error.rs @@ -17,7 +17,7 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use foxdie_services::git; +use crate::services::git; use reqwest; use serde_json; use std::error; diff --git a/src/foxdie/src/main.rs b/src/foxdie/src/main.rs index 225688f..51bcdc8 100644 --- a/src/foxdie/src/main.rs +++ b/src/foxdie/src/main.rs @@ -17,11 +17,13 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +mod actions; mod cli; +mod error; +mod services; use cli::{build_cli, parse_shared_arguments, SharedArguments}; use env_logger; -use foxdie_actions::actions; use log::{error, warn}; use std::env; use std::process; diff --git a/src/foxdie_services/src/git/mod.rs b/src/foxdie/src/services/git/mod.rs similarity index 100% rename from src/foxdie_services/src/git/mod.rs rename to src/foxdie/src/services/git/mod.rs diff --git a/src/foxdie_services/src/github/mod.rs b/src/foxdie/src/services/github/mod.rs similarity index 98% rename from src/foxdie_services/src/github/mod.rs rename to src/foxdie/src/services/github/mod.rs index 1493aea..a139951 100644 --- a/src/foxdie_services/src/github/mod.rs +++ b/src/foxdie/src/services/github/mod.rs @@ -20,7 +20,7 @@ mod v3; pub(self) use self::v3::*; -use crate::{PushRequest, PushRequestState, SCMProviderImpl}; +use super::{PushRequest, PushRequestState, SCMProviderImpl}; use log::debug; use reqwest::header; use reqwest::header::{HeaderMap, HeaderValue}; @@ -114,7 +114,7 @@ impl SCMProviderImpl for GitHub { .map(|_| ()) } - fn list_protected_branches(&self) -> ReqwestResult> { + fn list_protected_branches(&self) -> ReqwestResult> { let url = format!("{}/branches", self.construct_base_url()); let protected_branches: Vec = self .client diff --git a/src/foxdie_services/src/github/v3.rs b/src/foxdie/src/services/github/v3.rs similarity index 95% rename from src/foxdie_services/src/github/v3.rs rename to src/foxdie/src/services/github/v3.rs index c28bd51..c4622ba 100644 --- a/src/foxdie_services/src/github/v3.rs +++ b/src/foxdie/src/services/github/v3.rs @@ -17,7 +17,7 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use crate::PushRequest; +use super::PushRequest; use chrono::{DateTime, FixedOffset}; use glob::{Pattern, PatternError}; use serde::{Deserialize, Serialize}; @@ -87,9 +87,9 @@ pub struct ProtectedBranch { pub name: String, } -impl From for Result { +impl From for Result { fn from(branch: ProtectedBranch) -> Self { let pattern = Pattern::new(&branch.name)?; - Ok(crate::ProtectedBranch { pattern }) + Ok(super::super::ProtectedBranch { pattern }) } } diff --git a/src/foxdie_services/src/gitlab/mod.rs b/src/foxdie/src/services/gitlab/mod.rs similarity index 98% rename from src/foxdie_services/src/gitlab/mod.rs rename to src/foxdie/src/services/gitlab/mod.rs index 0df583f..cd05961 100644 --- a/src/foxdie_services/src/gitlab/mod.rs +++ b/src/foxdie/src/services/gitlab/mod.rs @@ -20,7 +20,7 @@ mod v4; pub(self) use self::v4::*; -use crate::{PushRequest, PushRequestState, SCMProviderImpl}; +use super::{PushRequest, PushRequestState, SCMProviderImpl}; use log::{debug, error}; use reqwest::header::{HeaderMap, HeaderValue}; use reqwest::Client; @@ -148,7 +148,7 @@ impl SCMProviderImpl for Gitlab { .map_err(Gitlab::handle_error) } - fn list_protected_branches(&self) -> ReqwestResult> { + fn list_protected_branches(&self) -> ReqwestResult> { let url = format!("{}/protected_branches", self.construct_base_url()); let protected_branches: Vec = self.client.get(&*url).send()?.json()?; Ok(protected_branches diff --git a/src/foxdie_services/src/gitlab/v4.rs b/src/foxdie/src/services/gitlab/v4.rs similarity index 95% rename from src/foxdie_services/src/gitlab/v4.rs rename to src/foxdie/src/services/gitlab/v4.rs index 2c83dbc..320dfee 100644 --- a/src/foxdie_services/src/gitlab/v4.rs +++ b/src/foxdie/src/services/gitlab/v4.rs @@ -17,7 +17,7 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use crate::PushRequest; +use super::PushRequest; use chrono::{DateTime, FixedOffset}; use glob::{Pattern, PatternError}; use serde::{Deserialize, Serialize}; @@ -107,9 +107,9 @@ pub struct ProtectedBranch { pub name: String, } -impl From for Result { +impl From for Result { fn from(branch: ProtectedBranch) -> Self { let pattern = Pattern::new(&branch.name)?; - Ok(crate::ProtectedBranch { pattern }) + Ok(super::super::ProtectedBranch { pattern }) } } diff --git a/src/foxdie_services/src/lib.rs b/src/foxdie/src/services/mod.rs similarity index 99% rename from src/foxdie_services/src/lib.rs rename to src/foxdie/src/services/mod.rs index 84f5a30..e645f07 100644 --- a/src/foxdie_services/src/lib.rs +++ b/src/foxdie/src/services/mod.rs @@ -111,6 +111,7 @@ impl SCMProvider { #[derive(Debug)] pub enum PushRequestState { Opened, + #[allow(dead_code)] Closed, } diff --git a/src/foxdie_actions/Cargo.toml b/src/foxdie_actions/Cargo.toml deleted file mode 100644 index 52ef90f..0000000 --- a/src/foxdie_actions/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "foxdie_actions" -version = "0.5.0" -authors = ["Aaron Sky "] -edition = "2018" -publish = false - -[lib] -name = "foxdie_actions" - -[dependencies] -chrono = { version = "0.4", features = ["serde"] } -log = "0.4" -reqwest = "0.9" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -foxdie_services = { version = "0.5.0", path = "../foxdie_services" } diff --git a/src/foxdie_actions/src/lib.rs b/src/foxdie_actions/src/lib.rs deleted file mode 100644 index 8ae0e21..0000000 --- a/src/foxdie_actions/src/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2018-2019, Wayfair LLC -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -// following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following -// disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the -// following disclaimer in the documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -pub mod actions; -pub mod error; diff --git a/src/foxdie_services/Cargo.toml b/src/foxdie_services/Cargo.toml deleted file mode 100644 index 2d0d522..0000000 --- a/src/foxdie_services/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "foxdie_services" -version = "0.5.0" -authors = ["Aaron Sky "] -edition = "2018" -publish = false - -[lib] -name = "foxdie_services" - -[dependencies] -chrono = { version = "0.4", features = ["serde"] } -git2 = "0.9" -glob = "0.3" -log = "0.4" -reqwest = "0.9" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -what_git = { version = "0.5.0", path = "../what_git" } -url = "1.7.2" diff --git a/src/what_git/Cargo.toml b/src/what_git/Cargo.toml index f97b80f..67cdc96 100644 --- a/src/what_git/Cargo.toml +++ b/src/what_git/Cargo.toml @@ -3,6 +3,12 @@ name = "what_git" version = "0.5.0" authors = ["Aaron Sky "] edition = "2018" +description = "A crate for determining which SCM your Git URL is associated with." +license = "BSD-2-Clause" +documentation = "https://docs.rs/what_git" +homepage = "https://github.com/wayfair/foxdie" +repository = "https://github.com/wayfair/foxdie" + [dependencies] reqwest = "0.9"