Koooooo-7 commented on issue #13413:
URL: https://github.com/apache/dubbo/issues/13413#issuecomment-1855878727

   > However, can we make a repo only pre-commit hook automatically?
   
   Technically, yes. 
   But it may need some dirty thing to implement it since Java world seems no 
something like `husky` in node.
   
   When contributors clone the project,  the `.git` folder and  the 
`.git/hooks/<hooks>.example` are auto generated,  all of those hook files are 
marked executable already.
   
   A feasible way is using the mvn lifecycle plugin (such as 
`exec-maven-plugin`) to run a lite java file (e.g. java gitHooks.java) to 
modify the `.git/hook/pre_commit.example` to `.git/hook/pre_commit` and append 
`mvn` commands into it, such as `mvn spotless`.
   
   What the prerequisite we need is there must have Java env when the 
`gitHooks.java` launched (Normally, it should be).
   It should work and we don't need consider about cross OS things as we don't 
create the `hook` directly and do something like `chmod +x`.
   
   ---
   Besides the assumptions above.
   IMO, for now, we could just add lint check in CI (In action, run `mvn 
spotless`,  check if contains no-staged files), let the guideline(PR template) 
stipulates how to do contribution and format.
   The format automation solution could put on the table later until there has 
more neat pre-commit hooks solution.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to