diff --git a/qlty-check/src/cache.rs b/qlty-check/src/cache.rs index c1fa6e116..7136f73e8 100644 --- a/qlty-check/src/cache.rs +++ b/qlty-check/src/cache.rs @@ -107,6 +107,7 @@ struct InvocationCacheKey { impl InvocationCacheKey { fn build(&self) -> HashDigest { let mut digest = HashDigest::new(); + if let Some(runtime) = &self.plugin.runtime { digest.add("plugin.runtime", &runtime.to_string()); } @@ -143,7 +144,7 @@ impl InvocationCacheKey { digest.add("plugin.download_type", download_type); } - for environment in &self.plugin.environment { + for environment in self.plugin.environment.iter().sorted() { if environment.list.is_empty() { digest.add( &format!("plugin.environment.{}", environment.name), @@ -189,10 +190,12 @@ impl InvocationCacheKey { &serde_yaml::to_string(output_category).unwrap(), ); } + digest.add( "plugin.driver.driver_type", &serde_yaml::to_string(&driver.driver_type).unwrap(), ); + digest.add("plugin.driver.batch", &driver.batch.to_string()); digest.add("plugin.driver.max_batch", &driver.max_batch.to_string()); @@ -211,6 +214,7 @@ impl InvocationCacheKey { "plugin.driver.target", &serde_yaml::to_string(&driver.target).unwrap(), ); + digest.add( "plugin.driver.invocation_directory_def", &serde_yaml::to_string(&driver.invocation_directory_def).unwrap(), @@ -239,11 +243,11 @@ impl InvocationCacheKey { digest.add("tool", &self.tool.directory()); digest.add("driver_name", &self.driver_name); - for config in self.configs.clone().iter() { + for config in self.configs.clone().iter().sorted() { digest.add(&config.path.to_string_lossy(), &config.contents); } - for (path, contents) in &self.affects_cache { + for (path, contents) in self.affects_cache.iter().sorted() { digest.add(&path.to_string_lossy(), contents); } @@ -261,7 +265,7 @@ impl IssuesCacheKey { ) -> Self { let mut cache_busters = HashMap::new(); - for affect_cache in affects_cache.iter() { + for affect_cache in affects_cache.iter().sorted() { let path = PathBuf::from(affect_cache); let contents = std::fs::read_to_string(&path).unwrap_or("".to_string()); cache_busters.insert(path, contents); @@ -282,8 +286,10 @@ impl IssuesCacheKey { pub fn finalize(&mut self, target: &Target) { self.digest.add("target_path", &target.path_string()); + self.digest .add("target_contents_size", &target.contents_size.to_string()); + self.digest.add( "target_content_modified", &target diff --git a/qlty-check/src/planner/config_files.rs b/qlty-check/src/planner/config_files.rs index 9e93a2396..bbcfb7497 100644 --- a/qlty-check/src/planner/config_files.rs +++ b/qlty-check/src/planner/config_files.rs @@ -16,6 +16,18 @@ pub struct PluginConfigFile { pub contents: String, } +impl Ord for PluginConfigFile { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.path.cmp(&other.path) + } +} + +impl PartialOrd for PluginConfigFile { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + impl PluginConfigFile { pub fn from_path(path: &Path) -> Result { let contents = fs::read_to_string(path) diff --git a/qlty-config/src/config/plugin.rs b/qlty-config/src/config/plugin.rs index c30c5bc32..5ef9aea25 100644 --- a/qlty-config/src/config/plugin.rs +++ b/qlty-config/src/config/plugin.rs @@ -389,7 +389,7 @@ impl std::fmt::Display for PackageFileCandidate { } } -#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Default)] +#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Default, Eq)] pub struct PluginEnvironment { #[serde(default)] pub name: String, @@ -401,6 +401,18 @@ pub struct PluginEnvironment { pub value: String, } +impl Ord for PluginEnvironment { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.name.cmp(&other.name) + } +} + +impl PartialOrd for PluginEnvironment { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + #[derive(Debug, Serialize, Deserialize, Copy, Clone, PartialEq, Eq, Hash, Default)] pub enum SuggestionMode { #[default]