From f5f6ae805f306b735eb2a08cc21f82929f9ba5cd Mon Sep 17 00:00:00 2001 From: Terky Date: Sun, 5 Mar 2023 01:09:27 +0100 Subject: [PATCH 1/5] Add swift starter template --- starter_templates/codecrafters.yml | 4 +-- starter_templates/swift/.gitignore | 9 ++++++ starter_templates/swift/Package.swift | 19 +++++++++++ .../Sources/swift-git-challenge/Main.swift | 32 +++++++++++++++++++ starter_templates/swift/your_git.sh | 15 +++++++++ 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 starter_templates/swift/.gitignore create mode 100644 starter_templates/swift/Package.swift create mode 100644 starter_templates/swift/Sources/swift-git-challenge/Main.swift create mode 100755 starter_templates/swift/your_git.sh diff --git a/starter_templates/codecrafters.yml b/starter_templates/codecrafters.yml index 2b4ecfe..6261d54 100644 --- a/starter_templates/codecrafters.yml +++ b/starter_templates/codecrafters.yml @@ -12,8 +12,8 @@ debug: false language_pack: python-3.8 {{/ language_is_python }} {{# language_is_swift }} -# Available versions: swift-5.1 -language_pack: swift-5.1 +# Available versions: swift-5.7 +language_pack: swift-5.7 {{/ language_is_swift }} {{# language_is_go }} # Available versions: go-1.19 diff --git a/starter_templates/swift/.gitignore b/starter_templates/swift/.gitignore new file mode 100644 index 0000000..3b29812 --- /dev/null +++ b/starter_templates/swift/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/starter_templates/swift/Package.swift b/starter_templates/swift/Package.swift new file mode 100644 index 0000000..7d4176a --- /dev/null +++ b/starter_templates/swift/Package.swift @@ -0,0 +1,19 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "swift-git-challenge", + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .executableTarget( + name: "swift-git-challenge", + dependencies: []), + ] +) diff --git a/starter_templates/swift/Sources/swift-git-challenge/Main.swift b/starter_templates/swift/Sources/swift-git-challenge/Main.swift new file mode 100644 index 0000000..4ef27c8 --- /dev/null +++ b/starter_templates/swift/Sources/swift-git-challenge/Main.swift @@ -0,0 +1,32 @@ +import Foundation + +@main +public struct Main { + public static func main() throws { + // You can use print statements as follows for debugging, they'll be visible when running tests. + print("Logs from your program will appear here!") + + // Uncomment this block to pass the first stage + // + // guard CommandLine.argc >= 2 else { + // print("usage: mygit [...]") + // return + // } + // + // let command = CommandLine.arguments[1] + // switch command { + // case "init": + // let fileManager = FileManager.default + // + // try fileManager.createDirectory(atPath: ".git", withIntermediateDirectories: false) + // try fileManager.createDirectory(atPath: ".git/objects", withIntermediateDirectories: false) + // try fileManager.createDirectory(atPath: ".git/refs", withIntermediateDirectories: false) + // fileManager.createFile(atPath: ".git/HEAD", contents: "ref: refs/heads/master\n".data(using: .utf8)) + // + // print("Initialized git directory") + // default: + // print("Unknown command \(command)") + // return + // } + } +} diff --git a/starter_templates/swift/your_git.sh b/starter_templates/swift/your_git.sh new file mode 100755 index 0000000..a9893ad --- /dev/null +++ b/starter_templates/swift/your_git.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# +# DON'T EDIT THIS! +# +# CodeCrafters uses this file to test your code. Don't make any changes here! +# +# DON'T EDIT THIS! +set -e +set -o pipefail + +packagePath=$(dirname "$0") +# Swift build writes errors to stdout instead of stderr. Let's collect all output in a file and only print if the exit code is zero. +buildOutputFile=$(mktemp) +swift build -c release --package-path "$packagePath" > "$buildOutputFile" || (cat "$buildOutputFile" && exit 1) +exec swift run -c release --skip-build --package-path "$packagePath" swift-git-challenge "$@" From 90ca62746354dca189d85935118a693c59441a0d Mon Sep 17 00:00:00 2001 From: Terky Date: Sun, 5 Mar 2023 01:09:52 +0100 Subject: [PATCH 2/5] Add swift dockerfile --- dockerfiles/swift-5.7.Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 dockerfiles/swift-5.7.Dockerfile diff --git a/dockerfiles/swift-5.7.Dockerfile b/dockerfiles/swift-5.7.Dockerfile new file mode 100644 index 0000000..dc7b5e7 --- /dev/null +++ b/dockerfiles/swift-5.7.Dockerfile @@ -0,0 +1,5 @@ +FROM swift:5.7.3-focal + +RUN apt update && \ + apt install --no-install-recommends --yes git && \ + rm -r /var/lib/apt/lists/ From 4d2b69d4dab5d7b3d1cfe6f2f4f6d282db42b621 Mon Sep 17 00:00:00 2001 From: Terky Date: Sun, 5 Mar 2023 01:10:22 +0100 Subject: [PATCH 3/5] Add swift to starter definition and course definition --- course-definition.yml | 2 +- starter-repository-definitions.yml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/course-definition.yml b/course-definition.yml index 90839ba..08369ac 100644 --- a/course-definition.yml +++ b/course-definition.yml @@ -14,7 +14,7 @@ short_description_md: | completion_percentage: 10 -early_access_languages: [] +early_access_languages: ["swift"] supported_languages: ["python", "ruby", "go", "rust"] # TODO: Add kotlin back once our builds are faster starter_repos: diff --git a/starter-repository-definitions.yml b/starter-repository-definitions.yml index f1f0545..fd724b5 100644 --- a/starter-repository-definitions.yml +++ b/starter-repository-definitions.yml @@ -62,4 +62,22 @@ required_executable: "cargo (1.54)" user_editable_file: "src/main.rs" +- language: swift + file_mappings: + - source: starter_templates/README.md + target: README.md + - source: starter_templates/codecrafters.yml + target: codecrafters.yml + - source: starter_templates/swift/.gitignore + target: .gitignore + - source: starter_templates/swift/Sources/swift-git-challenge/Main.swift + target: Sources/swift-git-challenge/Main.swift + - source: starter_templates/swift/Package.swift + target: Package.swift + - source: starter_templates/swift/your_git.sh + target: your_git.sh + template_attributes: + required_executable: "swift (5.7)" + user_editable_file: "Sources/swift-git-challenge/Main.swift" + # TODO: Add kotlin here once it's supported again! From 36eb8d657357510159028c8e904691dae8ee1ccf Mon Sep 17 00:00:00 2001 From: Terky Date: Sun, 5 Mar 2023 01:10:45 +0100 Subject: [PATCH 4/5] Add swift compiled starter --- .../git-starter-swift/.gitignore | 9 +++ .../git-starter-swift/Package.swift | 19 ++++++ compiled_starters/git-starter-swift/README.md | 61 +++++++++++++++++++ .../Sources/swift-git-challenge/Main.swift | 32 ++++++++++ .../git-starter-swift/codecrafters.yml | 11 ++++ .../git-starter-swift/your_git.sh | 15 +++++ 6 files changed, 147 insertions(+) create mode 100644 compiled_starters/git-starter-swift/.gitignore create mode 100644 compiled_starters/git-starter-swift/Package.swift create mode 100644 compiled_starters/git-starter-swift/README.md create mode 100644 compiled_starters/git-starter-swift/Sources/swift-git-challenge/Main.swift create mode 100644 compiled_starters/git-starter-swift/codecrafters.yml create mode 100755 compiled_starters/git-starter-swift/your_git.sh diff --git a/compiled_starters/git-starter-swift/.gitignore b/compiled_starters/git-starter-swift/.gitignore new file mode 100644 index 0000000..3b29812 --- /dev/null +++ b/compiled_starters/git-starter-swift/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/compiled_starters/git-starter-swift/Package.swift b/compiled_starters/git-starter-swift/Package.swift new file mode 100644 index 0000000..7d4176a --- /dev/null +++ b/compiled_starters/git-starter-swift/Package.swift @@ -0,0 +1,19 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "swift-git-challenge", + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .executableTarget( + name: "swift-git-challenge", + dependencies: []), + ] +) diff --git a/compiled_starters/git-starter-swift/README.md b/compiled_starters/git-starter-swift/README.md new file mode 100644 index 0000000..cd83267 --- /dev/null +++ b/compiled_starters/git-starter-swift/README.md @@ -0,0 +1,61 @@ +![progress-banner](https://codecrafters.io/landing/images/default_progress_banners/git.png) + +This is a starting point for Swift solutions to the +["Build Your Own Git" Challenge](https://codecrafters.io/challenges/git). + +In this challenge, you'll build a small Git implementation that's capable of +initializing a repository, creating commits and cloning a public repository. +Along the way we'll learn about the `.git` directory, Git objects (blobs, +commits, trees etc.), Git's transfer protocols and more. + +**Note**: If you're viewing this repo on GitHub, head over to +[codecrafters.io](https://codecrafters.io) to try the challenge. + +# Passing the first stage + +The entry point for your Git implementation is in +`Sources/swift-git-challenge/Main.swift`. Study and uncomment the relevant code, +and push your changes to pass the first stage: + +```sh +git add . +git commit -m "pass 1st stage" # any msg +git push origin master +``` + +That's all! + +# Stage 2 & beyond + +Note: This section is for stages 2 and beyond. + +1. Ensure you have `swift (5.7)` installed locally +1. Run `./your_git.sh` to run your Git implementation, which is implemented in + `Sources/swift-git-challenge/Main.swift`. +1. Commit your changes and run `git push origin master` to submit your solution + to CodeCrafters. Test output will be streamed to your terminal. + +# Testing locally + +The `your_git.sh` script is expected to operate on the `.git` folder inside the +current working directory. If you're running this inside the root of this +repository, you might end up accidentally damaging your repository's `.git` +folder. + +We suggest executing `your_git.sh` in a different folder when testing locally. +For example: + +```sh +mkdir -p /tmp/testing && cd /tmp/testing +/path/to/your/repo/your_git.sh init +``` + +To make this easier to type out, you could add a +[shell alias](https://shapeshed.com/unix-alias/): + +```sh +alias mygit=/path/to/your/repo/your_git.sh + +mkdir -p /tmp/testing && cd /tmp/testing +mygit init +``` diff --git a/compiled_starters/git-starter-swift/Sources/swift-git-challenge/Main.swift b/compiled_starters/git-starter-swift/Sources/swift-git-challenge/Main.swift new file mode 100644 index 0000000..4ef27c8 --- /dev/null +++ b/compiled_starters/git-starter-swift/Sources/swift-git-challenge/Main.swift @@ -0,0 +1,32 @@ +import Foundation + +@main +public struct Main { + public static func main() throws { + // You can use print statements as follows for debugging, they'll be visible when running tests. + print("Logs from your program will appear here!") + + // Uncomment this block to pass the first stage + // + // guard CommandLine.argc >= 2 else { + // print("usage: mygit [...]") + // return + // } + // + // let command = CommandLine.arguments[1] + // switch command { + // case "init": + // let fileManager = FileManager.default + // + // try fileManager.createDirectory(atPath: ".git", withIntermediateDirectories: false) + // try fileManager.createDirectory(atPath: ".git/objects", withIntermediateDirectories: false) + // try fileManager.createDirectory(atPath: ".git/refs", withIntermediateDirectories: false) + // fileManager.createFile(atPath: ".git/HEAD", contents: "ref: refs/heads/master\n".data(using: .utf8)) + // + // print("Initialized git directory") + // default: + // print("Unknown command \(command)") + // return + // } + } +} diff --git a/compiled_starters/git-starter-swift/codecrafters.yml b/compiled_starters/git-starter-swift/codecrafters.yml new file mode 100644 index 0000000..a8184fa --- /dev/null +++ b/compiled_starters/git-starter-swift/codecrafters.yml @@ -0,0 +1,11 @@ +# Set this to true if you want debug logs. +# +# These can be VERY verbose, so we suggest turning them off +# unless you really need them. +debug: false + +# Use this to change the Swift version used to run your code +# on Codecrafters. +# +# Available versions: swift-5.7 +language_pack: swift-5.7 diff --git a/compiled_starters/git-starter-swift/your_git.sh b/compiled_starters/git-starter-swift/your_git.sh new file mode 100755 index 0000000..a9893ad --- /dev/null +++ b/compiled_starters/git-starter-swift/your_git.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# +# DON'T EDIT THIS! +# +# CodeCrafters uses this file to test your code. Don't make any changes here! +# +# DON'T EDIT THIS! +set -e +set -o pipefail + +packagePath=$(dirname "$0") +# Swift build writes errors to stdout instead of stderr. Let's collect all output in a file and only print if the exit code is zero. +buildOutputFile=$(mktemp) +swift build -c release --package-path "$packagePath" > "$buildOutputFile" || (cat "$buildOutputFile" && exit 1) +exec swift run -c release --skip-build --package-path "$packagePath" swift-git-challenge "$@" From 09beef80c00e2694a3cae5d6843db42e6c548a5c Mon Sep 17 00:00:00 2001 From: Terky Date: Sun, 5 Mar 2023 01:11:24 +0100 Subject: [PATCH 5/5] Add swift solution --- solutions/swift/01-init/code/.gitignore | 9 +++ solutions/swift/01-init/code/Package.swift | 19 ++++++ solutions/swift/01-init/code/README.md | 61 +++++++++++++++++++ .../Sources/swift-git-challenge/Main.swift | 27 ++++++++ solutions/swift/01-init/code/codecrafters.yml | 11 ++++ solutions/swift/01-init/code/your_git.sh | 15 +++++ .../swift-git-challenge/Main.swift.diff | 52 ++++++++++++++++ solutions/swift/01-init/explanation.md | 36 +++++++++++ 8 files changed, 230 insertions(+) create mode 100644 solutions/swift/01-init/code/.gitignore create mode 100644 solutions/swift/01-init/code/Package.swift create mode 100644 solutions/swift/01-init/code/README.md create mode 100644 solutions/swift/01-init/code/Sources/swift-git-challenge/Main.swift create mode 100644 solutions/swift/01-init/code/codecrafters.yml create mode 100755 solutions/swift/01-init/code/your_git.sh create mode 100644 solutions/swift/01-init/diff/Sources/swift-git-challenge/Main.swift.diff create mode 100644 solutions/swift/01-init/explanation.md diff --git a/solutions/swift/01-init/code/.gitignore b/solutions/swift/01-init/code/.gitignore new file mode 100644 index 0000000..3b29812 --- /dev/null +++ b/solutions/swift/01-init/code/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/solutions/swift/01-init/code/Package.swift b/solutions/swift/01-init/code/Package.swift new file mode 100644 index 0000000..7d4176a --- /dev/null +++ b/solutions/swift/01-init/code/Package.swift @@ -0,0 +1,19 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "swift-git-challenge", + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .executableTarget( + name: "swift-git-challenge", + dependencies: []), + ] +) diff --git a/solutions/swift/01-init/code/README.md b/solutions/swift/01-init/code/README.md new file mode 100644 index 0000000..cd83267 --- /dev/null +++ b/solutions/swift/01-init/code/README.md @@ -0,0 +1,61 @@ +![progress-banner](https://codecrafters.io/landing/images/default_progress_banners/git.png) + +This is a starting point for Swift solutions to the +["Build Your Own Git" Challenge](https://codecrafters.io/challenges/git). + +In this challenge, you'll build a small Git implementation that's capable of +initializing a repository, creating commits and cloning a public repository. +Along the way we'll learn about the `.git` directory, Git objects (blobs, +commits, trees etc.), Git's transfer protocols and more. + +**Note**: If you're viewing this repo on GitHub, head over to +[codecrafters.io](https://codecrafters.io) to try the challenge. + +# Passing the first stage + +The entry point for your Git implementation is in +`Sources/swift-git-challenge/Main.swift`. Study and uncomment the relevant code, +and push your changes to pass the first stage: + +```sh +git add . +git commit -m "pass 1st stage" # any msg +git push origin master +``` + +That's all! + +# Stage 2 & beyond + +Note: This section is for stages 2 and beyond. + +1. Ensure you have `swift (5.7)` installed locally +1. Run `./your_git.sh` to run your Git implementation, which is implemented in + `Sources/swift-git-challenge/Main.swift`. +1. Commit your changes and run `git push origin master` to submit your solution + to CodeCrafters. Test output will be streamed to your terminal. + +# Testing locally + +The `your_git.sh` script is expected to operate on the `.git` folder inside the +current working directory. If you're running this inside the root of this +repository, you might end up accidentally damaging your repository's `.git` +folder. + +We suggest executing `your_git.sh` in a different folder when testing locally. +For example: + +```sh +mkdir -p /tmp/testing && cd /tmp/testing +/path/to/your/repo/your_git.sh init +``` + +To make this easier to type out, you could add a +[shell alias](https://shapeshed.com/unix-alias/): + +```sh +alias mygit=/path/to/your/repo/your_git.sh + +mkdir -p /tmp/testing && cd /tmp/testing +mygit init +``` diff --git a/solutions/swift/01-init/code/Sources/swift-git-challenge/Main.swift b/solutions/swift/01-init/code/Sources/swift-git-challenge/Main.swift new file mode 100644 index 0000000..d1259b9 --- /dev/null +++ b/solutions/swift/01-init/code/Sources/swift-git-challenge/Main.swift @@ -0,0 +1,27 @@ +import Foundation + +@main +public struct Main { + public static func main() throws { + guard CommandLine.argc >= 2 else { + print("usage: mygit [...]") + return + } + + let command = CommandLine.arguments[1] + switch command { + case "init": + let fileManager = FileManager.default + + try fileManager.createDirectory(atPath: ".git", withIntermediateDirectories: false) + try fileManager.createDirectory(atPath: ".git/objects", withIntermediateDirectories: false) + try fileManager.createDirectory(atPath: ".git/refs", withIntermediateDirectories: false) + fileManager.createFile(atPath: ".git/HEAD", contents: "ref: refs/heads/master\n".data(using: .utf8)) + + print("Initialized git directory") + default: + print("Unknown command \(command)") + return + } + } +} diff --git a/solutions/swift/01-init/code/codecrafters.yml b/solutions/swift/01-init/code/codecrafters.yml new file mode 100644 index 0000000..a8184fa --- /dev/null +++ b/solutions/swift/01-init/code/codecrafters.yml @@ -0,0 +1,11 @@ +# Set this to true if you want debug logs. +# +# These can be VERY verbose, so we suggest turning them off +# unless you really need them. +debug: false + +# Use this to change the Swift version used to run your code +# on Codecrafters. +# +# Available versions: swift-5.7 +language_pack: swift-5.7 diff --git a/solutions/swift/01-init/code/your_git.sh b/solutions/swift/01-init/code/your_git.sh new file mode 100755 index 0000000..a9893ad --- /dev/null +++ b/solutions/swift/01-init/code/your_git.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# +# DON'T EDIT THIS! +# +# CodeCrafters uses this file to test your code. Don't make any changes here! +# +# DON'T EDIT THIS! +set -e +set -o pipefail + +packagePath=$(dirname "$0") +# Swift build writes errors to stdout instead of stderr. Let's collect all output in a file and only print if the exit code is zero. +buildOutputFile=$(mktemp) +swift build -c release --package-path "$packagePath" > "$buildOutputFile" || (cat "$buildOutputFile" && exit 1) +exec swift run -c release --skip-build --package-path "$packagePath" swift-git-challenge "$@" diff --git a/solutions/swift/01-init/diff/Sources/swift-git-challenge/Main.swift.diff b/solutions/swift/01-init/diff/Sources/swift-git-challenge/Main.swift.diff new file mode 100644 index 0000000..da74fca --- /dev/null +++ b/solutions/swift/01-init/diff/Sources/swift-git-challenge/Main.swift.diff @@ -0,0 +1,52 @@ +@@ -1,32 +1,27 @@ + import Foundation + + @main + public struct Main { + public static func main() throws { +- // You can use print statements as follows for debugging, they'll be visible when running tests. +- print("Logs from your program will appear here!") ++ guard CommandLine.argc >= 2 else { ++ print("usage: mygit [...]") ++ return ++ } + +- // Uncomment this block to pass the first stage +- // +- // guard CommandLine.argc >= 2 else { +- // print("usage: mygit [...]") +- // return +- // } +- // +- // let command = CommandLine.arguments[1] +- // switch command { +- // case "init": +- // let fileManager = FileManager.default +- // +- // try fileManager.createDirectory(atPath: ".git", withIntermediateDirectories: false) +- // try fileManager.createDirectory(atPath: ".git/objects", withIntermediateDirectories: false) +- // try fileManager.createDirectory(atPath: ".git/refs", withIntermediateDirectories: false) +- // fileManager.createFile(atPath: ".git/HEAD", contents: "ref: refs/heads/master\n".data(using: .utf8)) +- // +- // print("Initialized git directory") +- // default: +- // print("Unknown command \(command)") +- // return +- // } ++ let command = CommandLine.arguments[1] ++ switch command { ++ case "init": ++ let fileManager = FileManager.default ++ ++ try fileManager.createDirectory(atPath: ".git", withIntermediateDirectories: false) ++ try fileManager.createDirectory(atPath: ".git/objects", withIntermediateDirectories: false) ++ try fileManager.createDirectory(atPath: ".git/refs", withIntermediateDirectories: false) ++ fileManager.createFile(atPath: ".git/HEAD", contents: "ref: refs/heads/master\n".data(using: .utf8)) ++ ++ print("Initialized git directory") ++ default: ++ print("Unknown command \(command)") ++ return ++ } + } + } diff --git a/solutions/swift/01-init/explanation.md b/solutions/swift/01-init/explanation.md new file mode 100644 index 0000000..ce185ca --- /dev/null +++ b/solutions/swift/01-init/explanation.md @@ -0,0 +1,36 @@ +The entry point for your Git implementation is in `Sources/swift-git-challenge/Main.swift`. + +Study and uncomment the relevant code: + +```swift +// Uncomment this block to pass the first stage + +guard CommandLine.argc >= 2 else { + print("usage: mygit [...]") + return +} + +let command = CommandLine.arguments[1] +switch command { +case "init": + let fileManager = FileManager.default + + try fileManager.createDirectory(atPath: ".git", withIntermediateDirectories: false) + try fileManager.createDirectory(atPath: ".git/objects", withIntermediateDirectories: false) + try fileManager.createDirectory(atPath: ".git/refs", withIntermediateDirectories: false) + fileManager.createFile(atPath: ".git/HEAD", contents: "ref: refs/heads/master\n".data(using: .utf8)) + + print("Initialized git directory") +default: + print("Unknown command \(command)") + return +} +``` + +Push your changes to pass the first stage: + +``` +git add . +git commit -m "pass 1st stage" # any msg +git push origin master +```