Skip to content

Add elixir 1.17 #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mikowitz
Copy link

@mikowitz mikowitz commented Apr 26, 2025

Add Dockerfile, starter template, compiled starter, and solution for Elixir v1.17

Summary by CodeRabbit

  • New Features

    • Introduced Elixir starter templates and solution files for the "Build Your Own Git" challenge, including project setup, configuration, and entry-point code.
    • Added scripts for compiling and running Elixir projects both locally and in the CodeCrafters environment.
    • Implemented a basic command-line interface capable of initializing a minimal Git-like repository structure.
  • Documentation

    • Added comprehensive README and explanation files with setup instructions, challenge overview, and guidance for safe local testing.
  • Chores

    • Included project configuration, code formatting, and version control files to support best practices and maintainability.

Copy link

coderabbitai bot commented Apr 26, 2025

Walkthrough

This update introduces Elixir starter templates, solution files, and supporting infrastructure for a "Build Your Own Git" challenge. It adds shell scripts for compiling and running Elixir projects, project configuration files, code formatters, and documentation. The main program logic is implemented in a new CLI module with a main/1 function that handles command-line arguments to initialize a minimal Git repository structure. The update also includes Dockerfile and YAML configuration for environment setup, as well as solution files demonstrating the completed logic for the challenge's first stage.

Changes

Files/Paths Change Summary
compiled_starters/elixir/.codecrafters/compile.sh,
solutions/elixir/01-gg4/code/.codecrafters/compile.sh,
starter_templates/elixir/code/.codecrafters/compile.sh
Added shell scripts to compile the Elixir project into an escript executable and move it to a temp directory.
compiled_starters/elixir/.codecrafters/run.sh,
solutions/elixir/01-gg4/code/.codecrafters/run.sh,
starter_templates/elixir/code/.codecrafters/run.sh
Added shell scripts to execute the compiled Elixir binary with passed arguments.
compiled_starters/elixir/.formatter.exs,
solutions/elixir/01-gg4/code/.formatter.exs,
starter_templates/elixir/code/.formatter.exs
Added Elixir formatter configuration files specifying formatting rules for project files.
compiled_starters/elixir/.gitattributes,
solutions/elixir/01-gg4/code/.gitattributes
Added .gitattributes files to normalize line endings across platforms.
compiled_starters/elixir/.gitignore,
solutions/elixir/01-gg4/code/.gitignore,
starter_templates/elixir/code/.gitignore
Added .gitignore files to exclude build artifacts, dependencies, and temporary files from version control.
compiled_starters/elixir/README.md,
solutions/elixir/01-gg4/code/README.md
Added README documentation describing the challenge, usage instructions, and local testing guidance.
compiled_starters/elixir/codecrafters.yml,
solutions/elixir/01-gg4/code/codecrafters.yml
Added configuration files specifying debug settings and Elixir version for the environment.
compiled_starters/elixir/lib/main.ex,
starter_templates/elixir/code/lib/main.ex
Introduced CLI module with a main/1 function; in the starter, command logic is commented out and only a debug print is present.
solutions/elixir/01-gg4/code/lib/main.ex,
solutions/elixir/01-gg4/diff/lib/main.ex.diff
Added/activated CLI module with main/1 function implementing command-line handling for init and error cases.
compiled_starters/elixir/mix.exs,
solutions/elixir/01-gg4/code/mix.exs,
starter_templates/elixir/code/mix.exs
Added Mix project files defining project metadata, dependencies, and escript main module.
compiled_starters/elixir/your_program.sh,
solutions/elixir/01-gg4/code/your_program.sh
Added shell scripts for local compilation and execution of the Elixir program.
dockerfiles/elixir-1.17.Dockerfile Added Dockerfile for Elixir 1.17.2 on Alpine, copying source, installing dependencies, and caching build output.
solutions/elixir/01-gg4/explanation.md Added explanation file guiding users to implement and activate the command-line logic for the first stage.
starter_templates/elixir/config.yml Added YAML configuration specifying required executable and main editable file for the starter template.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI_Module as CLI.main/1
    participant FileSystem

    User->>CLI_Module: Run program with argv
    alt argv is ["init"]
        CLI_Module->>FileSystem: Create .git/objects and .git/refs
        CLI_Module->>FileSystem: Write .git/HEAD file
        CLI_Module-->>User: Print "Initialized git directory"
    else argv is [unknown_command]
        CLI_Module-->>User: Print "Unknown command"
        CLI_Module-->>User: Exit with status 1
    else argv is []
        CLI_Module-->>User: Print usage instructions
        CLI_Module-->>User: Exit with status 1
    end
