sourcegit-scm / sourcegit

Windows/macOS/Linux GUI client for GIT users
MIT License
610 stars 66 forks source link

[FEATURE] Warn when commit subject line goes beyond a certain number of characters #201

Closed WrichikBasu closed 1 week ago

WrichikBasu commented 1 week ago

It is customary to limit the commit subject line to 50 characters. The subject line should be a synopsis; the details should go into the commit body. GitHub, for instance, trims the subject line to 50 characters, and shows the characters beyond that in the body of the commit.

JetBrains IDEs like IntelliJ IDEA, Android Studio and PyCharm have an option to show a warning if the commit subject line goes beyond a certain number of characters. It's switched off by default, but can be enabled independently in each project.

It would be extremely helpful if such a warning can be shown in this application too! I checked the Preferences window, but couldn't find any setting for that, so I assume this has not been implemented yet. If I am wrong, and this feature already exists, please let me know where to find it.

I have been using this application for the last few days, and find it extremely helpful. Especially because it can GPG-sign the commits, which no other git GUI application does currently (I have been through a lot of them, and every one lacks this feature.) Will be immensely helpful if this warning feature is implemented.

In case it matters, I am on Ubuntu 22.04.

love-linger commented 1 week ago

It's a new feature that is not supported by this app currently. I'll consider to add this feature later.

love-linger commented 1 week ago

I've pushed a simple implementation of this feature. Since the git traits all text before an empty line as subject, the subject length is not only include the first line. For example:

feature: xxxx
* a
* b

message

The subject of full commit message above is feature: xxxx * a * b. You can test this by git log --pretty=format:"%s".

%s in --pretty=format means to output commit's subject only.

In this implementation, there is a horizontal line to indicate where the subject ends. For example:

image image

You can test it from this build https://github.com/sourcegit-scm/sourcegit/actions/runs/9631824264

WrichikBasu commented 1 week ago

The horizontal line looks nice! Yes, git treats everything before the first blank line as subject, but GitHub treats anything after the first \n as body. Though I believe it's fine to stick to the current implementation; in general, it is not expected to use newlines in the subject. Tested it from the artifact and it worked fine.

One small improvement would be nice: I don't see any option to vertically decrease/increase the size of the commit message box. It would be helpful if one can decrease the vertical length of the Select File to View Changes box and thereby increase the vertical size of the commit message box.