Giter VIP home page Giter VIP logo

cto's Introduction

Commit Text Organizer

A Text Processor targeted at organizing Commit Messages.

Do you like to organize your commit messages? CTO does! CTO operates on commit messages structured in a simple readable format.

The input messages are cleaned up, condensed, and sorted alphabetically before being returned.

File Oriented Commit Information (FOCI)

FOCI is inspired by the following statement:

A Commit may change many files, but it has just one purpose.

FOCI Concepts
  • Headers
    • Signify the start of a commit message group
    • Make it easier to categorize and locate related changes
  • Commit Lines
    • Lines grouped together under each header
    • Detail changes to files or groups of files
    • Enhancing traceability and readability
  • Subjects
    • The start of a Commit Line
    • Indicating the file or group of files
    • Allowing for quick identification of affected areas
  • Content Details
    • The end of a Commit Line
    • Comma separated list of text describing specific changes
    • Providing clarity on the nature of the modification.

CTO and FOCI ensure that commit messages are well-organized and convey the intended changes in a clear, concise manner. This is key to making revision history easy to revisit.

Commit Message Structure

At a high level, messages are organized into groups.

Each group has a unique header name.

Headers

Structure your commits using your own set of headers, such as:

  • Database Migration 32
  • Database Integration
  • Test Database Migrations

When writing commits, ensure that you add a colon (:) immediately after the header name.

Then, the lines immediately below the header are included in that group. These are called Commit Lines.

A Commit Line starts with a subject, corresponding to a file, or group of files.

Subjects (Files or Groups of Files)

A Subject is the start of a Commit Line in a header Group. It will usually describe a change in a single file, but you can group files into the subject.

Subject Matching

Lines in the same Header Group can be merged, but only if the subjects match.

When Content details are merged, they are separated from the Subject, sorted alphabetically, and joined with a comma-space separator.

Subject Content Separators

The subject is separated from content details by one of these separators: (+) or (-).

If a separator appears more than once in a Commit Line, it is ignored.

A subject may include a verb, such as "Update", which can be replaced with a prefix shortcut.

Commit Line Prefix Shortcuts

To reduce typing the same word for so many file changes (such as "Update", or "Create"), CTO includes a Line Prefix recognition and replacement feature.

 cto/text/commit_line_prefixes.py

It recognizes prefixes (that you can change) and replaces them with the most commonly used words.

Commit Line Prefix Shortcuts

Shortcut Prefix
c Create
d Delete
f Fix
m Move
r Remove
t Test
u Update
cr Create
del Delete
mv Move
up Update

Important Commit Line Characters

  • A header ends with a colon ":"
  • A blank line will start a new group
  • Commit Lines start with the star (*)
  • Subject is separated from content by (+) or (-)
  • Content may contain multiple changes that are comma-separated

Sorting

By default, your squashed PR message will have groups organized alphabetically by their header names.

  • Subjects within each group are sorted alphabetically
  • Sorting is done after applying Commit Line Prefix Shortcuts.

Example

Input:

Header 1:
*u File.c - new method hello_world()
*u File.c - new method foo()

Header 2:
*c NewFile.c

Header 2:
*r OldFile.c

Output:

Header 1:
* Update File.c - new method hello_world(), new method foo()

Header 2:
* Create NewFile.c
* Remove OldFile.c

How To Use It

  1. Install: Use python -m pip install commit-text-organizer, or manage it manually.
  2. Main Script: Run the script with a file path argument containing the commit messages.
  3. Commit Message Structure: Commit messages are organized into groups defined by headers (e.g., "Database Migration 32"). Each group contains commit lines starting with a star (*) and details changes to subjects (files or groups of files).
  4. Subject Matching and Content Details: Commit lines within the same header group can be merged if their subjects match. The tool sorts and joins content details alphabetically, separated by a comma-space.
  5. Line Prefix Shortcuts: To simplify repetitive prefixes like "Update" or "Create", CTO includes a feature to recognize and replace line prefix shortcuts with their full forms (e.g., "c" for "Create").
  6. Sorting and Output: The tool sorts groups and lines within groups alphabetically.
  7. Output: The output is printed to the standard output. Pipe it to a file, or it will be printed on screen.

Requirements

Python 3.10 or higher is required to run Commit-Text-Organizer. This is because the Union Type Operator is used (not available in 3.9 or earlier).

Program Architecture

All python modules are contained in the commit_text_organizer package. In the following diagram, modules are grouped into symbolic packages for better understanding.

cto

Project Vision

Enhancements should aim to make CTO more versatile, user-friendly, and integrated with workflows. Examples:

  • Run git subprocess and read commit messages from a branch instead of a file
  • Allow users to add their own prefix shortcuts in a config file

cto's People

Contributors

dk96-os avatar

Stargazers

 avatar

Watchers

 avatar

cto's Issues

Enable Command Line Arguments To Provide Input

The current method of input involves a back and forth prompt, where the user is asked for the file name. This imposes a limitation on the process.

To improve the versatility of Commit Text Organizer and enable more workflow integrations, the project should support command line argument processing to resolve this limitation.

Compatibility

Any existing workflows do not need to be changed.

  • launch.py will remain as-is
  • The new main module will be independent of launch.py

Scope

Implement standard library Argument Parsing to provide the exact same functionality as provided by launch.py to command line argument users.

Inefficient Input Data Management Could Be Replaced By Git Log Integration

CTO Workflow Summary

The commit messages are grouped together when squashing from GitHub PR. You switch from Merge to Squash, click the box and the textbox containing all commit messages appears. This is the current data source for the workflow.

The data is then pasted into a temporary file; for the purpose of providing data to the program. The File is later deleted along with the output file.

Issue Part 1

It has been observed that under specific conditions, the commit messages in the GitHub PR text box do not contain the most recent commits. This is related to textbox history, and is not a bug and shouldn't change anytime soon. When this occurs, manual corrections are required.

The dependence on manual corrections on some occasions is one part of the issue.

Issue Part 2

The workflow requires manual clicks to obtain data, as well as creating files and cleaning them up later. This can be optimized significantly by removing all of these manual actions.

The goal of continuous improvement is to find the inefficiencies and remove them, and this workflow contains many of them.

Issue Parts Summary

  1. This transient issue highlights an opportunity to find a more capable data source.
  2. This workflow design contains multiple non-value-adding manual actions.

Proposed Solution

The commit messages that you want to squash are located in the branch history, which can be accessed through the git log command with a few specific options tacked on.

By experimenting with inputs to git log, I can find a format that provides similar results to the GitHub squash formatter.

Potential Future Improvements Enabled By This Proposal

I could modify the inputs to git log in order to provide a commit message summary.

Commit Summary Information Available Through Git

  • Create a Group Header for the Commit Summary
  • Count the Number of Commits
  • Count the Number of Files affected
  • Count the Number of Unique Contributors

Additional Contributor Related Information

  • Who worked on what files
  • Who wrote FOCI formatted commit messages
  • Who did not write FOCI formatted commit messages

Merge Commits from Remote Tracking Branch Text in Input

These Merge commits have appeared in the squashed branch text input.

Merge remote-tracking branch 'origin/feature' into feature

The goal of CTO is handle important changes to your FOCI.

Following that goal, this branch related information is not important and will be filtered out by default.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.