Harry caught sight of Malfoy, Crabbe, and Goyle's triumphant faces as he left, walking numbly in Professor McGonagall's wake as she strode toward the castle. He was going to be expelled, he just knew it. He wanted to say something to defend himself, but there seemed to be something wrong with his voice. Professor McGonagall was sweeping along without even looking at him; he had to jog to keep up. Now he'd done it. He hadn't even lasted two weeks. He'd be packing his bags in ten minutes. What would the Dursleys say when he turned up on the doorstep?
(Harry Potter and the Sorcerer's Stone)
Wiktionary says ‘have done’ means “to reach an end; to finish (with).” Then does ‘it’ refer to something else, for example, Harry’s Hogwart’s school life; or is the group,phrase ‘had done it’ used as a kind of idiom?