[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
commit message helpers (was Re: How can we decrease the cognitive overhe
From: |
Giovanni Biscuolo |
Subject: |
commit message helpers (was Re: How can we decrease the cognitive overhead for contributors?) |
Date: |
Wed, 30 Aug 2023 14:33:12 +0200 |
Hello,
Andreas Enge <andreas@enge.fr> writes:
> Am Wed, Aug 30, 2023 at 02:22:01AM +0200 schrieb Danny Milosavljevic:
>> Writing the metadata into the commit messages is annoying. It totally should
>> be automated, especially since Scheme has pretty simple syntax (so it should
>> be easy to write such a thing/famous-last-words). It should just figure out
>> which procedures the changed lines were in, automatically.
>
> It does exist inside git itself for C code; "git diff" always shows
in the hunk header
> the function in which I make a change.
Does this mean that the function/procedure of the specific language - C
in this case - is/can be automatically provided in the generated draft
commit message by parsing the "git diff" output?
> I agree it should be easy to have the same support for scheme.
The documentation for this git feature is here:
«Defining a custom hunk-header»
https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header
All is needed is to enable one of the built in patterns via
.gitattributes; in the Guix git root we defined this:
--8<---------------cut here---------------start------------->8---
*.scm diff=scheme
*.scm.in diff=scheme
*.texi diff=texinfo
--8<---------------cut here---------------end--------------->8---
This means that when doing "git diff" in a Guix worktree we get
something like:
--8<---------------cut here---------------start------------->8---
[~/{git}/giovanni.biscuolo.net/guix/gnu/packages]
giovanni@roquette: git diff
diff --git a/gnu/packages/abiword.scm b/gnu/packages/abiword.scm
index 1635ed54fd..a9c937c39b 100644
--- a/gnu/packages/abiword.scm
+++ b/gnu/packages/abiword.scm
@@ -56,7 +56,7 @@ (define-public abiword
(string-append "https://www.abisource.com/downloads/abiword/" version
"/source/abiword-" version ".tar.gz"))
(sha256
- (base32 "1d1179pnslijpjhz1q155fsc828rrlqf7lsn2inqsl3hk5z28mqj"))
+ (base32 "BOGUS"))
(patches
(search-patches "abiword-explictly-cast-bools.patch"))))
@@ -67,7 +67,7 @@ (define-public abiword
"--enable-clipart" ;; TODO: The following plugins have unresolved
"--enable-templates" ;; dependencies: aiksaurus, grammar, wpg, gda,
(string-append ;; wordperfect, psion, mathview.
- "--enable-plugins="
+ "--enable-plugins= FIXME"
"applix " "babelfish " "bmp " "clarisworks " "collab " "command "
"docbook " "eml " "epub " "freetranslation " "garble " "gdict "
"gimp " "goffice " "google " "hancom " "hrtext " "iscii " "kword
"
--8<---------------cut here---------------end--------------->8---
In the example above have two hunk headers:
1. @@ -56,7 +56,7 @@ (define-public abiword
2. @@ -67,7 +67,7 @@ (define-public abiword
each one showing the function I modified.
Furthermore, "git diff -W" (or --function-context) will show the whole
function in the hunk:
--8<---------------cut here---------------start------------->8---
[~/{git}/giovanni.biscuolo.net/guix/gnu/packages]
giovanni@roquette: git --no-pager diff -W
diff --git a/gnu/packages/abiword.scm b/gnu/packages/abiword.scm
index 1635ed54fd..a9c937c39b 100644
--- a/gnu/packages/abiword.scm
+++ b/gnu/packages/abiword.scm
@@ -48,89 +48,89 @@ (define-module (gnu packages abiword)
(define-public abiword
(package
(name "abiword")
(version "3.0.5")
(source
(origin
(method url-fetch)
(uri
(string-append "https://www.abisource.com/downloads/abiword/" version
"/source/abiword-" version ".tar.gz"))
(sha256
- (base32 "1d1179pnslijpjhz1q155fsc828rrlqf7lsn2inqsl3hk5z28mqj"))
+ (base32 "BOGUS"))
(patches
(search-patches "abiword-explictly-cast-bools.patch"))))
(build-system glib-or-gtk-build-system)
(arguments ;; NOTE: rsvg is disabled, since Abiword
`(#:configure-flags ;; supports it directly, and its BS is broken.
(list ;; wmf was removed from Guix for security.
"--enable-clipart" ;; TODO: The following plugins have unresolved
"--enable-templates" ;; dependencies: aiksaurus, grammar, wpg, gda,
(string-append ;; wordperfect, psion, mathview.
- "--enable-plugins="
+ "--enable-plugins= FIXME"
"applix " "babelfish " "bmp " "clarisworks " "collab " "command "
[...]
(license license:gpl2+)))
--8<---------------cut here---------------end--------------->8---
As you can see, here the hunk header is:
3. @@ -48,89 +48,89 @@ (define-module (gnu packages abiword)
showing the function in with "define-public abiword" is defined.
I don't know if this is/could be used to automatically set a more helpful
commit message draft, but this helps to "figure out which procedures the
changed lines were in, automatically."
WDYT?
Also, I can't find if there is some plan or feature request to add
tree-sitter support in the "git diff" parser, but that could be a great
improvement IMO, since it will allow git users to use all tree-sitter
available parsers and not just pattern matching to understand/show the
context in which the changes happened.
In this context, I found this two currently active project of
tree-sitter based diff tools:
1. Difftastic https://difftastic.wilfred.me.uk/
2. diffsitter https://github.com/afnanenayet/diffsitter
Both can be used as external "git difftool"s [1] [2]
None is currently packaged in Guix.
Happy hacking! Gio'
[1] https://difftastic.wilfred.me.uk/git.html#git-difftool
[2] https://github.com/afnanenayet/diffsitter#git-integration
--
Giovanni Biscuolo
Xelera IT Infrastructures
signature.asc
Description: PGP signature