Code Monkey home page Code Monkey logo

michaelcurrin / auto-commit-msg Goto Github PK

View Code? Open in Web Editor NEW
123.0 5.0 14.0 1.75 MB

A VS Code extension to generate a smart commit message based on file changes

Home Page: https://marketplace.visualstudio.com/items?itemName=MichaelCurrin.auto-commit-msg

License: MIT License

Shell 4.03% JavaScript 0.41% TypeScript 94.87% Makefile 0.69%
commit commit-message commit-message-formatter auto automation generate vscode vscode-extension typescript nodejs

auto-commit-msg's Introduction

Auto Commit Message ⚙️ 🧙‍♂️ ✉️

A VS Code extension to generate a smart commit message based on file changes

Node CI CodeQL License Contributions - welcome

Logo

VS Code extension marketplace version VS Code extension installs VS Code extension rating maintained - yes

Preview

Starting from an empty commit message, the extension created a recommended message and populated it inside the Git pane of VS Code:

sample screenshot of chore

Getting started

How to install and run the extension in VS Code.

docs - Getting started

Features

Just click the extension's one button in the Git pane.

This is what the extension can do:

  • Look at any staged changes files, otherwise falls back to all unstaged changes.
  • Generate a commit message, which you can use or edit.
  • It can describe a variety of changes - when a file is added, removed, moved, renamed, etc.
  • Can handle multiple files at once.
  • Based on paths and extensions, infers a Conventional Commit prefix type e.g. feat, chore, ci, build, build(deps), docs.

See more info on the Features page in the docs.

Comparison with other extensions

Other extensions usually require some manual input, such as selecting prefix type from a droplist or writing a commit message by hand along with other form parameters.

This extension takes zero parameters. Just click a button.

With the explosion of AI tools, you can find alternatives to this extension which use AI - see AI tools

Sample usage

Here are some screenshots of what messages the extension generates based on changed files.

If you created a new file and staged it:

feat

If you updated a build-related file:

build

If updated a file in docs/ or a README.md anywhere:

docs

If you renamed a file:

rename

Documentation

Guides for installing and using the pre-built extension and for developers to build from source code.

view - Documentation

Contributing

See the Contributing guide.

License

Released under MIT by @MichaelCurrin.

See the Credit doc for more info.

auto-commit-msg's People

Contributors

dependabot[bot] avatar michaelcurrin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

auto-commit-msg's Issues

Add scope

e.g. when working on package files.

chore(deps): - not yet supported
build(deps): - supported


This style is harder and depends on the knowing the codebase.

feat(lang): add polish language

Maybe it can be automated using the highest module for the file or files. e.g. src or lib (for src/lib). The directory could be nested a few levels deep. But also there is some risk of duplication of dir names across dirs.

It's not worth putting a filename.


Well maybe chore(docs) is a good way to mix docs directory with others.


https://www.conventionalcommits.org/en/v1.0.0/

A scope may be provided to a commit’s type, to provide additional contextual information and is contained within parenthesis, e.g., feat(parser): add ability to parse arrays.

A scope MAY be provided after a type. A scope MUST consist of a noun describing a section of the codebase surrounded by parenthesis, e.g., fix(parser):

Can this be hooked into onSave?

I'm using this in a workspace where i don't care about commit messages, it's a static repo, of markdown files.

And while this is useful, i would rather it automatically populate the message onsave that way all i have to do is click one button.

Use "🎉 Initial commit"

Check for this error in "Log (Window)"

When there are zero commits

: Error: Command failed: git diff-index --name-status --find-renames --find-copies --no-color --cached HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.

Add integration tests

This is a long term goal as the app has simple UI. See the notes in test section of the docs.

Note that there are different approaches to integration tests. The approach in semantic commit messages is nice. It uses vscode-test as a package in dev deps, which is downloaded when added to .vscode-test dir at the root.

I got error messages before that vscode tests would not run while vscode is running, but this seems okay now in vscode-git-semantic-commit when running my fork and vscode 1.48 downloaded.

Here is the approach in git-prefix to downloading and running vscode

		"postinstall": "node ./node_modules/vscode/bin/install",
		"test": "npm run compile && node ./node_modules/vscode/bin/test"

But the tests doesn't actually do much because of limited coverage.

Infer action from lines

e.g. if the diff is all adding new lines, then "add to foo.txt" vs "update foo.txt" for modify. Or "remove lines from foo.txt" for delete.

Figure out old/new msg for counts

Relates to #38

What happens when there is an old message when making a count message? Throw it away? Especially not useful if the old msg is a count and mixing old and new count messages doesn't make sense or look good.

Maybe keep the conv commit portion

Add `fix` semantic support

Perhaps assume feat if no other context can be found.

Then click the button again. If the output message is the same as the input message, then replace feat with fix

Such that clicking the button twice gives "fix".

