Re: svn commit: r368736 - head/tools/tools/git/hooks

2020-12-28 Thread Alan Somers
On Mon, Dec 28, 2020 at 3:29 PM Ed Maste  wrote:

> On Mon, 28 Dec 2020 at 14:34, Alan Somers  wrote:
> >
> > On Thu, Dec 17, 2020 at 12:58 PM Ed Maste  wrote:
> >>
> >> Author: emaste
> >> Date: Thu Dec 17 19:58:29 2020
> >> New Revision: 368736
> >> URL: https://svnweb.freebsd.org/changeset/base/368736
> >>
> >> Log:
> >>   Add initial version of git commit message preparation hook
> >>
> > Thanks!  But how can we use it?  Is there a "git config" incantation
> that will use this file?
>
> Just copy it into .git/hooks/. Can also fetch the latest version
> directly from cgit; lwhsu added this to
> https://github.com/bsdimp/freebsd-git-docs/blob/main/URLs.md:
>
> fetch
> https://cgit.freebsd.org/src/plain/tools/tools/git/hooks/prepare-commit-msg
> -o
> 
> .git/hooks
> chmod 755 .git/hooks/prepare-commit-msg
>
> I'd like us to end up with a setup-repo.sh or such that will offer to
> take care of all of these things.
>
> >Also, this seems too complicated.  Git already has a "config.template"
> configuration variable.   Could we just use that instead, or does it not
> work for some reason?
>
> It does work, although it's a bit awkward. For one thing, the provided
> template is placed at the top of the message, followed by the default
> message, but our addition is really commented-out information and fits
> best in the middle of the existing text - after the "Please enter
> the..." and before the list of changes and such. With config.template
> we'd end up with something like:
>
> 
>
> # PR:   
> # ...
> # Differential Revision:
> #
> # Please enter the commit message for your changes. Lines starting
> # with '#' will be ignored, and an empty message aborts the commit.
> #
> # ...
> 
>
> Additionally we might want to make some more programmatic changes in
> the default message (depending on the resolution of some open
> questions). For example we could strip the "MFC after" line that's
> copied from the original commit, when preparing the commit message for
> a MFC/cherry-pick.
>

Thanks for the explanation.  It all makes sense, and the commit template
works.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r368736 - head/tools/tools/git/hooks

2020-12-28 Thread Ed Maste
On Mon, 28 Dec 2020 at 14:34, Alan Somers  wrote:
>
> On Thu, Dec 17, 2020 at 12:58 PM Ed Maste  wrote:
>>
>> Author: emaste
>> Date: Thu Dec 17 19:58:29 2020
>> New Revision: 368736
>> URL: https://svnweb.freebsd.org/changeset/base/368736
>>
>> Log:
>>   Add initial version of git commit message preparation hook
>>
> Thanks!  But how can we use it?  Is there a "git config" incantation that 
> will use this file?

Just copy it into .git/hooks/. Can also fetch the latest version
directly from cgit; lwhsu added this to
https://github.com/bsdimp/freebsd-git-docs/blob/main/URLs.md:

fetch 
https://cgit.freebsd.org/src/plain/tools/tools/git/hooks/prepare-commit-msg
-o .git/hooks
chmod 755 .git/hooks/prepare-commit-msg

I'd like us to end up with a setup-repo.sh or such that will offer to
take care of all of these things.

>Also, this seems too complicated.  Git already has a "config.template" 
>configuration variable.   Could we just use that instead, or does it not work 
>for some reason?

It does work, although it's a bit awkward. For one thing, the provided
template is placed at the top of the message, followed by the default
message, but our addition is really commented-out information and fits
best in the middle of the existing text - after the "Please enter
the..." and before the list of changes and such. With config.template
we'd end up with something like:



# PR:   
# ...
# Differential Revision:
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# ...


Additionally we might want to make some more programmatic changes in
the default message (depending on the resolution of some open
questions). For example we could strip the "MFC after" line that's
copied from the original commit, when preparing the commit message for
a MFC/cherry-pick.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r368736 - head/tools/tools/git/hooks

2020-12-28 Thread Alan Somers
On Thu, Dec 17, 2020 at 12:58 PM Ed Maste  wrote:

> Author: emaste
> Date: Thu Dec 17 19:58:29 2020
> New Revision: 368736
> URL: https://svnweb.freebsd.org/changeset/base/368736
>
> Log:
>   Add initial version of git commit message preparation hook
>
>   Start with a slightly modified version of the SVN commit template, to
>   allow developers to experiment.  This will be updated in the future as
>   our process and techniques evolve.
>
>   This can be installed by copying or symlinking into the .git/hooks/
>   directory.
>
>   Feedback from:cem, jhb
>   Reviewed by:  imp
>   Sponsored by: The FreeBSD Foundation
>   Differential Revision:https://reviews.freebsd.org/D27633
>
> Added:
>   head/tools/tools/git/hooks/
>   head/tools/tools/git/hooks/prepare-commit-msg   (contents, props changed)
>

Thanks!  But how can we use it?  Is there a "git config" incantation that
will use this file?  Also, this seems too complicated.  Git already has a
"config.template" configuration variable.   Could we just use that instead,
or does it not work for some reason?
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r368736 - head/tools/tools/git/hooks

2020-12-17 Thread Ed Maste
Author: emaste
Date: Thu Dec 17 19:58:29 2020
New Revision: 368736
URL: https://svnweb.freebsd.org/changeset/base/368736

Log:
  Add initial version of git commit message preparation hook
  
  Start with a slightly modified version of the SVN commit template, to
  allow developers to experiment.  This will be updated in the future as
  our process and techniques evolve.
  
  This can be installed by copying or symlinking into the .git/hooks/
  directory.
  
  Feedback from:cem, jhb
  Reviewed by:  imp
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D27633

Added:
  head/tools/tools/git/hooks/
  head/tools/tools/git/hooks/prepare-commit-msg   (contents, props changed)

Added: head/tools/tools/git/hooks/prepare-commit-msg
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/git/hooks/prepare-commit-msg   Thu Dec 17 19:58:29 
2020(r368736)
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+case "$2" in
+commit|message)
+   # It appears git invokes this script for interactive rebase but does
+   # not remove commented lines, so just exit if we're not called with the
+   # default (comment-containing) template.
+   egrep -q '^#' "$1" || return 0
+   ;;
+template)
+   return 0
+   ;;
+merge)
+   return 0
+   ;;
+esac
+
+outfile=$(mktemp /tmp/freebsd-git-commit.)
+cat >$outfile