Code Monkey home page Code Monkey logo

commit-comments's Introduction

Commit Comments

Commit Comments automatically create a bulleted list of changes from comments in your code. Write comments using @commit keyword, and they will be added to your commit message when it's time to commit.

It works by using two Git hooks (prepare-commit-m sg and post-commit) to search your repository for @commit comments and construct a clean list of changes.

Once you've successfully committed, @commit comments are removed from your files

Installation

Clone the repository and move the prepare-commit-msg and post-commit files.

$ git clone https://github.com/thebearjew/commit-comments.git
$ cd commit-comments
$ chmod a+x prepare-commit-msg post-commit
$ cp prepare-commit-msg post-commit your-repository/.git/hooks 

Usage

As you're writing code, drop // @commit comments anywhere a significant change has been made.

Commit comments work with (inline & standalone):

  • C-like comments (C/C++, Java, JavaScript, etc.) //, /* */
  • Python/Ruby/Perl #
  • Assembly ;

Example:

foo.js

// @commit: Added a parameter to helloWorld function
function helloWorld(phrase) {
  console.log('Hello World + ' + phrase); /*  @commit - Concatenated strings */
}

Output in Git commit message

# Commit title goes here

- [foo.js#1] Added a parameter to helloWorld function
- [foo.js#3] Concatenated strings
# Changes to be committed:
#	modified:   foo.js 
#
# Changes not staged for commit:
# ...

Comments are removed from the original files.

foo.js - after commit


function helloWorld(phrase) {
  console.log('Hello World + ' + phrase); 
}

Ignoring Files

To ignore some files from being searched, create a .ccignore file in your repository and add file names/types.

README.md
build.sh
.cpp

Dependencies

  1. GNU sed is required to remove @commit comments in post-commit.

On Mac OS X, the default sed is from the FreeBSD distribution. To download the GNU sed version, use Brew

$ brew install gnu-sed --with-default-names

Without the --with-default-names option, the command will be downloaded as gsed.

  1. pcregrep is the primary search utility due to its widespread portability.

If pcregrep is not available, GNU grep is used (for Perl RegEx & variable lookback).

Contributing & Todo

Contributions to improve simplicity/resolve compatibility would be preferred. If there are useful improvements, tricks, or hacks, please submit a Pull Request and a directory of add-ons and snippets will be created.

TODO

  • Add filename and line number to bulleted commit commets - suggestion by joncalhoun on HN
  • Use git diff --cached --name-status --diff-filter=ACM in place of git ls-files
  • Develop more test cases (finding edge cases with grep expression)
  • Rewrite sed commands to be POSIX (BSD) compatible regular expressions
  • Create more robust regular expression for validating comment syntax
    • Check for multiline block comments
    • Check for closing comment symbols (positive look aheads)
  • Programming Languages
    • HTML
    • Fortran
    • AppleScript

--

Special Thanks to Bryan Wyatt for feedback and bug fixes - @brwyatt

commit-comments's People

Contributors

jryio avatar

Watchers

 avatar  avatar  avatar

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.