davids5 commented on a change in pull request #448: Add a sample of git pre-commit hook URL: https://github.com/apache/incubator-nuttx/pull/448#discussion_r389883624
########## File path: tools/git-hooks/pre-commit ########## @@ -0,0 +1,30 @@ +#!/bin/sh + +############################################################################ +# tools/git-hooks/pre-commit +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +# This file is intended to be used as .git/hooks/pre-commit + +if ! type nxstyle > /dev/null 2>&1; then Review comment: @xiaoxiang781216 Make can run all the pieces. Please do not only think abut this ONLY the way you have to work. Good tools solve everyone problems are self documenting. What if a user is doing a style cleanup NOW and not concerned about about licenses in the PR? The documentation of the script tools is poor. There are no examples of what the arguments take as values. Forcing a user to decodes the script when it is not necessary is not inviting. Why is it it tools/configure.sh imx-1060evk/nsh not `make imx-1060evk/nsh'? A lot of pieces all over the place is fine jut keep them out the the users face and have reasonable granularity. Yes, we can add more small step like spell/copyright, but it's better that: 1.Implment these check as the bash script or program 2.Invoke them from Makefile/checkpatch.sh/pre-commit 3.check_patch should be the target invoked in normal case, so we can improve the action as need with the furture workflow. Other targets can be used in the special case. > The correct version is always the latest one on the master, we need rebase/cherry-pick our patch with the master anyway, why don't we run checkpatch.sh before sending PR? No we do not. I explained this already (in email and comments) that work flow is a waste of time and effort with back and forth chery-picking. You do not have a good 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services