Skip to main content

Generate a well-structured commit message based on staged changes

Project description

🧠 The Problem: The Empty Commit Syndrome

empty commit

You just wrapped up an intense dev session. You proudly run:

git add .
git commit ""

And then… nothing.

The cursor blinks. The quotes are empty. No idea what to write. How do you summarize what you just did? How do you follow commit conventions? Should you mention the ticket? Where? How?

That’s where Commitly comes in.


🚀 What is Commitly?

Commitly is a Python library that uses AI to automatically generate smart commit messages from your staged Git changes (git diff --cached).

No more writer’s block. Commitly gives you clear, structured, multilingual messages — even splits large diffs into logical commits if needed.


📦 Installation

Install Commitly via PyPI:

pip install commitly

Make sure Git is installed and properly configured on your system.


⚙️ Main Features

🔹 __init__(file_temp="commit.txt", lang="fr")

Creates a Commitly instance:

  • file_temp: Temporary file name to save the commit message.
  • lang: Output language (en or fr). Default is French.

🔹 add(file: str) -> bool

Adds a file to the Git staging area.

commitly.add("app/models/user.py")

🔹 generate_commit_message(...) -> dict | List[dict]

Generates one or more commit messages from the current staged diff.

Parameters:

  • style_commit, format_commit, recommandation_commit: Customize commit style and rules.
  • ticket: Ticket ID to include in the commit.
  • fact (bool): Enables smart factorization to split the diff into multiple coherent commits.

⚠️ Raises a DiffEmptyException if no changes are detected in staging.


🔹 save_message_to_file(message: str) -> bool

Saves the generated commit message to the temporary file.


🔹 commit() -> bool

Performs a Git commit using the saved message from the temporary file and deletes it afterward.


🔹 push()

Pushes your latest commit to the remote repository.


🔹 unstage(file: str)

Removes a file from the Git staging area (git reset <file>).


🔹 file_stage() -> List[str]

Returns a list of currently staged files (git diff --cached --name-only).


🔹 _run_cmd(cmd: str, return_code: bool = False)

Internal method to execute shell commands.


🧪 Full Example

from commitly.commitly import Commitly

commitly = Commitly()

# Stage a file
commitly.add("main.py")

# Generate a message with a ticket
message = commitly.generate_commit_message(ticket="#42")

# Save it and commit
commitly.save_message_to_file(message["commit"])
commitly.commit()
commitly.push()

🧠 Example with smart factorization

messages = commitly.generate_commit_message(ticket="#42", fact=True)
for item in messages:
    print(item["commit"], ":", item["files"])

Example output:

[
    {
        "commit": "feat[core]: add role management to authentication",
        "files": ["auth/roles.py", "auth/utils.py"]
    },
    {
        "commit": "docs: update setup guide",
        "files": ["docs/setup.md"]
    }
]

🧩 About the Commit Format

Generated messages follow a conventional structure:

<type>[optional scope]: <description>

[optional body]

[optional footer] ← ticket goes here (#1234)

Common types:

  • feat: a new feature
  • fix: a bug fix
  • docs: documentation-only changes
  • refactor: code changes that neither fix a bug nor add a feature
  • chore: other routine tasks like config or CI changes

💡 Why use Commitly?

✅ Say goodbye to “wip” commits ✅ Enforce a consistent commit standard across your team ✅ Generate logical, factorized commits from complex diffs ✅ Multilingual support (EN/FR) ✅ Easy integration into any Git workflow


📋 License

MIT © 2025 Kouya Chance Boman Tosten


Stop staring at your empty commit. Let Commitly tell the story of your code — one commit at a time.

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

commitly-3.0.2.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

commitly-3.0.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file commitly-3.0.2.tar.gz.

File metadata

  • Download URL: commitly-3.0.2.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for commitly-3.0.2.tar.gz
Algorithm Hash digest
SHA256 e5257925f2e3acb4854a6e94cbff0e7cb32805f0c119198eeda1d8b0163342e1
MD5 d793c0a3c043e9f1bf1a0de29f8021f9
BLAKE2b-256 e205680d6c67a04bfc6bbc1e5e94b57d0fc45b0a9245855a0f59d0f604c6e28c

See more details on using hashes here.

File details

Details for the file commitly-3.0.2-py3-none-any.whl.

File metadata

  • Download URL: commitly-3.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for commitly-3.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64aa4fe77bcc3474d2af2a75bb0035464d3ba7483d8235bb78ddbf1e5ade072c
MD5 775848327f62e4c028ea4f2243e4e4d9
BLAKE2b-256 a8aee66969d7da3aff81f573bdc83895f72d08523c37e7852d93131cccc248f7

See more details on using hashes here.

Supported by

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