Perhaps an option can be added in the command prompt to go straight to fix as well.
An extra button would not work so well on a small screen where there are a few other extensions already

And adding a pop-up on the single button would not be a nice flow because mostly its not needed

Filenames with spaces

Thanks for this extension, I find it very useful. One problem is that I need to work with some files with spaces in their filenames (nothing I can do about it), and the extension splits the file name at the first blank space. Is there a way to let it handle filenames with any Unicode characters like spaces (and other characters, like Russian letters)?

Add VS Code integration

VS Code does not work with git hooks. So after getting the shell version working I can look at making a vs code extension based on this one

https://github.com/benjaminadk/emojigit

I could even use my existing command as using the confirmation flow there is a terminal git commit command, but one gets there after using the extension UI. Also the confirmation in the terminal can be toggled. Maybe it is just behind the scenes

Update move/rename

Use just dir for rename

Use move or rename word appropriately

Update tests

Collapse package changes

If package.json and package-lock.json both change (or only the latter changed) and nothing else, then message can be:

build: Update dependencies

Same for pairs as yarn.lock, Gemfile.lock and maybe Pipfile.lock

Refactor enum

See if enum can be cleaned up

Reverse keys and values?

Change lookup with function or alternate use that is safer than any.

What is proper way to handle undefined, maybe just with if an error?

Fix multi repo handling

There is currently a not implemented message setup to be raised on multiple repos in a workspace, but this did not actually trigger.

So either do that, or get the functionality to work in multiple repos (using the scope of the current scope files and message box (there are multiple).

Use feat and switch feat and fix

First make feat the default

Then if the message is identical, replace feat with fix. And back again?

I might be missing the behavior anyway to detect repeat message which is meant to do nothing, besides this new feature.

Add coverage for prepareCommitMsg

The prepareCommitMsg module has missing coverage based on the reports.

The functions are used in the app but in the autofill and cli modules which are not practical to test and don't have tests, so prepareCommitMsg appears unused.

But the functions in prepareCommitMsg that are missing tests should still be tested directly.

Setup CLI use for outside IDE

I've already setup a flow for using the compiled JS files outside of VS Code.

Test and document this, maybe more work is needed to build that and release it.

It could be used as a hook - not in VS Code otherwise it works badly because of VS Code limitations.

It can be available as a globally available NPM package or shell script that calls it. As an alternative to git commit maybe. Maybe as a bin or alias target.

To pre-fill the git message and wait for confirmation (force editing).

e.g.

$ git commit -m $(auto-commit-msg) --edit

Use full name on repeats

e.g.

update cli.ts and cli.ts

To

update cli.ts and git/cli.ts

Using common root src without using src in either.

Semantic choice in UI

When docs: etc. is not manually entered already or deducible...

Maybe one chooses from a droplist like the semantic commit message extension and then that is pushed to the commit message.

Add Conventional Commit for X files changed

Depends on #38

How about the prefix before the message should always be feat if you add or update a file?

And if you only move or rename, it is refactor.

If you only delete files, then it is chore.

Then #50 later.

Detect comments

Detect if all changes in a file are whitespace (ignore those using a git diff-index flag) or start with # or //. This may not be practical for multi-line comments.

This may also required using diff.

Respect commit message template

This is something part of standard git hook for commit message, where a check is done to see if the message comes from a template.

If this is not possible, then just read the actual value of commit.template e.g. _COMMIT_MESSAGE and use that as a prefix.

This is useful as a simple alternative to reading from the branch name (which is covered by the git-prefix extension already). And allows manually entering a ticket message or project name that is not based on branch name.

There is a low priority issue though

Add formatting

TODO

This has become confusing where testing also runs linting with pretest, but then you're locked
into a linting choice of fix or not. Same for fmt, if it even goes here.
Also should then fmt go in all?

And CI/CD

Allow use of semantic support option only

Perhaps a command prompt option or a button. Or just a space in the message bar.

Fill the message bar with chore: etc. but don't fill in the message - this allows for custom messages.

Make Run extension work in temp dir

It's annoying if the extension is launched not in a dir

Then using open opens a normal window without the extension (or using the global one).

See semantic commit handling of test-temp even if not for integration tests but manual testing

Push message to input box

Perhaps a way in this extension to get close to the easy GH autofill flow.

To listen for when files are staged on unstaged and then push a message to the input box for you.

Apply style effect

Use style in Semantic section - check if the changes are all whitespace only.

For staged, check if there is a diff. and check if the no-whitespace diff is empty (need to check by hand). Then you know there are only whitespace changes.

Repeat for unstaged as fallback.

Otherwise you need to do regex checks against each file diff (maybe using plain diff and not diff-index? either way need patch output)

Flags for diff-index https://www.git-scm.com/docs/git-diff-index

-b
--ignore-space-change

    Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.
-w
--ignore-all-space

    Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.

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.