Skip to content

Commit

Permalink
clippy and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlan404 committed Dec 22, 2023
1 parent d4bd99c commit baf3267
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 87 deletions.
2 changes: 1 addition & 1 deletion src/commands/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::app::App;

mod docker;
mod gitignore;
mod workflow_test;
mod workflow_packwiz;
mod workflow_test;

#[derive(clap::Subcommand, Clone, Copy)]
pub enum Commands {
Expand Down
8 changes: 5 additions & 3 deletions src/commands/env/workflow_packwiz.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use std::{path::Path, io::Write};
use std::{io::Write, path::Path};

use anyhow::Result;
use std::fs::File;

use crate::{util::env::get_git_root, app::App};
use crate::{app::App, util::env::get_git_root};

pub fn run(app: &App) -> Result<()> {
let path = Path::new(&get_git_root()?.unwrap_or(".".to_owned())).join(".github").join("workflows");
let path = Path::new(&get_git_root()?.unwrap_or(".".to_owned()))
.join(".github")
.join("workflows");

let mut f = File::create(path.join("packwiz.yml"))?;
f.write_all(include_bytes!("../../../res/workflows/packwiz.yml"))?;
Expand Down
8 changes: 5 additions & 3 deletions src/commands/env/workflow_test.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use std::{path::Path, io::Write};
use std::{io::Write, path::Path};

use anyhow::Result;
use std::fs::File;

use crate::{util::env::get_git_root, app::App};
use crate::{app::App, util::env::get_git_root};

pub fn run(app: &App) -> Result<()> {
let path = Path::new(&get_git_root()?.unwrap_or(".".to_owned())).join(".github").join("workflows");
let path = Path::new(&get_git_root()?.unwrap_or(".".to_owned()))
.join(".github")
.join("workflows");

let mut f = File::create(path.join("test.yml"))?;
f.write_all(include_bytes!("../../../res/workflows/test.yml"))?;
Expand Down
1 change: 0 additions & 1 deletion src/sources/modrinth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ pub struct ModrinthFile {
// file_type omitted
}


#[async_trait]
pub trait ModrinthWaitRatelimit<T> {
async fn wait_ratelimit(self) -> Result<T>;
Expand Down
29 changes: 14 additions & 15 deletions src/sources/vanilla.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use anyhow::{anyhow, Result, Context};
use anyhow::{anyhow, Context, Result};

use crate::app::{App, CacheStrategy, ResolvedFile};

Expand All @@ -17,23 +17,22 @@ impl<'a> VanillaAPI<'a> {
}

pub async fn resolve_source(&self, version: &str) -> Result<ResolvedFile> {
let version_manifest = mcapi::vanilla::fetch_version_manifest(&self.0.http_client).await
let version_manifest = mcapi::vanilla::fetch_version_manifest(&self.0.http_client)
.await
.context("Fetching version manifest")?;

let version = match version {
"latest" => {
version_manifest
.fetch_latest_release(&self.0.http_client)
.await
.context("Fetching latest release")?
}
"latest-snapshot" => {
version_manifest
.fetch_latest_snapshot(&self.0.http_client)
.await
.context("Fetching latest snapshot")?
}
id => version_manifest.fetch(id, &self.0.http_client).await
"latest" => version_manifest
.fetch_latest_release(&self.0.http_client)
.await
.context("Fetching latest release")?,
"latest-snapshot" => version_manifest
.fetch_latest_snapshot(&self.0.http_client)
.await
.context("Fetching latest snapshot")?,
id => version_manifest
.fetch(id, &self.0.http_client)
.await
.context(format!("Fetching release {id}"))?,
};

Expand Down
4 changes: 2 additions & 2 deletions src/util/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use std::{
use anyhow::{anyhow, Result};
use pathdiff::diff_paths;

pub fn try_get_url(folder: &PathBuf) -> Result<String> {
pub fn try_get_url(folder: &Path) -> Result<String> {
let repo_url = get_git_remote()?.ok_or(anyhow!("cant get repo url"))?;
let root = get_git_root()?.ok_or(anyhow!("cant get repo root"))?;
let branch = get_git_branch()?.ok_or(anyhow!("cant get repo branch"))?;

let root_path = Path::new(&root).canonicalize()?;

let diff = diff_paths(folder.canonicalize()?, &root_path).ok_or(anyhow!("cant diff paths"))?;
let diff = diff_paths(folder.canonicalize()?, root_path).ok_or(anyhow!("cant diff paths"))?;

let repo = if repo_url.starts_with("https") {
repo_url.strip_prefix("https://github.com/")
Expand Down
61 changes: 0 additions & 61 deletions src/util/logger.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use anyhow::Result;
use regex::Regex;

pub mod env;
pub mod logger;
pub mod maven_import;
pub mod md;

Expand Down

0 comments on commit baf3267

Please sign in to comment.