Skip to main content

A tool that AI automatically recommends commit messages.

Project description

commit-autosuggestions

Build Status License: Apache 2.0 PyPI Downloads

Have you ever hesitated to write a commit message? Now get a commit message from Artificial Intelligence!

Abstract

CodeBERT: A Pre-Trained Model for Programming and Natural Languages introduces a pre-trained model in a combination of Program Language and Natural Language(PL-NL). It also introduces the problem of converting code into natural language (Code Documentation Generation).

diff --git a/test.py b/test.py
new file mode 100644
index 0000000..1b1b82a
--- /dev/null
+++ b/test.py
@@ -0,0 +1,3 @@
+
+def add(a, b):
+    return a + b
Recommended Commit Message : Add two arguments .

We can use CodeBERT to create a model that generates a commit message when code is added. However, most code changes are not made only by add of the code, and some parts of the code are deleted.

diff --git a/test.py b/test.py
index 1b1b82a..32a93f1 100644
--- a/test.py
+++ b/test.py
@@ -1,3 +1,5 @@
+import torch
+import arguments

 def add(a, b):
     return a + b
Recommended Commit Message : Remove unused imports

To solve this problem, use a new embedding called patch_type_embeddings that can distinguish added and deleted, just as the sample et al, 2019 (XLM) used language embeddeding. (1 for added, 2 for deleted.)

Language support

Language Added Diff
Python
JavaScript
Go
JAVA
Ruby
PHP
  • ✅ — Supported
  • 🔶 — Partial support
  • 🚧 — Under development
  • ⬜ - N/A ️

We plan to slowly conquer languages that are not currently supported. However, I also need to use expensive GPU instances of AWS or GCP to train about the above languages. Please do a simple sponsor for this!

Quick Start

To run this project, you need a flask-based inference server (GPU) and a client (commit module). If you don't have a GPU, don't worry, you can use it through Google Colab.

1. Run flask pytorch server.

Prepare Docker and Nvidia-docker before running the server.

1-a. If you have GPU machine.

Serve flask server with Nvidia Docker

$ docker run -it --gpus 0 -p 5000:5000 commit-autosuggestions:0.1-gpu
1-b. If you don't have GPU machine.

Even if you don't have a GPU, you can still serve the flask server by using the ngrok setting in commit_autosuggestions.ipynb.

2. Start commit autosuggestion with Python client module named commit.

First, install the package through pip.

$ pip install commit

Set the endpoint for the flask server configured in step 1 through the commit configure command. (For example, if the endpoint is http://127.0.0.1:5000, set it as follows: commit configure --endpoint http://127.0.0.1:5000)

$ commit configure --help       
Usage: commit configure [OPTIONS]

Options:
  --profile TEXT   unique name for managing each independent settings
  --endpoint TEXT  endpoint address accessible to the server (example :
                   http://127.0.0.1:5000/)  [required]

  --help           Show this message and exit.

All setup is done! Now, you can get a commit message from the AI with the command commit.

$ commit --help          
Usage: commit [OPTIONS] COMMAND [ARGS]...

Options:
  --profile TEXT       unique name for managing each independent settings
  -f, --file FILENAME  patch file containing git diff (e.g. file created by
                       `git add` and `git diff --cached > test.diff`)

  -v, --verbose        print suggested commit message more detail.
  -a, --autocommit     automatically commit without asking if you want to
                       commit

  --help               Show this message and exit.

Commands:
  configure

Training detail

Refer How to train for your lint style. This allows you to re-fine tuning to your repository's commit lint style.

Contribution

You can contribute anything, even a typo or code in the article. Don't hesitate!!. Versions are managed only within the branch with the name of each version. After being released on Pypi, it is merged into the master branch and new development proceeds in the upgraded version branch.

Author

Tae Hwan Jung(@graykode)

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

commit-0.1.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

commit-0.1.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file commit-0.1.0.tar.gz.

File metadata

  • Download URL: commit-0.1.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for commit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60d393de26060d3818a17fae02c185bb65c799f49ac43352463760fc98daf14c
MD5 db1a6b1501a4f79ff78f742642500657
BLAKE2b-256 4e57071e168dce5432ef7ece054fae06726c35418d83be8619906a3d0d220216

See more details on using hashes here.

File details

Details for the file commit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: commit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for commit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4dca43f080437d349366cdc1093ebfea944441bd93500f64f1e0498b267c1784
MD5 398b9deeaed6472c6dc3f8ae26d42157
BLAKE2b-256 5c601c57e0331c00550f54a4a5d2975b733e5daa89f6b316e2e7197914087b86

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