Skip to content

Commit 8c3879f

Browse files
committed
Fix CI
1 parent 6399b20 commit 8c3879f

File tree

7 files changed

+112
-112
lines changed

7 files changed

+112
-112
lines changed

src/commands/analysis.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ impl SummaryCommand {
186186
let mut authors = Vec::new();
187187

188188
for line in output.lines() {
189-
if let Some((count_str, name)) = line.trim().split_once('\t') {
190-
if let Ok(count) = count_str.trim().parse::<u32>() {
191-
authors.push(AuthorStats {
192-
name: name.to_string(),
193-
commits: count,
194-
});
195-
}
189+
if let Some((count_str, name)) = line.trim().split_once('\t')
190+
&& let Ok(count) = count_str.trim().parse::<u32>()
191+
{
192+
authors.push(AuthorStats {
193+
name: name.to_string(),
194+
commits: count,
195+
});
196196
}
197197
}
198198

@@ -456,13 +456,13 @@ impl AsyncSummaryCommand {
456456
let mut authors = Vec::new();
457457

458458
for line in output.lines() {
459-
if let Some((count_str, name)) = line.trim().split_once('\t') {
460-
if let Ok(count) = count_str.trim().parse::<u32>() {
461-
authors.push(AuthorStats {
462-
name: name.to_string(),
463-
commits: count,
464-
});
465-
}
459+
if let Some((count_str, name)) = line.trim().split_once('\t')
460+
&& let Ok(count) = count_str.trim().parse::<u32>()
461+
{
462+
authors.push(AuthorStats {
463+
name: name.to_string(),
464+
commits: count,
465+
});
466466
}
467467
}
468468

src/commands/repository.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,12 @@ impl HealthCommand {
500500
}
501501

502502
// Check for stale branches
503-
if let Ok(stale_count) = Self::count_stale_branches() {
504-
if stale_count > 0 {
505-
issues.push(format!(
506-
"⚠️ {stale_count} potentially stale branches found"
507-
));
508-
}
503+
if let Ok(stale_count) = Self::count_stale_branches()
504+
&& stale_count > 0
505+
{
506+
issues.push(format!(
507+
"⚠️ {stale_count} potentially stale branches found"
508+
));
509509
}
510510

511511
issues
@@ -560,14 +560,14 @@ impl HealthCommand {
560560
// Use git count-objects for repository size
561561
if let Ok(output) = GitOperations::run(&["count-objects", "-vH"]) {
562562
for line in output.lines() {
563-
if line.starts_with("size-pack") {
564-
if let Some(size_str) = line.split_whitespace().nth(1) {
565-
// Parse size and check if it's concerning
566-
if size_str.ends_with("GiB") || size_str.contains("1024") {
567-
issues.push(format!(
568-
"⚠️ Repository size: {size_str} (consider cleanup)"
569-
));
570-
}
563+
if line.starts_with("size-pack")
564+
&& let Some(size_str) = line.split_whitespace().nth(1)
565+
{
566+
// Parse size and check if it's concerning
567+
if size_str.ends_with("GiB") || size_str.contains("1024") {
568+
issues.push(format!(
569+
"⚠️ Repository size: {size_str} (consider cleanup)"
570+
));
571571
}
572572
}
573573
}
@@ -714,29 +714,29 @@ impl HealthCommand {
714714
files_checked += 1;
715715

716716
// Use filesystem metadata instead of external commands
717-
if let Ok(metadata) = std::fs::metadata(file) {
718-
if metadata.is_file() {
719-
let size = metadata.len();
720-
721-
// Simple heuristic: consider it binary if it's over 1MB or has certain extensions
722-
let is_likely_binary = size > 1_000_000
723-
|| file.ends_with(".exe")
724-
|| file.ends_with(".dll")
725-
|| file.ends_with(".so")
726-
|| file.ends_with(".dylib")
727-
|| file.ends_with(".bin")
728-
|| file.ends_with(".jpg")
729-
|| file.ends_with(".png")
730-
|| file.ends_with(".gif")
731-
|| file.ends_with(".pdf")
732-
|| file.ends_with(".zip");
733-
734-
if is_likely_binary {
735-
binary_count += 1;
736-
737-
if size > 1_000_000 {
738-
large_files.push((file.to_string(), size));
739-
}
717+
if let Ok(metadata) = std::fs::metadata(file)
718+
&& metadata.is_file()
719+
{
720+
let size = metadata.len();
721+
722+
// Simple heuristic: consider it binary if it's over 1MB or has certain extensions
723+
let is_likely_binary = size > 1_000_000
724+
|| file.ends_with(".exe")
725+
|| file.ends_with(".dll")
726+
|| file.ends_with(".so")
727+
|| file.ends_with(".dylib")
728+
|| file.ends_with(".bin")
729+
|| file.ends_with(".jpg")
730+
|| file.ends_with(".png")
731+
|| file.ends_with(".gif")
732+
|| file.ends_with(".pdf")
733+
|| file.ends_with(".zip");
734+
735+
if is_likely_binary {
736+
binary_count += 1;
737+
738+
if size > 1_000_000 {
739+
large_files.push((file.to_string(), size));
740740
}
741741
}
742742
}

src/commands/stash.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ impl StashCommand {
410410
fn get_stash_info(&self, stash_ref: &str) -> Result<StashInfo> {
411411
let output = GitOperations::run(&["stash", "list", "--pretty=format:%gd|%s", stash_ref])?;
412412

413-
if let Some(line) = output.lines().next() {
414-
if let Some(stash) = self.parse_stash_line_with_branch(line) {
415-
return Ok(stash);
416-
}
413+
if let Some(line) = output.lines().next()
414+
&& let Some(stash) = self.parse_stash_line_with_branch(line)
415+
{
416+
return Ok(stash);
417417
}
418418

419419
Err(GitXError::GitCommand(

src/core/safety.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ impl SafetyBuilder {
250250
Ok(result) => Ok(result),
251251
Err(e) => {
252252
// Try to restore from checkpoint on failure
253-
if self.checkpoint_needed {
254-
if let Err(restore_err) = Safety::restore_checkpoint() {
255-
eprintln!("Warning: Failed to restore checkpoint: {restore_err}");
256-
}
253+
if self.checkpoint_needed
254+
&& let Err(restore_err) = Safety::restore_checkpoint()
255+
{
256+
eprintln!("Warning: Failed to restore checkpoint: {restore_err}");
257257
}
258258
Err(e)
259259
}

src/core/validation.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ impl Validate {
128128
)));
129129
}
130130

131-
if let Some(max_val) = max {
132-
if value > max_val {
133-
return Err(GitXError::Parse(format!(
134-
"{field_name} must be <= {max_val}, got {value}"
135-
)));
136-
}
131+
if let Some(max_val) = max
132+
&& value > max_val
133+
{
134+
return Err(GitXError::Parse(format!(
135+
"{field_name} must be <= {max_val}, got {value}"
136+
)));
137137
}
138138

139139
Ok(())

src/domain/branch_manager.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ impl BranchManager {
2020
// Validate inputs
2121
Validate::branch_name(&request.name)?;
2222

23-
if let Some(ref base) = request.from {
24-
if !GitOperations::commit_exists(base)? {
25-
return Err(GitXError::GitCommand(format!(
26-
"Base branch or ref '{base}' does not exist"
27-
)));
28-
}
23+
if let Some(ref base) = request.from
24+
&& !GitOperations::commit_exists(base)?
25+
{
26+
return Err(GitXError::GitCommand(format!(
27+
"Base branch or ref '{base}' does not exist"
28+
)));
2929
}
3030

3131
// Check if branch already exists

tests/test_cli_handlers.rs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -314,30 +314,30 @@ fn test_branch_cli_handler_creation_outside_git_repo() {
314314
let current_dir = std::env::current_dir().unwrap();
315315

316316
// Try to change to a non-git directory (system temp)
317-
if let Ok(temp_dir) = std::env::temp_dir().canonicalize() {
318-
if std::env::set_current_dir(&temp_dir).is_ok() {
319-
// We're now in a temp directory (likely not a git repo)
320-
let result = BranchCliHandler::new();
321-
322-
// This should fail since we're not in a git repo
323-
match result {
324-
Ok(_) => {
325-
// Unexpectedly succeeded (temp dir might be in a git repo)
326-
}
327-
Err(err) => {
328-
// Expected to fail
329-
let error_msg = err.to_string();
330-
assert!(
331-
error_msg.contains("not a git repository")
332-
|| error_msg.contains("Git command failed")
333-
|| error_msg.contains("IO error")
334-
);
335-
}
336-
}
317+
if let Ok(temp_dir) = std::env::temp_dir().canonicalize()
318+
&& std::env::set_current_dir(&temp_dir).is_ok()
319+
{
320+
// We're now in a temp directory (likely not a git repo)
321+
let result = BranchCliHandler::new();
337322

338-
// Restore original directory
339-
let _ = std::env::set_current_dir(current_dir);
323+
// This should fail since we're not in a git repo
324+
match result {
325+
Ok(_) => {
326+
// Unexpectedly succeeded (temp dir might be in a git repo)
327+
}
328+
Err(err) => {
329+
// Expected to fail
330+
let error_msg = err.to_string();
331+
assert!(
332+
error_msg.contains("not a git repository")
333+
|| error_msg.contains("Git command failed")
334+
|| error_msg.contains("IO error")
335+
);
336+
}
340337
}
338+
339+
// Restore original directory
340+
let _ = std::env::set_current_dir(current_dir);
341341
}
342342
}
343343

@@ -347,27 +347,27 @@ fn test_repository_cli_handler_creation_outside_git_repo() {
347347
// Test behavior when not in a git repository
348348
let current_dir = std::env::current_dir().unwrap();
349349

350-
if let Ok(temp_dir) = std::env::temp_dir().canonicalize() {
351-
if std::env::set_current_dir(&temp_dir).is_ok() {
352-
let result = RepositoryCliHandler::new();
353-
354-
match result {
355-
Ok(_) => {
356-
// Unexpectedly succeeded
357-
}
358-
Err(err) => {
359-
// Expected to fail
360-
let error_msg = err.to_string();
361-
assert!(
362-
error_msg.contains("not a git repository")
363-
|| error_msg.contains("Git command failed")
364-
|| error_msg.contains("IO error")
365-
);
366-
}
367-
}
350+
if let Ok(temp_dir) = std::env::temp_dir().canonicalize()
351+
&& std::env::set_current_dir(&temp_dir).is_ok()
352+
{
353+
let result = RepositoryCliHandler::new();
368354

369-
let _ = std::env::set_current_dir(current_dir);
355+
match result {
356+
Ok(_) => {
357+
// Unexpectedly succeeded
358+
}
359+
Err(err) => {
360+
// Expected to fail
361+
let error_msg = err.to_string();
362+
assert!(
363+
error_msg.contains("not a git repository")
364+
|| error_msg.contains("Git command failed")
365+
|| error_msg.contains("IO error")
366+
);
367+
}
370368
}
369+
370+
let _ = std::env::set_current_dir(current_dir);
371371
}
372372
}
373373

0 commit comments

Comments
 (0)