Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Himasnhu-AT/git-history

Repository files navigation

Git-History

Git-History is a tool that generates a JSON representation of the Git history for a repository. You can use it either as a command-line tool or as a server providing an API.

Important

Updated script, now it will also provide following json from pr:

{
  "prompt": "issue: <PR Title> | description: <PR Description>",
  "completion": [
    {
      "file": "<Filename>",
      "git_diff": "<Git Diff>",
      "file_content": "<Full File Content>"
    },
    ...
  ]
}

To run script, use following command:

python3 fetch_pr.py

Ensure to complete the following steps before running the script:

  1. Create a .env file in the root directory of the project, and add GITHUB_TOKEN
  2. Update the owner and repo name in the fetch_pr.py file, at line 102 and 103

Table of Contents

Usage

Run Locally

Generate a JSON file containing Git history:

cargo run --release index <path_to_git_repo>

This command will create a JSON file in the current directory and print it to the terminal.

Run as a Server

Start a server to provide Git history via an API:

cargo run --release server

The server will be available at http://localhost:8080.

API

  • Endpoint: POST /git_history
    • URL: http://localhost:8080/git_history
    • Request Body:
      {
        "repo": "<path_to_git_repo>"
      }
    • Response: A JSON object containing the Git history for the specified repository.

Example

Request Git history using curl:

curl -X POST -H "Content-Type: application/json" -d '{"repo": "github.com/himanshu-at/git-history"}' http://localhost:8080/git_history

Running in Docker

Build and Run Locally

Build and run the Docker image:

docker compose up -d

Use Pre-built Docker Image

Alternatively, use the pre-built Docker image from Docker Hub:

Create a docker-compose.yml file:

services:
  backend:
    image: himanshu806/git-history:0.1.0
    # build:
    #   context: .
    #   dockerfile: dockerfile
    ports:
      - 8080:8080
    command: cargo run --release server

JSON Structure

The JSON response includes an array of commit objects with the following structure:

[
  {
    "commit_id": "commit_hash",
    "author": "author_name",
    "message": "commit_message",
    "pl_and_issue_id": "pull_request_and_issue_id",
    "files": [
      {
        "file": "file_name",
        "diff": "diff_content"
      }
    ]
  }
]

License

This project is licensed under the MIT License.

Releases

No releases published

Packages

No packages published