-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from youtube/repo-improvements
Add hooks and PS1 for Go.
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
# Copyright 2012 The Go Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style | ||
# license that can be found in the LICENSE file. | ||
|
||
# git gofmt pre-commit hook | ||
# | ||
# To use, store as .git/hooks/pre-commit inside your repository and make sure | ||
# it has execute permissions. | ||
# | ||
# This script does not handle file names that contain spaces. | ||
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$') | ||
|
||
[ -z "$gofiles" ] && exit 0 | ||
unformatted=$(gofmt -l=true $gofiles 2>&1 | awk -F: '{print $1}') | ||
[ -z "$unformatted" ] && exit 0 | ||
|
||
# Some files are not gofmt'd. Print message and fail. | ||
|
||
echo >&2 "Go files must be formatted with gofmt. Please run:" | ||
echo -n >&2 " gofmt -w" | ||
for fn in $unformatted; do | ||
echo -n >&2 " $PWD/$fn" | ||
done | ||
echo | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# Runs any hooks in mic/git/hooks, and exits if any of them fail. | ||
set -e | ||
|
||
# This is necessary because the Emacs extensions don't set GIT_DIR. | ||
if [ -z "$GIT_DIR"]; then | ||
GIT_DIR="$(pwd)/.git" | ||
fi | ||
for hook in $GIT_DIR/../misc/git/hooks/*; do | ||
$hook | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Source this file in your shell to get the current git branch name in | ||
# the prompt. | ||
|
||
# parse_git_branch echoes the name of the current branch followed by a | ||
# space (if its not nil). | ||
function parse_git_branch { | ||
branch=$(git branch --no-color 2> /dev/null |grep '*'|awk '{print $2}') | ||
if [ ! -z $branch ]; then | ||
echo " $branch" | ||
fi | ||
} | ||
PS1='\A [\j] (\u \[\e[1;34m\]\h\[\e[m\]):\w\[\e[0;31m\]$(parse_git_branch)\[\e[m\]\$ ' |