A Michigan federal judge on Tuesday ordered Immigration and Customs Enforcement to give a longtime resident a bond hearing or release him from detention within seven days, finding the government has been inappropriately keeping him in custody under a section of law that applies to those trying to enter at the border.