Loading

Poem

In Elixir fields where code does sprout,
New scripts and docs are hopping out!
With .git and mix, the groundwork’s laid,
For Git-like tools by bunnies made.
Hop, compile, and run with glee—
The repo’s fresh as it can be!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (13)
solutions/elixir/01-gg4/code/mix.exs (2)

5-14: Project configuration is set up for Elixir 1.17.

  • elixir: "~> 1.17" specifies support for Elixir v1.17 and above.
  • escript: [main_module: CLI] defines CLI as the entry point for the compiled executable.

Consider pinning to the patch version ("~> 1.17.0") if you intend to restrict to 1.17.x and prevent inadvertent upgrades to 1.18+.


23-29: Dependency list is empty but ready for future additions.
You might remove the commented examples if you prefer a cleaner deps/0, but keeping them can help contributors learn how to add dependencies.

compiled_starters/elixir/.codecrafters/run.sh (1)

9-11: Add a pre-flight check for the compiled binary.

If /tmp/codecrafters-build-git-elixir is missing or not executable, the script will fail with a cryptic error. Consider:

+ if [ ! -x /tmp/codecrafters-build-git-elixir ]; then
+   echo "Error: executable not found or not executable at /tmp/codecrafters-build-git-elixir" >&2
+   exit 1
+ fi
  exec /tmp/codecrafters-build-git-elixir "$@"
starter_templates/elixir/code/.codecrafters/compile.sh (1)

11-12: Ensure dependencies are fetched before building.

To support any future dependencies declared in mix.exs, insert:

+ mix deps.get --only prod
  mix escript.build
  mv codecrafters_git /tmp/codecrafters-build-git-elixir
solutions/elixir/01-gg4/code/.codecrafters/compile.sh (1)

11-12: Fetch and compile dependencies in CI.

Even if the current solution has no external deps, adding:

+ mix deps.get --only prod
  mix escript.build
  mv codecrafters_git /tmp/codecrafters-build-git-elixir

will ensure the build remains robust when new dependencies are introduced.

starter_templates/elixir/code/mix.exs (1)

1-4: Align the Mix project module name with the app name.

The stub App.MixProject is generic. Renaming it to match the OTP app (:codecrafters_git)—for example, CodecraftersGit.MixProject—improves readability and consistency:

-defmodule App.MixProject do
+defmodule CodecraftersGit.MixProject do
   use Mix.Project
compiled_starters/elixir/.codecrafters/compile.sh (1)

11-12: Add dependency fetching for resilience.

Although the starter has no external dependencies today, including:

+ mix deps.get --only prod
  mix escript.build
  mv codecrafters_git /tmp/codecrafters-build-git-elixir

will future-proof the compile step if deps are ever added.

solutions/elixir/01-gg4/code/lib/main.ex (1)

1-20: LGTM: Well-structured Elixir implementation of Git init

The code properly implements the CLI functionality for initializing a Git repository with the correct directory structure and file content. It follows Elixir best practices with effective pattern matching and explicit error handling.

One potential enhancement would be to handle the case where the .git directory or its subdirectories already exist. For a more robust implementation, consider:

- :ok = File.mkdir(".git")
+ :ok = File.mkdir_p(".git")

