MichaelCurrin / auto-commit-msg

A VS Code extension to generate a smart commit message based on file changes
https://marketplace.visualstudio.com/items?itemName=MichaelCurrin.auto-commit-msg
MIT License
128 stars 13 forks source link

Count the files for multi-file changes #38

Closed MichaelCurrin closed 3 years ago

MichaelCurrin commented 3 years ago

e.g.

Relates to #13

MichaelCurrin commented 3 years ago

See Many files in the Wiki https://github.com/MichaelCurrin/auto-commit-msg/wiki/Message-output-samples#many-files

MichaelCurrin commented 3 years ago

Consider a threshold - maybe 4 files or less lists the names otherwise breaks out as counts

Or maybe check the length of the generated message and then fallback to generating the count one.

glassesUSA commented 3 years ago

Any idea when this will be available?

MichaelCurrin commented 3 years ago

I haven't though about this one for a while. I can find time this weekend.

If I make PR, would you be able to review it and/or try it out locally before the next release?

glassesUSA commented 3 years ago

Sure will do!

MichaelCurrin commented 3 years ago

I have some work in progress on draft linked PR. So far handles exactly one file so not useful yet LOL. But following TDD with tests firsts and one file is the easiest to start with.

MichaelCurrin commented 3 years ago

I'll update here when it's ready for review

MichaelCurrin commented 3 years ago

@glassesUSA i made some good progress. I have a function that can generate

create 1 file, update 2 files and delete 1 file

I have two areas I'd like your input on. See if you agree and if there are any scenarios or behaviors that you want to suggest.

Conventional commit

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.

BTW I have an idea to implement pressing the button twice to go from feat to fix in a follow up. #50

When to count files

I was wondering when it makes sense to apply the create x files bit.

I'm thinking:

The more than 4 is easy to do initially. I'm thinking later generate the named files and if the message is more than 50 characters then regenerate a message using counts. #49

glassesUSA commented 3 years ago

Sounds good to me!

MichaelCurrin commented 3 years ago

@glassesUSA I've put through 2 PRs and have the code working well installed in my IDE

I'm not doing a release yet so that I have time to use it some more, but you can try it out by cloning the repo and running the following:

make install
make ext      # build and install extension

For the second PR that was merged.

Please see the test cases for these functions for high-level message handling. See if you think I covered a good mix of cases.

  _msgNamed,
  _msgCount,
  _msgFromChanges,

The _msgFromChanges function uses a constant set at 5 and will use _msgCount for 5 or more files.

https://github.com/MichaelCurrin/auto-commit-msg/blob/master/src/test/prepareCommitMsg.test.ts


In the first PR that was merged, I set up count.ts module. There are a bunch of low-level tests for countMsg here.

See https://github.com/MichaelCurrin/auto-commit-msg/blob/master/src/test/generate/count.test.ts

The countMsg function is used internally by _msgCount, so you'll see some overlap.


I've linked some follow-up issues here, in particular to add conv commit support.

49 #50 #52 #55

MichaelCurrin commented 3 years ago

This came in useful today

Screen Shot 2021-07-19 at 10 02 54 am
MichaelCurrin commented 3 years ago

I didn't see a response but I have been using this code the last week and it works fine for me. So am making a new release and closing this issue.

glassesUSA commented 3 years ago

Apologies was running a different repo that required a specific naming convention for requests so didn't have time to test. Glad it seems to be working!

MichaelCurrin commented 3 years ago

Please see release with downloadable file

https://github.com/MichaelCurrin/auto-commit-msg/releases/tag/v0.20.0