Skip to content

Commit

Permalink
formatting and updating rust
Browse files Browse the repository at this point in the history
  • Loading branch information
perryqh committed Dec 18, 2024
1 parent d99b1ca commit 3aa18b1
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.77.2"
channel = "1.83.0"
components = ["clippy", "rustfmt"]
targets = ["x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu"]
2 changes: 2 additions & 0 deletions src/packs/caching/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ pub enum CacheResult {

#[derive(Debug, Default)]
pub struct EmptyCacheEntry {
#[allow(dead_code)]
pub filepath: PathBuf,
pub file_contents_digest: String,
#[allow(dead_code)]
pub file_name_digest: String,
pub cache_file_path: PathBuf,
}
Expand Down
9 changes: 6 additions & 3 deletions src/packs/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ mod tests {

assert!(!actual.cache_enabled);

let expected_readme_template_path = absolute_root.join("README_TEMPLATE.md");
let expected_readme_template_path =
absolute_root.join("README_TEMPLATE.md");
assert_eq!(actual.readme_template_path, expected_readme_template_path);
}

Expand Down Expand Up @@ -470,11 +471,13 @@ mod tests {

#[test]
fn with_readme_template_path() {
let absolute_root = PathBuf::from("tests/fixtures/app_with_custom_readme");
let absolute_root =
PathBuf::from("tests/fixtures/app_with_custom_readme");
let actual = configuration::get(&absolute_root).unwrap();

let actual_readme_template_path = actual.readme_template_path;
let expected_readme_template_path = absolute_root.join("config/packs/README_EXAMPLE.md");
let expected_readme_template_path =
absolute_root.join("config/packs/README_EXAMPLE.md");
assert_eq!(actual_readme_template_path, expected_readme_template_path);
}
}
6 changes: 2 additions & 4 deletions src/packs/creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn create(
fn readme(configuration: &Configuration, pack_name: &str) -> String {
let readme_template_path = configuration.readme_template_path.clone();

let readme_template = if readme_template_path.exists() {
if readme_template_path.exists() {
std::fs::read_to_string(readme_template_path).unwrap()
} else {
format!(
Expand All @@ -83,9 +83,7 @@ README.md should change as your public API changes.
See https://github.com/rubyatscale/pks#readme for more info!",
pack_name
)
};

readme_template
}
}

fn is_rails(configuration: &Configuration) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/packs/pack_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ impl PackSet {
pub fn all_pack_dependencies<'a>(
&'a self,
configuration: &'a Configuration,
) -> Result<Vec<PackDependency>> {
let mut pack_refs: Vec<PackDependency> = Vec::new();
) -> Result<Vec<PackDependency<'a>>> {
let mut pack_refs: Vec<PackDependency<'a>> = Vec::new();
for from_pack in &configuration.pack_set.packs {
for dependency_pack_name in &from_pack.dependencies {
match configuration.pack_set.for_pack(dependency_pack_name) {
Expand Down
2 changes: 1 addition & 1 deletion src/packs/parsing/ruby/experimental/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct ReferenceCollector<'a> {
pub custom_associations: Vec<String>,
}

impl<'a> Visitor for ReferenceCollector<'a> {
impl Visitor for ReferenceCollector<'_> {
fn on_class(&mut self, node: &nodes::Class) {
// We're not collecting definitions, so no need to visit the class definitioname);
let namespace_result = fetch_const_name(&node.name);
Expand Down
2 changes: 1 addition & 1 deletion src/packs/parsing/ruby/packwerk/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct ReferenceCollector<'a> {
pub custom_associations: Vec<String>,
}

impl<'a> Visitor for ReferenceCollector<'a> {
impl Visitor for ReferenceCollector<'_> {
fn on_class(&mut self, node: &nodes::Class) {
// We're not collecting definitions, so no need to visit the class definitioname);
let namespace_result = fetch_const_name(&node.name);
Expand Down
6 changes: 4 additions & 2 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ pub fn delete_foobar() {

#[allow(dead_code)]
pub fn delete_foobaz() {
let directory = PathBuf::from("tests/fixtures/simple_packs_first_app/packs/foobaz");
let directory =
PathBuf::from("tests/fixtures/simple_packs_first_app/packs/foobaz");
if let Err(err) = fs::remove_dir_all(directory) {
eprintln!(
"Failed to remove tests/fixtures/simple_packs_first_app/packs/foobaz during test teardown: {}",
Expand All @@ -44,7 +45,8 @@ pub fn delete_foobaz() {

#[allow(dead_code)]
pub fn delete_foobar_app_with_custom_readme() {
let directory = PathBuf::from("tests/fixtures/app_with_custom_readme/packs/foobar");
let directory =
PathBuf::from("tests/fixtures/app_with_custom_readme/packs/foobar");
if let Err(err) = fs::remove_dir_all(directory) {
eprintln!(
"Failed to remove tests/fixtures/app_with_custom_readme/packs/foobar during test teardown: {}",
Expand Down
15 changes: 11 additions & 4 deletions tests/create_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ See https://github.com/rubyatscale/pks#readme for more info!");
}

#[test]
fn test_create_with_readme_template_default_path() -> Result<(), Box<dyn Error>> {
fn test_create_with_readme_template_default_path() -> Result<(), Box<dyn Error>>
{
common::delete_foobaz();

fs::write("tests/fixtures/simple_packs_first_app/README_TEMPLATE.md", "This is a test custom README template")?;
fs::write(
"tests/fixtures/simple_packs_first_app/README_TEMPLATE.md",
"This is a test custom README template",
)?;

Command::cargo_bin("pks")?
.arg("--project-root")
Expand All @@ -90,13 +94,16 @@ fn test_create_with_readme_template_default_path() -> Result<(), Box<dyn Error>>

common::teardown();
common::delete_foobaz();
fs::remove_file("tests/fixtures/simple_packs_first_app/README_TEMPLATE.md")?;
fs::remove_file(
"tests/fixtures/simple_packs_first_app/README_TEMPLATE.md",
)?;

Ok(())
}

#[test]
fn test_create_with_readme_template_custom_path() -> Result<(), Box<dyn Error>> {
fn test_create_with_readme_template_custom_path() -> Result<(), Box<dyn Error>>
{
common::delete_foobar_app_with_custom_readme();

Command::cargo_bin("pks")?
Expand Down

0 comments on commit 3aa18b1

Please sign in to comment.