git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 1/2] hooks: allow input from stdin for commit-related hooks

From
Orgad Shaneh <orgads@gmail.com>
Date
Nov 20, 2020, 12:34 UTC
Message-ID
<CAGHpTB+LzXTNp3UGia6bdEDqV=mjAY+JQkO3aeUmddhYa1xajw@mail.gmail.com>
In-Reply-To
<87sg94pa45.fsf@evledraar.gmail.com>

On Fri, Nov 20, 2020 at 12:59 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 11 quoted lines
>
>
> On Fri, Nov 20 2020, Orgad Shaneh wrote:
>
> > Can you suggest an alternative way to determine if I can accept user
> > input from the console or not?
>
> Like Eric noted in his reply I can't think of a way to do that
> particular thing reliably either, and agree with his comments that if
> such a way is found / some aspect of this change is kept having this
> explanation in the patch/commit message is really helpful.
I'll reword.
Show 11 quoted lines
> I think what you're trying to do here isn't a good fit for most git
> workflows. Instead of trying to interactively compose a commit message
> why not change the commit template to start with e.g.:
>
>     # You must replace XXX with an issue number here!:
>     Issue #XXX:
>
> That gives the user the same thing to fill out, but in their editor
> instead of via some terminal/GUI prompt. They need to write the rest of
> the commit message anyway in the editor, so even if you could why open
> up two UIs?

We do have a template. The hook pops a listbox with all the open issues assigned to the user, which he/she can easily pick from, instead of searching for them in the browser and copying the issue id. This is only done if the user doesn't write an issue in the commit message.

> Projects that have these conventions also typically settle on just not
> trying to solve this problem on the client-side, but e.g. having a
> pre-receive hook that does the validation, or do it via CI / before a
> merge to master happens etc.
We have validation on the server too. The hook is there for convenience.
- Orgad
Previous: Ævar Arnfjörð BjarmasonNext: Orgad Shaneh via GitGitGadget
Message 18 of 22 in “hooks: allow input from stdin”
  1. hooks: allow input from stdinOrgad Shaneh via GitGitGadget, Nov 17, 2020
  2. Junio C HamanoNov 17, 2020
  3. hooks: allow input from stdinOrgad Shaneh via GitGitGadget, Nov 19, 2020
  4. hooks: allow input from stdin for commit-related hooksOrgad Shaneh via GitGitGadget, Nov 19, 2020
  5. Junio C HamanoNov 19, 2020
  6. Orgad ShanehNov 19, 2020
  7. 0/2 hooks: allow input from stdin for commit-related hooksOrgad Shaneh via GitGitGadget, Nov 19, 2020
  8. 2/2 commit: fix stdin conflict between message and hookOrgad Shaneh via GitGitGadget, Nov 19, 2020
  9. 1/2 hooks: allow input from stdin for commit-related hooksOrgad Shaneh via GitGitGadget, Nov 19, 2020
  10. Eric SunshineNov 19, 2020
  11. Junio C HamanoNov 19, 2020
  12. Orgad ShanehNov 20, 2020
  13. Eric SunshineNov 20, 2020
  14. Eric SunshineNov 20, 2020
  15. Orgad ShanehNov 20, 2020
  16. Junio C HamanoNov 20, 2020
  17. Ævar Arnfjörð BjarmasonNov 20, 2020
  18. Orgad ShanehNov 20, 2020
  19. 0/2 hooks: allow input from stdin for commit-related hooksOrgad Shaneh via GitGitGadget, Dec 9, 2020
  20. 1/2 hooks: lay foundations for passing stdin to hooksOrgad Shaneh via GitGitGadget, Dec 9, 2020
  21. 2/2 hooks: allow input from stdin for commit-related hooksOrgad Shaneh via GitGitGadget, Dec 9, 2020
  22. Junio C HamanoDec 9, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.