@@ -90,10 +90,10 @@ public static function evaluate( array $metrics, array $thresholds = array(), bo
9090 $ warnings = array ();
9191 $ refused = false ;
9292
93- $ effective_refuse_bytes = $ thresholds ['refuse_free_bytes ' ];
94- $ effective_warn_bytes = $ thresholds ['warn_free_bytes ' ];
93+ $ effective_refuse_bytes = ( int ) $ thresholds ['refuse_free_bytes ' ];
94+ $ effective_warn_bytes = ( int ) $ thresholds ['warn_free_bytes ' ];
9595 if ( null !== $ total_bytes && $ total_bytes > 0 ) {
96- $ effective_refuse_bytes = self ::effective_free_bytes_threshold (
96+ $ effective_refuse_bytes = self ::effective_refuse_free_bytes_threshold (
9797 (int ) $ thresholds ['refuse_free_bytes ' ],
9898 $ thresholds ['refuse_free_percent ' ],
9999 $ total_bytes
@@ -109,11 +109,10 @@ public static function evaluate( array $metrics, array $thresholds = array(), bo
109109 if ( $ free_bytes < $ effective_refuse_bytes ) {
110110 $ refused = ! $ forced ;
111111 $ warnings [] = sprintf (
112- 'Free disk space is %.1f GiB%s, below the refusal threshold of %.1f GiB or %.1f%% free, whichever is stricter . ' ,
112+ 'Free disk space is %.1f GiB%s, below the refusal threshold of %.1f GiB. ' ,
113113 self ::bytes_to_gib ($ free_bytes ),
114114 null === $ free_percent ? '' : sprintf (' (%.1f%%) ' , $ free_percent ),
115- self ::bytes_to_gib ( (int ) $ thresholds ['refuse_free_bytes ' ] ),
116- $ thresholds ['refuse_free_percent ' ]
115+ self ::bytes_to_gib ($ effective_refuse_bytes )
117116 );
118117 } elseif ( $ free_bytes < $ effective_warn_bytes ) {
119118 $ warnings [] = sprintf (
@@ -381,6 +380,29 @@ private static function effective_free_bytes_threshold( int $absolute_bytes, flo
381380 return max ($ absolute_bytes , $ percent_bytes );
382381 }
383382
383+ /**
384+ * Calculate the hard refusal threshold for a measured filesystem.
385+ *
386+ * Large filesystems can safely fall below a percentage threshold while still
387+ * having enough absolute free space for a bare worktree checkout. Keep the
388+ * percentage refusal only for filesystems smaller than the absolute floor,
389+ * where the absolute GiB floor is impossible to satisfy.
390+ *
391+ * @param int $absolute_bytes Absolute free-space threshold.
392+ * @param float $percent Percentage free-space threshold.
393+ * @param int $total_bytes Measured filesystem size.
394+ * @return int
395+ */
396+ private static function effective_refuse_free_bytes_threshold ( int $ absolute_bytes , float $ percent , int $ total_bytes ): int {
397+ $ percent_bytes = (int ) ceil ($ total_bytes * ( $ percent / 100 ));
398+
399+ if ( $ total_bytes < $ absolute_bytes ) {
400+ return $ percent_bytes ;
401+ }
402+
403+ return $ absolute_bytes ;
404+ }
405+
384406 /**
385407 * Convert bytes to GiB.
386408 *
0 commit comments