diff --git a/solutions/c/01-gg4/explanation.md b/solutions/c/01-gg4/explanation.md deleted file mode 100644 index 58453c0..0000000 --- a/solutions/c/01-gg4/explanation.md +++ /dev/null @@ -1,32 +0,0 @@ -The entry point for your Git implementation is in `src/main.c`. - -Study and uncomment the relevant code: - -```c -// Uncomment this block to pass the first stage - -if (mkdir(".git", 0755) == -1 || - mkdir(".git/objects", 0755) == -1 || - mkdir(".git/refs", 0755) == -1) { - fprintf(stderr, "Failed to create directories: %s\n", strerror(errno)); - return 1; -} - -FILE *headFile = fopen(".git/HEAD", "w"); -if (headFile == NULL) { - fprintf(stderr, "Failed to create .git/HEAD file: %s\n", strerror(errno)); - return 1; -} -fprintf(headFile, "ref: refs/heads/main\n"); -fclose(headFile); - -printf("Initialized git directory\n"); -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/cpp/01-gg4/explanation.md b/solutions/cpp/01-gg4/explanation.md deleted file mode 100644 index 9212df0..0000000 --- a/solutions/cpp/01-gg4/explanation.md +++ /dev/null @@ -1,49 +0,0 @@ -The entry point for your Git implementation is in `src/main.cpp`. - -Study and uncomment the relevant code: - -```cpp -// Uncomment this block to pass the first stage - -if (argc < 2) { - std::cerr << "No command provided.\n"; - return EXIT_FAILURE; -} - -std::string command = argv[1]; - -if (command == "init") { - try { - std::filesystem::create_directory(".git"); - std::filesystem::create_directory(".git/objects"); - std::filesystem::create_directory(".git/refs"); - - std::ofstream headFile(".git/HEAD"); - if (headFile.is_open()) { - headFile << "ref: refs/heads/main\n"; - headFile.close(); - } else { - std::cerr << "Failed to create .git/HEAD file.\n"; - return EXIT_FAILURE; - } - - std::cout << "Initialized git directory\n"; - } catch (const std::filesystem::filesystem_error& e) { - std::cerr << e.what() << '\n'; - return EXIT_FAILURE; - } -} else { - std::cerr << "Unknown command " << command << '\n'; - return EXIT_FAILURE; -} - -return EXIT_SUCCESS; -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/csharp/01-gg4/explanation.md b/solutions/csharp/01-gg4/explanation.md deleted file mode 100644 index cae3211..0000000 --- a/solutions/csharp/01-gg4/explanation.md +++ /dev/null @@ -1,21 +0,0 @@ -The entry point for your Git implementation is in `src/Program.cs`. - -Study and uncomment the relevant code: - -```csharp -// Uncomment this block to pass the first stage - -Directory.CreateDirectory(".git"); -Directory.CreateDirectory(".git/objects"); -Directory.CreateDirectory(".git/refs"); -File.WriteAllText(".git/HEAD", "ref: refs/heads/main\n"); -Console.WriteLine("Initialized git directory"); -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/go/01-gg4/explanation.md b/solutions/go/01-gg4/explanation.md deleted file mode 100644 index a0a24b4..0000000 --- a/solutions/go/01-gg4/explanation.md +++ /dev/null @@ -1,28 +0,0 @@ -The entry point for your Git implementation is in `app/main.go`. - -Study and uncomment the relevant code: - -```go -// Uncomment this block to pass the first stage! - -for _, dir := range []string{".git", ".git/objects", ".git/refs"} { - if err := os.MkdirAll(dir, 0755); err != nil { - fmt.Fprintf(os.Stderr, "Error creating directory: %s\n", err) - } -} - -headFileContents := []byte("ref: refs/heads/main\n") -if err := os.WriteFile(".git/HEAD", headFileContents, 0644); err != nil { - fmt.Fprintf(os.Stderr, "Error writing file: %s\n", err) -} - -fmt.Println("Initialized git directory") -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/haskell/01-gg4/explanation.md b/solutions/haskell/01-gg4/explanation.md deleted file mode 100644 index f8d382e..0000000 --- a/solutions/haskell/01-gg4/explanation.md +++ /dev/null @@ -1,21 +0,0 @@ -The entry point for your Git implementation is in `app/Main.hs`. - -Study and uncomment the relevant code: - -```haskell --- Uncomment this block to pass first stage -let createParents = True -createDirectoryIfMissing createParents ".git" -createDirectoryIfMissing createParents (".git" "objects") -createDirectoryIfMissing createParents (".git" "refs") -withFile (".git" "HEAD") WriteMode $ \f -> hPutStrLn f "ref: refs/heads/main" -putStrLn $ "Initialized git directory" -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/java/01-gg4/explanation.md b/solutions/java/01-gg4/explanation.md deleted file mode 100644 index 64ea074..0000000 --- a/solutions/java/01-gg4/explanation.md +++ /dev/null @@ -1,35 +0,0 @@ -The entry point for your Git implementation is in `src/main/java/Main.java`. - -Study and uncomment the relevant code: - -```java -// Uncomment this block to pass the first stage - -final String command = args[0]; - -switch (command) { - case "init" -> { - final File root = new File(".git"); - new File(root, "objects").mkdirs(); - new File(root, "refs").mkdirs(); - final File head = new File(root, "HEAD"); - - try { - head.createNewFile(); - Files.write(head.toPath(), "ref: refs/heads/main\n".getBytes()); - System.out.println("Initialized git directory"); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - default -> System.out.println("Unknown command: " + command); -} -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/javascript/01-gg4/explanation.md b/solutions/javascript/01-gg4/explanation.md deleted file mode 100644 index 52fc825..0000000 --- a/solutions/javascript/01-gg4/explanation.md +++ /dev/null @@ -1,33 +0,0 @@ -The entry point for your Git implementation is in `app/main.js`. - -Study and uncomment the relevant code: - -```javascript -// Uncomment this block to pass the first stage -const command = process.argv[2]; - -switch (command) { - case "init": - createGitDirectory(); - break; - default: - throw new Error(`Unknown command ${command}`); -} - -function createGitDirectory() { - fs.mkdirSync(path.join(process.cwd(), ".git"), { recursive: true }); - fs.mkdirSync(path.join(process.cwd(), ".git", "objects"), { recursive: true }); - fs.mkdirSync(path.join(process.cwd(), ".git", "refs"), { recursive: true }); - - fs.writeFileSync(path.join(process.cwd(), ".git", "HEAD"), "ref: refs/heads/main\n"); - console.log("Initialized git directory"); -} -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/kotlin/01-gg4/explanation.md b/solutions/kotlin/01-gg4/explanation.md deleted file mode 100644 index 32d35b9..0000000 --- a/solutions/kotlin/01-gg4/explanation.md +++ /dev/null @@ -1,23 +0,0 @@ -The entry point for your Git implementation is in `app/src/main/kotlin/App.kt`. - -Study and uncomment the relevant code: - -```kotlin -// Uncomment this block to pass the first stage - -val gitDir = File(".git") -gitDir.mkdir() -File(gitDir, "objects").mkdir() -File(gitDir, "refs").mkdir() -File(gitDir, "HEAD").writeText("ref: refs/heads/master\n") - -println("Initialized git directory") -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/python/01-gg4/explanation.md b/solutions/python/01-gg4/explanation.md deleted file mode 100644 index 40b4a38..0000000 --- a/solutions/python/01-gg4/explanation.md +++ /dev/null @@ -1,26 +0,0 @@ -The entry point for your Git implementation is in `app/main.py`. - -Study and uncomment the relevant code: - -```python -# Uncomment this block to pass the first stage - -command = sys.argv[1] -if command == "init": - os.mkdir(".git") - os.mkdir(".git/objects") - os.mkdir(".git/refs") - with open(".git/HEAD", "w") as f: - f.write("ref: refs/heads/main\n") - print("Initialized git directory") -else: - raise RuntimeError(f"Unknown command #{command}") -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/ruby/01-gg4/explanation.md b/solutions/ruby/01-gg4/explanation.md deleted file mode 100644 index d46bb4d..0000000 --- a/solutions/ruby/01-gg4/explanation.md +++ /dev/null @@ -1,27 +0,0 @@ -The entry point for your Git implementation is in `app/main.rb`. - -Study and uncomment the relevant code: - -```ruby -# Uncomment this block to pass the first stage - -command = ARGV[0] -case command -when "init" - Dir.mkdir(".git") - Dir.mkdir(".git/objects") - Dir.mkdir(".git/refs") - File.write(".git/HEAD", "ref: refs/heads/main\n") - puts "Initialized git directory" -else - raise RuntimeError.new("Unknown command #{command}") -end -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/rust/01-gg4/explanation.md b/solutions/rust/01-gg4/explanation.md deleted file mode 100644 index a37b0ea..0000000 --- a/solutions/rust/01-gg4/explanation.md +++ /dev/null @@ -1,25 +0,0 @@ -The entry point for your Git implementation is in `src/main.rs`. - -Study and uncomment the relevant code: - -```rust -// Uncomment this block to pass the first stage -let args: Vec = env::args().collect(); -if args[1] == "init" { - fs::create_dir(".git").unwrap(); - fs::create_dir(".git/objects").unwrap(); - fs::create_dir(".git/refs").unwrap(); - fs::write(".git/HEAD", "ref: refs/heads/main\n").unwrap(); - println!("Initialized git directory") -} else { - println!("unknown command: {}", args[1]) -} -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/typescript/01-gg4/explanation.md b/solutions/typescript/01-gg4/explanation.md deleted file mode 100644 index 4a20728..0000000 --- a/solutions/typescript/01-gg4/explanation.md +++ /dev/null @@ -1,20 +0,0 @@ -The entry point for your Git implementation is in `app/main.ts`. - -Study and uncomment the relevant code: - -```typescript -// Uncomment this block to pass the first stage -fs.mkdirSync(".git", { recursive: true }); -fs.mkdirSync(".git/objects", { recursive: true }); -fs.mkdirSync(".git/refs", { recursive: true }); -fs.writeFileSync(".git/HEAD", "ref: refs/heads/main\n"); -console.log("Initialized git directory"); -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -``` diff --git a/solutions/zig/01-gg4/explanation.md b/solutions/zig/01-gg4/explanation.md deleted file mode 100644 index e85a77b..0000000 --- a/solutions/zig/01-gg4/explanation.md +++ /dev/null @@ -1,25 +0,0 @@ -The entry point for your Git implementation is in `src/main.zig`. - -Study and uncomment the relevant code: - -```zig -// Uncomment this block to pass the first stage -const cwd = std.fs.cwd(); -_ = try cwd.makeDir("./.git"); -_ = try cwd.makeDir("./.git/objects"); -_ = try cwd.makeDir("./.git/refs"); -{ - const head = try cwd.createFile("./.git/HEAD", .{}); - defer head.close(); - _ = try head.write("ref: refs/heads/main\n"); -} -try stdout.writeAll("Initialized git directory\n"); -``` - -Push your changes to pass the first stage: - -``` -git add . -git commit -m "pass 1st stage" # any msg -git push origin master -```