tripleo-quickstart/ci-scripts/pre-commit.d/validate-yaml-in-commit
Sorin Sbarnea 4a41ca7bf0 Lint fixes for ci-scripts and config folders
This normalizes the formatting of files from ci-scripts and config
folders in order to allow further hardening of linting.

Fixing linting was too big to be made in a single commit as it would
involve too many files to review and could merge conflicts with
existing changes. Thus doing it in few chunks would makes it possible.

Original full change is at https://review.openstack.org/#/c/627545/ and
will be the one merging the last.

Change-Id: Ifb215c0e2ea0ef7115897721f75ba8489bd59b97
2018-12-28 10:01:11 +00:00

19 lines
568 B
Bash
Executable File

#!/bin/sh
SCRIPTS="$PWD/ci-scripts"
tmpdir=$(mktemp -d commitXXXXXX)
trap "rm -rf $tmpdir" EXIT
# This checks out the index into a temporary directory, which is
# necessary if you want to validate the files that are actually
# part of the commit (because when performing an interactive add,
# for example, files in a commit may not actually match the content
# of files in the working directory).
git checkout-index --prefix=$tmpdir/ -af
git diff --cached --name-only --diff-filter=ACM | grep '.yml' | (
cd $tmpdir
xargs --no-run-if-empty $SCRIPTS/validate-yaml
)