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:
- Create a
.env
file in the root directory of the project, and addGITHUB_TOKEN
- Update the
owner
andrepo
name in thefetch_pr.py
file, at line102
and103
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.
Start a server to provide Git history via an API:
cargo run --release server
The server will be available at http://localhost:8080
.
- 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.
- URL:
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
Build and run the Docker image:
docker compose up -d
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
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"
}
]
}
]
This project is licensed under the MIT License.