-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: More Verbose Auto-Commit Messages #51
Comments
Apologies for the late reply! I was on vacation for a bit. I think this is a great idea, and I actually already do this for my GistPad extension. Out of curiosity: are you mostly interested in the commit message that includes the impacted file names and operation? Or did you also want to include the conventional commit prefix? |
I'd like to have the list of changed files. I don't know why, perhaps because Gitlab did it this way. |
I'd love this too! FWIW I've written a script to do this in the past using the output of Here's the scripts, in case they're helpful for anybody else: # file: ~/.gitconfig
...
[alias]
summary = "!git status --porcelain=v1 -z | jq -rR git_summarize_changes"
commit-on-save = "!set -x; fswatch -l20 -0b . | xargs -0n1 git ls-files -z | xargs -0n1 bash -c 'git add -A && git commit -m \"$(git summary)\" && git push'" # file: ~/.jq
...
def git_summarize_changes: (
[
scan("(?x)
(?: \\A | \\G )
(?<index_status> (?<is_rename>[RC]) | [^RC] )
(?<worktree_status> . )
[ ]
(?<path> [^\u0000]+ )
(?(<is_rename>) \u0000 (?<renamed_from> [^\u0000]+ ) )
(?: \\Z | \u0000 )
")
| . as [$index_status, $_, $__, $path, $renamed_path]
| {$index_status, $path, $renamed_path}
]
| length as $num_files
| group_by(.index_status)
| map(
# https://git-scm.com/docs/git-status#_short_format
({
"M": "update",
"A": "add",
"D": "delete",
"R": "rename",
"C": "copy",
"T": "change type of",
}[.[0].index_status] // empty)
+ " "
+ (
if $num_files == 1
then .[] | .path + (if .renamed_path then " from " + .renamed_path else "" end)
else "\(length) file" + (if length == 1 then "" else "s" end)
end
)
)
| if length == 0
then error("No staged git changes")
else
join(", ")
| (.[0:1] | ascii_upcase) + .[1:]
end
); I think I did some manual testing when I first wrote this (the details of which have been lost to time), but hopefully it's a starting point. |
A prefix might be nice, yes. Perhaps "auto" is a good prefix to have by default, though. |
Does this look close to what you have in mind? https://copilot-workspace.githubnext.com/lostintangent/gitdoc/issues/51?shareId=4f167bda-f665-4e96-9dd8-25850bf01eab |
There's a different extension out there, which can create more detailed commit messages. Even when squashed, it might help to have these details from something like gitdoc. They more closely resemble the so-called Conventional Commits.
I thought to share it here and request this functionality, as it doesn't seem the two work together very well.
The text was updated successfully, but these errors were encountered: