Skip to content

Commit c143ae7

Browse files
doctor: Improve status reporting granularity
Distinguish between blocking problems and missing state in repository and hooks directory checks. Introduce Miss status for non-error missing states instead of incorrectly reporting Fail. Include Unknown hook content state alongside Stale when marking hooks as failed. Co-authored-by: SCE <sce@crocoder.dev>
1 parent 3bf8099 commit c143ae7

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

cli/src/services/doctor.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,25 +1297,47 @@ fn config_location_status(
12971297
}
12981298

12991299
fn repository_root_status(report: &HookDoctorReport) -> HumanTextStatus {
1300-
if report.repository_root.is_some() {
1300+
let has_blocking_problem = report.problems.iter().any(|p| {
1301+
matches!(
1302+
p.kind,
1303+
ProblemKind::BareRepository | ProblemKind::NotInsideGitRepository
1304+
)
1305+
});
1306+
if has_blocking_problem {
1307+
HumanTextStatus::Fail
1308+
} else if report.repository_root.is_some() {
13011309
HumanTextStatus::Pass
13021310
} else {
1303-
HumanTextStatus::Fail
1311+
HumanTextStatus::Miss
13041312
}
13051313
}
13061314

13071315
fn hooks_directory_status(report: &HookDoctorReport) -> HumanTextStatus {
1308-
if report.hooks_directory.is_some() {
1316+
let has_blocking_problem = report.problems.iter().any(|p| {
1317+
matches!(
1318+
p.kind,
1319+
ProblemKind::HooksDirectoryMissing
1320+
| ProblemKind::HooksPathNotDirectory
1321+
| ProblemKind::UnableToResolveGitHooksDirectory
1322+
)
1323+
});
1324+
if has_blocking_problem {
1325+
HumanTextStatus::Fail
1326+
} else if report.hooks_directory.is_some() {
13091327
HumanTextStatus::Pass
13101328
} else {
1311-
HumanTextStatus::Fail
1329+
HumanTextStatus::Miss
13121330
}
13131331
}
13141332

13151333
fn hook_human_text_status(hook: &HookFileHealth) -> HumanTextStatus {
13161334
if !hook.exists {
13171335
HumanTextStatus::Miss
1318-
} else if hook.content_state == HookContentState::Stale || !hook.executable {
1336+
} else if matches!(
1337+
hook.content_state,
1338+
HookContentState::Stale | HookContentState::Unknown
1339+
) || !hook.executable
1340+
{
13191341
HumanTextStatus::Fail
13201342
} else {
13211343
HumanTextStatus::Pass

0 commit comments

Comments
 (0)