Skip to main content

No project description provided

Project description

GOC

This script, goc.py, is a utility tool that leverages the OpenAI GPT-3.5 Turbo model to generate Markdown documentation for Git diffs and commits. It can be used to automatically generate a markdown document based on the output of git diff:

Prerequisites

You will need an OpenAI API key, configure it to the environment variable like below:

export OPENAI_API_KEY=<your_key_here>

You will need a python version higher than 3.8

Installation

You can either install from Pypi (https://pypi.org/project/goc/)

pip install goc

Or you can download this repository and run

poetry install

Usage

To execute the script, run the following command:

goc [mode] [arguments]

Replace [mode] with one of the following options:

diff: Generate documentation for the git diff between commits or files. commit: Generate a commit message for the current git diff. Replace [arguments] based on the mode selected:

For the diff mode, provide the arguments to specify the commits or files to compare. For the commit mode, no additional arguments are needed.

  • Generate documentation for the diff between two commits:

    goc diff [commit_a] [commit_b]
    
  • Document Comparison vs Current Commit:

    goc diff [commit_hash]
    
  • Document Comparison of a single commit:

    goc diff [commit_hash]^!
    
  • Document Staged Changes:

    goc diff --staged
    
  • Automatically generate commit message and commit:

    goc commit
    

Output

The script generates Markdown documentation by utilizing the OpenAI GPT-3.5 Turbo model. The resulting documentation will be displayed in the console output.

Examples

$ goc diff a0f72101be85667a362425c2cdc30ef794e2a738
## Commit Details

- **Commit Type:** Code update
- **Commit Scope:** goc.py, pyproject.toml
- **Commit Description:**

### goc.py
1. Removed the `document_comparison_vs_current_commit` and `document_comparison_of_2_commits` functions as they were not being used.
2. Created a new function `document_git_diff_wrap` that takes command line arguments and runs the `git diff` command with those arguments. This allows for easy comparison of commits by passing the commit hashes or branches directly as arguments.
3. Modified the `goc` function to handle different scenarios based on the number of command line arguments passed. If no arguments are provided, it compares the latest two commits. If one or more arguments are provided, it passes them directly to `document_git_diff_wrap` for comparison.
4. updated the `parse_gpt_resp` function to return the content of the last choice/message in the response, as the final generated markdown content is usually the last choice.

### pyproject.toml
1. Updated the version to `"0.2.0"`.

Please review and merge these changes.
$ goc commit
Committing with message: "Update git diff handling, handle case when no diff is found"

Note

Make sure you have the necessary permissions and access to the Git repository you intend to analyze. Also, ensure that the repository is properly cloned on your local machine.

Disclaimer

This tool relies on the OpenAI GPT-3.5 Turbo model for generating documentation. The accuracy and quality of the generated content depend on the model's training data and the provided input. Please review and validate the generated documentation before using it in your projects.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goc-0.5.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

goc-0.5.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file goc-0.5.0.tar.gz.

File metadata

  • Download URL: goc-0.5.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/22.3.0

File hashes

Hashes for goc-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b4b9de7524e570738de3f27392b71e0c276de23a6e043b2f88273277ed0c3d87
MD5 930034ed7ed0f3eb726c97606c1a3aab
BLAKE2b-256 c41348a238aab4d7b0f1e657688e4439d55ab9ae7d1e2c3a36f427a7bb612e35

See more details on using hashes here.

File details

Details for the file goc-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: goc-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/22.3.0

File hashes

Hashes for goc-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b0eb6b4f73008d7d2f942d5c2753d91c82cff6f3c24c7324add046fc7a8dd85
MD5 a7207ccc5de13e1258c87ad1f5f047f8
BLAKE2b-256 29269eb8239f83a74175be120cd473facb4965c2e0ede2e815f8ecc1ef34f318

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page