Skip to content

Instantly share code, notes, and snippets.

View zeenix's full-sized avatar

Zeeshan Ali Khan zeenix

View GitHub Profile
@zeenix
zeenix / pre-commit
Created December 13, 2017 14:59
git hook to ensure commit doesn't break rustfmt
#!/bin/sh
# Put in your Rust repository's .git/hooks/pre-commit to ensure you never
# breaks rustfmt.
#
# WARNING: rustfmt is a fast moving target so ensure you have the version that
# all contributors have.
for FILE in `git diff --cached --name-only`; do
#if [[ $FILE == *.rs ]] && ! rustup run nightly rustfmt --write-mode diff --skip-children $FILE; then
@zeenix
zeenix / error.rs
Created November 24, 2017 13:55
WIP work to use failure in parts of habitat
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// Licensed 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,
@zeenix
zeenix / rustfmt-git-hook
Created November 20, 2017 17:03
Git pre-commit hook to ensure your changes don't break rustfmt formatting rules
#!/bin/sh
for FILE in `git diff --cached --name-only`; do
if [[ $FILE == *.rs ]] && ! rustfmt --write-mode diff --skip-children $FILE; then
echo "Commit rejected due to invalid formatting of \"$FILE\" file."
exit 1
fi
done