I’m stuck on Stage #(#IC4).
I am trying to read the blob file but there seems to be some error and every time the test cases are failing. I have tried everything, even referred the code examples, but nothing seems to be working. Please help.
Here are my logs:
remote: [tester::#IC4] Running tests for Stage #IC4 (Read a blob object)
remote: [tester::#IC4] $ ./your_git.sh init
remote: [your_program] Logs from your program will appear here!
remote: [your_program] Initialized git directory
remote: [tester::#IC4] Added blob object to .git/objects: 6047f8fc18433ba22022e8a356c8539034219088
remote: [tester::#IC4] $ ./your_git.sh cat-file -p 6047f8fc18433ba22022e8a356c8539034219088
remote: [your_program] Logs from your program will appear here!
remote: [your_program] monkey doo scooby donkey doo donkey
remote: [tester::#IC4] Expected "monkey doo scooby donkey doo donkey" as stdout, got: "Logs from your program will appear here!\nmonkey doo scooby donkey doo donkey"
And here’s a snippet of my code:
case "cat-file" -> {
String hash = args[2];
String dirHash = hash.substring(0, 2);
String fileHash = hash.substring(2);
File blobFile = new File("./.git/objects/" + dirHash + "/" + fileHash);
try(BufferedReader blobRead = new BufferedReader (new InputStreamReader(new InflaterInputStream(new FileInputStream(blobFile))))) {
String blob = blobRead.readLine();
String content = blob.substring(blob.indexOf("\0")+1);
System.out.print(content);
} catch (IOException e) {
throw new RuntimeException(e);
}
}