~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to misc/git/pre-commit

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# Copyright 2012 The Go Authors. All rights reserved.
 
3
# Use of this source code is governed by a BSD-style
 
4
# license that can be found in the LICENSE file.
 
5
 
 
6
# git gofmt pre-commit hook
 
7
#
 
8
# To use, store as .git/hooks/pre-commit inside your repository and make sure
 
9
# it has execute permissions.
 
10
#
 
11
# This script does not handle file names that contain spaces.
 
12
 
 
13
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$')
 
14
[ -z "$gofiles" ] && exit 0
 
15
 
 
16
unformatted=$(gofmt -l $gofiles)
 
17
[ -z "$unformatted" ] && exit 0
 
18
 
 
19
# Some files are not gofmt'd. Print message and fail.
 
20
 
 
21
echo >&2 "Go files must be formatted with gofmt. Please run:"
 
22
for fn in $unformatted; do
 
23
        echo >&2 "  gofmt -w $PWD/$fn"
 
24
done
 
25
 
 
26
exit 1