And adding error handling for cases where files might already exist.

solutions/elixir/01-gg4/explanation.md (1)

28-32: Add language specification to the fenced code block

Adding a language specification to the fenced code block will improve syntax highlighting and make the document more consistent with Markdown best practices.

-```
+```bash
 git add .
 git commit -m "pass 1st stage" # any msg
 git push origin master
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

28-28: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

solutions/elixir/01-gg4/code/README.md (1)

7-9: Add a comma after "Along the way" for better readability

This is a compound sentence with two independent clauses that should be separated by a comma.

 initializing a repository, creating commits and cloning a public repository.
-Along the way we'll learn about the `.git` directory, Git objects (blobs,
+Along the way, we'll learn about the `.git` directory, Git objects (blobs,
 commits, trees etc.), Git's transfer protocols and more.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~8-~8: A comma might be missing here.
Context: ... cloning a public repository. Along the way we'll learn about the .git directory,...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

compiled_starters/elixir/README.md (1)

7-9: Add a comma after "Along the way" for better readability

This is a compound sentence with two independent clauses that should be separated by a comma.

 initializing a repository, creating commits and cloning a public repository.
-Along the way we'll learn about the `.git` directory, Git objects (blobs,
+Along the way, we'll learn about the `.git` directory, Git objects (blobs,
 commits, trees etc.), Git's transfer protocols and more.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~8-~8: A comma might be missing here.
Context: ... cloning a public repository. Along the way we'll learn about the .git directory,...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

starter_templates/elixir/code/lib/main.ex (2)

10-13: Consider adding error handling for file operations.

The code assumes file operations will always succeed with :ok results. In a real-world implementation, you might want to handle potential errors when creating directories or writing files.

# When uncommenting, consider updating with error handling:
-#     :ok = File.mkdir(".git")
-#     :ok = File.mkdir(".git/objects")
-#     :ok = File.mkdir(".git/refs")
-#     :ok = File.write(".git/HEAD", "ref: refs/heads/main\n")
+#     case File.mkdir(".git") do
+#       :ok -> 
+#         with {:ok, _} <- File.mkdir(".git/objects"),
+#              {:ok, _} <- File.mkdir(".git/refs"),
+#              {:ok, _} <- File.write(".git/HEAD", "ref: refs/heads/main\n") do
+#           IO.puts("Initialized git directory")
+#         else
+#           {:error, reason} -> 
+#             IO.puts("Error initializing git directory: #{inspect(reason)}")
+#             System.halt(1)
+#         end
+#       {:error, reason} ->
+#         IO.puts("Error creating .git directory: #{inspect(reason)}")
+#         System.halt(1)
+#     end

1-25: Consider adding module documentation.

Adding @moduledoc and @doc annotations would help users understand the purpose of the module and its functions.

+# @moduledoc """
+# CLI module that implements Git-like functionality for the CodeCrafters challenge.
+# """
 defmodule CLI do
+  @doc """
+  Main entry point that processes command line arguments.
+  
+  ## Parameters
+  
+  - argv: List of command-line arguments
+  """
   def main(argv) do
     # You can use print statements as follows for debugging, they'll be visible when running tests.
     IO.puts("Logs from your program will appear here!")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97b5ce9 and d3c7152.

