Harry had duelled with Draco Malfoy and used the Dark spell Sectumsempra, leaving Draco bleeding on the floor until Professor Snape arrived to save his life. As a result, Harry had to serve a detention with Snape on Saturday instead of playing in the last Quidditch match of the school year (HBP24).
The detention consisted of Harry manually copying detention cards from Filch’s filing cabinet that included the years when Snape and the Marauders were at Hogwarts. Many of the cards included wrong-doing by Harry’s father James, as well as Sirius Black, Peter Pettigrew and even Remus Lupin.
At 12:15, Harry returned to Gryffindor Tower after his detention to find a massive celebration – Gryffindor have won – and immediately kisses Ginny in front of everybody.