visevol / GithubVisualisation

PFE028 Été 2024
MIT License
0 stars 1 forks source link

[Backend] Add GitRepository lib class #18

Closed zergov closed 1 week ago

zergov commented 2 weeks ago

Part of: https://github.com/visevol/GihubVisualisation/issues/10

Add the GitRepository class in the lib directory.

This is a wrapper over the process of cloning and extracting logs from a git repository.

How to test locally

  1. Build the api docker container: docker compose build api
  2. Open a rails command line: docker compose run api bin/rails c
  3. From this console, you can instantiate the GitRepository class of this PR and play with it:
    repo = GitRepository.new("https://github.com/rails/rails")
    repo.clone
    repo.logs do |logs|
    logs.each do |line|
    p line
    end
    end

^ This clones the https://github.com/rails/rails repository, and dumps the content of all its commits (93 000).