📒 Files selected for processing (30)
  • compiled_starters/elixir/.codecrafters/compile.sh (1 hunks)
  • compiled_starters/elixir/.codecrafters/run.sh (1 hunks)
  • compiled_starters/elixir/.formatter.exs (1 hunks)
  • compiled_starters/elixir/.gitattributes (1 hunks)
  • compiled_starters/elixir/.gitignore (1 hunks)
  • compiled_starters/elixir/README.md (1 hunks)
  • compiled_starters/elixir/codecrafters.yml (1 hunks)
  • compiled_starters/elixir/lib/main.ex (1 hunks)
  • compiled_starters/elixir/mix.exs (1 hunks)
  • compiled_starters/elixir/your_program.sh (1 hunks)
  • dockerfiles/elixir-1.17.Dockerfile (1 hunks)
  • solutions/elixir/01-gg4/code/.codecrafters/compile.sh (1 hunks)
  • solutions/elixir/01-gg4/code/.codecrafters/run.sh (1 hunks)
  • solutions/elixir/01-gg4/code/.formatter.exs (1 hunks)
  • solutions/elixir/01-gg4/code/.gitattributes (1 hunks)
  • solutions/elixir/01-gg4/code/.gitignore (1 hunks)
  • solutions/elixir/01-gg4/code/README.md (1 hunks)
  • solutions/elixir/01-gg4/code/codecrafters.yml (1 hunks)
  • solutions/elixir/01-gg4/code/lib/main.ex (1 hunks)
  • solutions/elixir/01-gg4/code/mix.exs (1 hunks)
  • solutions/elixir/01-gg4/code/your_program.sh (1 hunks)
  • solutions/elixir/01-gg4/diff/lib/main.ex.diff (1 hunks)
  • solutions/elixir/01-gg4/explanation.md (1 hunks)
  • starter_templates/elixir/code/.codecrafters/compile.sh (1 hunks)
  • starter_templates/elixir/code/.codecrafters/run.sh (1 hunks)
  • starter_templates/elixir/code/.formatter.exs (1 hunks)
  • starter_templates/elixir/code/.gitignore (1 hunks)
  • starter_templates/elixir/code/lib/main.ex (1 hunks)
  • starter_templates/elixir/code/mix.exs (1 hunks)
  • starter_templates/elixir/config.yml (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
compiled_starters/elixir/lib/main.ex (2)
solutions/elixir/01-gg4/code/lib/main.ex (1)
  • main (2-19)
starter_templates/elixir/code/lib/main.ex (1)
  • main (2-24)
starter_templates/elixir/code/lib/main.ex (1)
solutions/elixir/01-gg4/code/lib/main.ex (1)
  • main (2-19)
solutions/elixir/01-gg4/code/lib/main.ex (2)
compiled_starters/elixir/lib/main.ex (1)
  • main (2-24)
starter_templates/elixir/code/lib/main.ex (1)
  • main (2-24)
🪛 LanguageTool
solutions/elixir/01-gg4/code/README.md

[uncategorized] ~8-~8: A comma might be missing here.
Context: ... cloning a public repository. Along the way we'll learn about the .git directory,...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

compiled_starters/elixir/README.md

[uncategorized] ~8-~8: A comma might be missing here.
Context: ... cloning a public repository. Along the way we'll learn about the .git directory,...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

🪛 Hadolint (2.12.0)
dockerfiles/elixir-1.17.Dockerfile

[error] 10-10: invalid flag: --exclude

(DL1000)

🪛 markdownlint-cli2 (0.17.2)
solutions/elixir/01-gg4/explanation.md

28-28: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (32)
solutions/elixir/01-gg4/code/.gitattributes (1)

1-2: Approve line-ending normalization
The .gitattributes file correctly enforces automatic line-ending normalization for all text files in the solution directory, ensuring cross-platform consistency.

compiled_starters/elixir/.gitattributes (1)

1-2: Approve line-ending normalization in starter
This .gitattributes entry ensures that starter files under compiled_starters/elixir/ will have normalized line endings, matching the solution setup.

compiled_starters/elixir/.formatter.exs (1)

1-5: Approve Elixir formatter configuration
The input patterns cover mix.exs, .formatter.exs, and all .ex/.exs files under config, lib, and test. This aligns with standard Mix formatting conventions.

solutions/elixir/01-gg4/code/.gitignore (1)

1-28: Approve Elixir solution .gitignore patterns
The ignore rules comprehensively cover build artifacts (_build/), dependencies (deps/), coverage reports (cover/), and other temporary files (.ez, erl_crash.dump, etc.). This mirrors best practices for Mix-based projects.

solutions/elixir/01-gg4/code/mix.exs (3)

1-4: Module definition and Mix integration look correct.
The App.MixProject module properly uses Mix.Project and follows standard conventions.


17-21: Application extra applications are minimal and appropriate.
Starting only :logger is sufficient if your runtime logic doesn’t depend on other OTP apps.


5-14:

✅ Verification successful

Verify the existence and namespace of the CLI module.
Ensure that lib/main.ex defines a top-level CLI module (i.e., defmodule CLI do ... end) so that mix escript.build can correctly resolve the main_module.

Run:


🏁 Script executed:

#!/bin/bash
# Verify top-level CLI module declaration
rg --max-count=1 "^defmodule CLI" -n solutions/elixir/01-gg4/code/lib

Length of output: 131


CLI module correctly defined

Verified that CLI is declared in solutions/elixir/01-gg4/code/lib/main.ex:1 (defmodule CLI do … end), so escript will resolve main_module: CLI without issues.

starter_templates/elixir/config.yml (1)

1-3: Starter template configuration is correct.
The required_executable and user_editable_file keys align with our challenge runner’s expectations for setting up the development environment.

solutions/elixir/01-gg4/code/.formatter.exs (1)

1-4: Formatter inputs are correctly specified.
These patterns ensure mix format covers mix.exs, .formatter.exs, and all .ex/.exs files under the standard directories.

starter_templates/elixir/code/.formatter.exs (1)

1-4: Formatter configuration in starter matches solution.
Consistent formatting rules across starter and solution templates will help maintain code style.

compiled_starters/elixir/.gitignore (5)

1-7: Ignoring compiled binaries and build artifacts is correct.
/codecrafters_git and /_build/ ensure that generated escripts and artifacts aren’t committed.


8-12: Coverage and dependencies folders are excluded.
Patterns for /cover/ and /deps/ will keep test artifacts and fetched dependencies out of source control.


13-18: Documentation and fetch artifacts are ignored.
/doc/ and /.fetch align with Mix’s conventions.


19-21: Erlang VM crash dumps are excluded.
erl_crash.dump is appropriately ignored.


22-27: Archive artifacts are covered.
*.ez and app-*.tar patterns prevent hex archives from polluting the repo.

solutions/elixir/01-gg4/code/codecrafters.yml (2)

5-5: Configuration for debug logs added.
The debug: false flag is a sensible default to avoid verbose output in the solution environment.


11-11: Elixir version set to 1.17.
Locking language_pack: elixir-1.17 aligns with the PR objective to support Elixir 1.17.

compiled_starters/elixir/codecrafters.yml (2)

5-5: Default debug logging disabled.
Keeping debug: false in the compiled starter is appropriate for clean initial runs.


11-11: Elixir version locked to 1.17.
Specifying elixir-1.17 in the starter ensures consistency with the solution and the intended environment.

starter_templates/elixir/code/.gitignore (2)

4-27: Standard Elixir build artifacts are ignored.
The rest of the patterns correctly exclude _build/, cover/, deps/, doc/, .fetch, crash dumps, archive artifacts (*.ez), and tarballs (app-*.tar). This aligns with typical Elixir/Mix workflows.


1-2:

✅ Verification successful

Verify compiled binary ignore pattern.
The line /codecrafters_git should match the escript executable name produced by your Mix project (as invoked in .codecrafters/compile.sh and .codecrafters/run.sh). Please confirm the actual output filename in mix.exs and update this entry if needed to ensure the binary is properly excluded.


🏁 Script executed:

#!/bin/bash
# Verify escript name defined in mix.exs
rg -n "escript: *:.*" starter_templates/elixir/code/mix.exs

Length of output: 61


🏁 Script executed:

#!/bin/bash
# Check project app name
rg -n "app:" -C2 starter_templates/elixir/code/mix.exs

# Check for any escript configuration
rg -n "escript" -C2 starter_templates/elixir/code/mix.exs

Length of output: 348


.gitignore escript ignore pattern verified
The Mix project’s app: :codecrafters_git together with escript: [main_module: CLI] yields a binary named codecrafters_git by default, so the /codecrafters_git entry in .gitignore is correct.

starter_templates/elixir/code/.codecrafters/run.sh (2)

1-8: Shell script header and comments are clear.
The shebang (#!/bin/sh), set -e, and documentation comments correctly frame this run script for CodeCrafters.


9-12: Executes the compiled escript.
The call to exec /tmp/codecrafters-build-git-elixir "$@" cleanly forwards arguments to the built escript. Ensure the compile step generates the binary at this location.

solutions/elixir/01-gg4/code/.codecrafters/run.sh (2)

1-8: Run script header is appropriately documented.
Shebang, set -e, and usage comments are all present to meet CodeCrafters conventions.


9-12: Executes the solution escript.
Forwarding "$@" to the /tmp/codecrafters-build-git-elixir binary matches the starter logic and will correctly invoke the compiled solution.

compiled_starters/elixir/your_program.sh (1)

1-25: LGTM: Shell script follows best practices

The shell script is well-structured with proper directory navigation, error handling with set -e, and correct use of exec to pass arguments. The comments clearly explain the purpose and relationship to the remote compilation process.

solutions/elixir/01-gg4/code/your_program.sh (1)

1-25: LGTM: Consistent shell script implementation

This script is identical to the one in the compiled_starters directory, maintaining consistency across the starter and solution codebases. It correctly handles compilation and execution of the Elixir Git implementation.

solutions/elixir/01-gg4/diff/lib/main.ex.diff (1)

1-41: LGTM: Properly uncommented the Git init implementation

The diff correctly uncomments and implements the first stage of the Git challenge. The code follows Elixir best practices with proper pattern matching, error handling, and file operations to create the expected .git directory structure.

compiled_starters/elixir/mix.exs (1)

1-30: LGTM: Mix.exs file is correctly configured for the Elixir 1.17 project

The Mix project configuration is well-structured and correctly sets up:

  • Proper app name and versioning
  • Correct Elixir version requirement (~> 1.17)
  • Escript configuration pointing to the CLI module as the main entry point
  • Required applications and empty dependency list (with helpful commented examples)
compiled_starters/elixir/lib/main.ex (1)

1-25: LGTM: The CLI module is correctly implemented as a starter template

The CLI module is well-structured with:

  • Proper entry point using the main/1 function to accept command-line arguments
  • Helpful debug statement to show users how to output logs
  • Well-commented code block that correctly implements the Git init command
  • Proper pattern matching for different command scenarios

The implementation matches the solution example and follows Elixir best practices.

starter_templates/elixir/code/lib/main.ex (2)

1-5: Clear module structure with helpful debug statement.

The module definition and debug print statement provide a good starting point for users. The debug message clearly indicates where logs will appear during testing.


6-23: Well-structured commented code block for the first challenge stage.

The commented implementation provides clear guidance on how to initialize a Git repository, with proper directory structure creation and HEAD file setup. The pattern matching approach is idiomatic Elixir and handles the three main cases appropriately:

  1. Git init command
  2. Unknown commands
  3. No arguments provided

This demonstrates good practices for new Elixir developers.

Comment on lines +9 to +11
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix invalid COPY flags; use .dockerignore instead
Docker’s COPY does not support --exclude. To prevent cache misses on .git and README.md, create a .dockerignore at the repo root listing those entries, then simplify the Dockerfile copy step:

- COPY --exclude=.git --exclude=README.md . /app
+ # Ensure .dockerignore excludes .git and README.md
+ COPY . /app

Also add a .dockerignore alongside the Dockerfile:

.git
README.md
🧰 Tools
🪛 Hadolint (2.12.0)

[error] 10-10: invalid flag: --exclude

(DL1000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant