Skip to content

Commit a243265

Browse files
committed
greptile fix and clippy fix
1 parent c6b0d52 commit a243265

File tree

3 files changed

+37
-40
lines changed

3 files changed

+37
-40
lines changed

helix-cli/src/commands/integrations/helix.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'a> HelixManager<'a> {
8686
let cluster_id = "YOUR_CLUSTER_ID".to_string();
8787

8888
// Use provided region or default to us-east-1
89-
let region = region.or_else(|| Some("us-east-1".to_string()));
89+
let region = region.or(Some("us-east-1".to_string()));
9090

9191
Ok(CloudInstanceConfig {
9292
cluster_id,
@@ -168,7 +168,7 @@ impl<'a> HelixManager<'a> {
168168
build_mode_override: Option<BuildMode>,
169169
) -> Result<()> {
170170
let credentials = require_auth().await?;
171-
let path = match get_path_or_cwd(path.as_ref()) {
171+
let path = match get_path_or_cwd(path.as_deref()) {
172172
Ok(path) => path,
173173
Err(e) => {
174174
return Err(eyre!("Error: failed to get path: {e}"));
@@ -553,7 +553,7 @@ impl<'a> HelixManager<'a> {
553553
config: &crate::config::EnterpriseInstanceConfig,
554554
) -> Result<()> {
555555
let credentials = require_auth().await?;
556-
let path = match get_path_or_cwd(path.as_ref()) {
556+
let path = match get_path_or_cwd(path.as_deref()) {
557557
Ok(path) => path,
558558
Err(e) => {
559559
return Err(eyre!("Error: failed to get path: {e}"));
@@ -568,8 +568,7 @@ impl<'a> HelixManager<'a> {
568568
for entry in std::fs::read_dir(&queries_dir)? {
569569
let entry = entry?;
570570
let file_path = entry.path();
571-
if file_path.is_file() && file_path.extension().map(|e| e == "rs").unwrap_or(false)
572-
{
571+
if file_path.is_file() && file_path.extension().is_some_and(|e| e == "rs") {
573572
let filename = file_path.file_name().unwrap().to_string_lossy().to_string();
574573
let content = std::fs::read_to_string(&file_path)
575574
.map_err(|e| eyre!("Failed to read {}: {}", filename, e))?;
@@ -710,7 +709,7 @@ impl<'a> HelixManager<'a> {
710709
}
711710

712711
/// Returns the path or the current working directory if no path is provided
713-
pub fn get_path_or_cwd(path: Option<&String>) -> Result<PathBuf> {
712+
pub fn get_path_or_cwd(path: Option<&str>) -> Result<PathBuf> {
714713
match path {
715714
Some(p) => Ok(PathBuf::from(p)),
716715
None => Ok(env::current_dir()?),

helix-cli/src/commands/sync.rs

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn collect_local_hx_manifest(queries_dir: &Path) -> Result<HashMap<String, Manif
220220
continue;
221221
}
222222

223-
let is_hx = path.extension().map(|ext| ext == "hx").unwrap_or(false);
223+
let is_hx = path.extension().is_some_and(|ext| ext == "hx");
224224
if !is_hx {
225225
continue;
226226
}
@@ -704,6 +704,17 @@ fn pull_remote_snapshot_into_local(
704704

705705
let target_manifest = collect_local_hx_manifest(target_queries_dir)?;
706706

707+
fs::create_dir_all(target_queries_dir)?;
708+
709+
for (relative_path, remote_entry) in remote_manifest {
710+
let destination = safe_join_relative(target_queries_dir, relative_path)?;
711+
if let Some(parent) = destination.parent() {
712+
fs::create_dir_all(parent)?;
713+
}
714+
fs::write(&destination, &remote_entry.content)
715+
.map_err(|e| eyre!("Failed to write {}: {}", relative_path, e))?;
716+
}
717+
707718
for relative_path in local_manifest.keys() {
708719
let local_path = safe_join_relative(current_queries_dir, relative_path)?;
709720
if local_path.exists() {
@@ -725,17 +736,6 @@ fn pull_remote_snapshot_into_local(
725736
}
726737
}
727738

728-
fs::create_dir_all(target_queries_dir)?;
729-
730-
for (relative_path, remote_entry) in remote_manifest {
731-
let destination = safe_join_relative(target_queries_dir, relative_path)?;
732-
if let Some(parent) = destination.parent() {
733-
fs::create_dir_all(parent)?;
734-
}
735-
fs::write(&destination, &remote_entry.content)
736-
.map_err(|e| eyre!("Failed to write {}: {}", relative_path, e))?;
737-
}
738-
739739
Ok(())
740740
}
741741

@@ -1745,17 +1745,14 @@ async fn run_project_sync_flow(project: &ProjectContext, assume_yes: bool) -> Re
17451745
assume_yes,
17461746
)
17471747
.await?;
1748-
if let SyncReconciliationOutcome::Pulled = sync_outcome {
1749-
if project.config.project.queries != selected_queries_relative {
1750-
update_project_queries_path_in_helix_toml(
1751-
&project.root,
1752-
&selected_queries_relative,
1753-
)?;
1754-
Step::verbose_substep(&format!(
1755-
" Updated project queries path to {}",
1756-
selected_queries_relative.display()
1757-
));
1758-
}
1748+
if let SyncReconciliationOutcome::Pulled = sync_outcome
1749+
&& project.config.project.queries != selected_queries_relative
1750+
{
1751+
update_project_queries_path_in_helix_toml(&project.root, &selected_queries_relative)?;
1752+
Step::verbose_substep(&format!(
1753+
" Updated project queries path to {}",
1754+
selected_queries_relative.display()
1755+
));
17591756
}
17601757
}
17611758

@@ -2176,17 +2173,17 @@ async fn pull_from_cloud_instance(
21762173
)
21772174
.await?;
21782175

2179-
if let SyncReconciliationOutcome::Pulled = sync_outcome {
2180-
if project.config.project.queries != selected_queries_relative {
2181-
update_project_queries_path_in_helix_toml(
2182-
&project.root,
2183-
&selected_queries_relative,
2184-
)?;
2185-
Step::verbose_substep(&format!(
2186-
" Updated project queries path to {}",
2187-
selected_queries_relative.display()
2188-
));
2189-
}
2176+
if let SyncReconciliationOutcome::Pulled = sync_outcome
2177+
&& project.config.project.queries != selected_queries_relative
2178+
{
2179+
update_project_queries_path_in_helix_toml(
2180+
&project.root,
2181+
&selected_queries_relative,
2182+
)?;
2183+
Step::verbose_substep(&format!(
2184+
" Updated project queries path to {}",
2185+
selected_queries_relative.display()
2186+
));
21902187
}
21912188

21922189
reconcile_project_config_from_cloud(

helix-cli/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ impl CloudInstanceConfig {
286286
}
287287

288288
impl EnterpriseInstanceConfig {
289+
#[allow(dead_code)]
289290
pub fn runtime_config(&self) -> RuntimeConfig {
290291
self.db_config.to_runtime_config()
291292
}

0 commit comments

Comments
 (0)