Re: [Edgex-tsc-devops] Gofmt git commit hook

Fede Claramonte

I think it is easier just to add that test to the test rule in the makefile. It will not be run automatically in the developers machine, but anyone should run make test before doing a PR. And it does not need any change in the server or CI.


On 06/15/2018 10:51 PM, Jeremy Phelps wrote:

Yeah we will explore this further for sure.  I did confirm that we will not be able to do git hooks on GitHubs servers; it's an obvious security concern for them.  With some work we can make something with webhooks though.

On Fri, Jun 15, 2018 at 3:34 PM, <Trevor.Conn@...> wrote:

Dell - Internal Use - Confidential

Thanks, Jeremy. It looks like the git-hooks utility you linked to below would allow us to create a git-hooks directory in our repo and then put the appropriate scripts in there. This would allow us to source control the scripts.


It also looks like their “community hooks” would allow us to create a repo specifically for githook scripts. Then all we’d have to include in our projects is a githooks.json file like this one. Execution requires internet connectivity though, obviously.


We’d need to require all developers to install the utility if we go down this route.




From: [] On Behalf Of Jeremy Phelps
Sent: Friday, June 15, 2018 1:10 PM
To: Conn, Trevor
Subject: Re: [Edgex-tsc-devops] Gofmt git commit hook


Hi Trevor,

I am in favor of something like this generally.  I think because we use GitHub we will have to have client side hooks ( I will look into it further though ).  There are tools available to help share commit hook scripts such as  Lets put this on the table for discussion, we can ramp up the DevOps WG meetings again if we need extra time.



On Fri, Jun 15, 2018 at 12:12 PM, <Trevor.Conn@...> wrote:


Per our discussion in the Core WG call yesterday, I’m working today on looking for code quality tools that we can easily integrate and that will do as many of the required checks prior to merge as possible. I found the above git pre-commit script which can be used to run gofmt prior to commit on the client side. Sample output for poorly formatted code when I try to commit looks like this:


Go files must be formatted with gofmt. Please run:

  gofmt -w /Users/tconn/go/src/


I can't commit until I fix the problems. The only downside, as I understand it, is that it relies on the developer to create the scripts and give it execute permissions. Plus I don’t understand how this can be source controlled. It looks like there are server-side git hooks as well.


Would this be more appropriate as a server-side hook that runs during a push? If so, what’s the effort in setting that up in all Go repos? How about when we create new Go repos?


The script is linked from a larger blog post:


Using this strategy we could also wire in golint and other tools. Thoughts?


Trevor Conn
Senior Principal Software Engineer
Dell Technologies | IoT DellTech
Round Rock, TX  USA


Join to automatically receive all group messages.