Sec. 4. When a defendant who has been sentenced to imprisonment in the Texas Department of Criminal Justice has spent time in jail pending trial and sentence or pending appeal, the judge of the sentencing court shall direct the sheriff to attach to the commitment papers a statement assessing the defendant's conduct while in jail.