Thanks for your contribution!

I think you can write docs as the following procedures:
- As you have already written detailed document in your PR with Markdown. You 
can just copy them and add README.md to tools/git-hooks/ . 
- Write a short description with the hyperlink to the new README.md at 
docs/Development/ContributeGuide.md in English. You can use a level-2 
header(Starts with ##) between 'Code Style' and 'Contributing Guide' section. 
The title is as you like, maybe it's called 'Use git-hooks'.
- Write the same content but in Chinese in file 
zh/Development/ContributeGuide.md .

After your code is merged, the daily site build will recompile the markdown 
files. I think for developers who learns the contribute guide will get the 
usage of git-hooks smoothly.

在 2022/6/22 15:48,“Ke Lin”<linkyy2000...@gmail.com> 写入:

    LOL I make it!

    PR 
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Fiotdb%2Fpull%2F6380&amp;data=05%7C01%7C%7C8628dc8797cb4ffffc2a08da54238abb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637914808877793519%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=SiLFMp68aAt8rd0XARZW7NUA%2FDtOJb%2BFuSP57tatrT4%3D&amp;reserved=0
 gives the details. I wonder if
    I have to place the doc to somewhere else?


    Eric Pai <ericpa...@hotmail.com> 于2022年6月21日周二 09:50写道:

    > Got it! If we use shell script, we should consider both mac/Linux/Windows
    > environment, as we have lots of developers using Windows, coding with
    > powershell is not easy. and the usage of same command may be different in
    > Mac and Linux.
    > If we use Python or Ruby, or any other interpreted programming language,
    > we should check whether the developing machine has those interpreters
    > before executing.
    > So it's better to add the pre-hook and disable it by default. Developers
    > can set some environment variables as you said to enable it if needed.
    >
    > 在 2022/6/21 00:40,“Ke Lin”<linkyy2000...@gmail.com> 写入:
    >
    >     Thanks for your advice!
    >
    >     After reading the doc of git-hooks
    >     <
    > 
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit-scm.com%2Fbook%2Fen%2Fv2%2FCustomizing-Git-Git-Hooks&amp;data=05%7C01%7C%7C8628dc8797cb4ffffc2a08da54238abb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637914808878106412%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=uWA0t87MuoWYTX%2BRsCT5mknc9pY6yHOjeKfB5czgAGI%3D&amp;reserved=0>,
    > I probably
    >     found some solutions:
    >     1. Git-hooks are executable scripts in fact, e.g., shell scripts, ruby
    > or
    >     python. So we can define our rules for the linter reports.
    >     2. To reduce the maven overhead, we may do some tricks to the
    > executable
    >     scripts and validate only on the changed code. But I'm not pretty sure
    > if
    >     it's viable.
    >     3. Env variables should work well with the hook scripts to control the
    >     pre-commit pipeline.
    >
    >     Eric Pai <ericpa...@hotmail.com> 于2022年6月20日周一 20:55写道:
    >
    >     > This is a very helpful tool for developers!
    >     >
    >     > In IoTDB we have not only code formatter, the spotless, but also the
    > code
    >     > linter, checkstyle. In maven we can run ‘mvn validate‘ to run checks
    > of
    >     > both the linter and formatter, or 'mvn validate -pl <module_name>'
    > to check
    >     > one or more particular modules. However, unlike 'mvn 
spotless:apply',
    >     > there's no way to automatically fix the linter error, as it needs
    > more
    >     > semantic information. E.g. we forbid to use wildcard import in Java
    > codes,
    >     > but the linter doesn’t know which class we really want to import, so
    > I have
    >     > some suggestions for this tool.
    >     >
    >     > 1. If we want to let pre-commit hook reformat the code 
automatically,
    >     > could we also report whether there're any violations of the linter
    > rules?
    >     > 2. Running a maven command is a heavy operation as it will launch a
    > JVM. I
    >     > have tested in my desktop running 'mvn validate' and 'mvn
    > spotless:apply'.
    >     > They cost 90 and 55 seconds, it's too long to wait for a commit. Can
    > the
    >     > hook be wisely to choose the modules whose codes are updated to run
    > only?
    >     > For example I just change the codes in confignode module, so it's 
not
    >     > necessary to run the check in the module server, jdbc, session...
    >     > 3. It's necessary to give some docs to explain how to enable/disable
    > this
    >     > tool easily. It means that developers can change this through their
    > local
    >     > git config, not forcefully restricted by the git-hook script. For
    > some
    >     > developer who has followed the ContributeGuide [1] to config his IDE
    > well,
    >     > the formatter will be automatically run after file saving. This tool
    > is
    >     > less helpful for them.
    >     >
    >     > [1]
    >     >
    > 
https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fiotdb.apache.org%2FDevelopment%2FContributeGuide.html%23code-formatting&amp;data=05%7C01%7C%7C8628dc8797cb4ffffc2a08da54238abb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637914808878106412%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=widk89VLhU%2B41G%2BaWV8I2nKHzJttjecF3P1%2B7kWxqRQ%3D&amp;reserved=0
    >     >
    >     > -----邮件原件-----
    >     > 发件人: 林地宁宁 <linkyy2000...@gmail.com>
    >     > 发送时间: 2022年6月20日 19:21
    >     > 收件人: dev@iotdb.apache.org
    >     > 主题: Add `pre-commit-hooks` for pre-commit checks
    >     >
    >     > Hi guys!
    >     >
    >     > AFAIK, we have some style checks in CI/CD. As a novice here, I find
    > it
    >     > quite annoying to remember the checks before I commit.
    >     >
    >     > So how about adding some pre-commit hooks to do these checks for us,
    > such
    >     > as `mvn spotless:apply`.
    >     >
    >     > Though there are some small questions here:
    >     > 1. Which checks or operations should be done by pre-commit hooks?
    >     > 2. If a pre-commit check failed, should it throw the error and stop
    > the
    >     > commit? Or just apply the modifications to finish the commit?
    >     >
    >     > Any suggestions?
    >     >
    >     >
    >     > --
    >     > Kind regards,
    >     > Ke Lin
    >     >
    >
    >

Reply via email to