You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Tomoko Uchida (Jira)" <ji...@apache.org> on 2021/07/17 13:51:00 UTC

[jira] [Commented] (LUCENE-10028) Optionally allow to enable git pre-commit hook for precommit

    [ https://issues.apache.org/jira/browse/LUCENE-10028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17382564#comment-17382564 ] 

Tomoko Uchida commented on LUCENE-10028:
----------------------------------------

I opened a draft PR to provide a working example; this works for me (on linux setup) but isn't perfect. If there is anyone who is interested in it, I think we can refine or finish the implementation.

> Optionally allow to enable git pre-commit hook for precommit
> ------------------------------------------------------------
>
>                 Key: LUCENE-10028
>                 URL: https://issues.apache.org/jira/browse/LUCENE-10028
>             Project: Lucene - Core
>          Issue Type: Task
>          Components: general/build
>            Reporter: Tomoko Uchida
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> With [githooks|https://git-scm.com/docs/githooks], one can automatically perform arbitrary checks (e.g. "precommit") when before performing "git commit".
> I found the "precommit" check is now pretty fast on main branch, it might make sense for developers who want to run it in an automated manner (to prevent premature commits ore push).
> *Implementation*
> Hooks are just plain shell scripts that are placed in .git/hooks, so we can provide a simple executable "pre-commit" script that runs "gradlew precommit" and a gradle Copy task to copy it under local .git/hooks dir.
> *Usage*
> Install pre-commit hook (opt-in)
> {code:java}
> ./gradlew precommitHook
> {code}
> After installing, precommit will be automatically performed before every commit.
> {code:java}
> git commit -m "commit attempt that doesn't pass spotless check"
> ......
> > Task :lucene:luke:spotlessJavaCheck FAILED
> FAILURE: Build failed with an exception.
> * What went wrong:
> Execution failed for task ':lucene:luke:spotlessJavaCheck'.
> > The following files had format violations:
> ......
> // commit fails.
> {code}
> As another option, one could use pre-push hook.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org