Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scripts/pre-commit.git-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
# limitations under the License.

# First part return the files being commited, excluding deleted files.
git diff-index -z --cached HEAD --name-only --diff-filter=ACMRTUXB |
xargs --null --no-run-if-empty git lint;
DIFF=$(git diff-index -z --cached HEAD --name-only --diff-filter=ACMRTUXB)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename to something like DIFF_FILES.

if [ -z "$DIFF" ]
then
exit 0;
else
git lint;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is not exactly the same as the original script. The original script was linting only files being commited.

Here it should read something like:

echo $DIFF_FILES | xargs -0 git lint

The same applies for the mercurial hook.

fi

if [ "$?" != "0" ]; then
echo "There are some problems with the modified files.";
Expand Down
9 changes: 7 additions & 2 deletions scripts/pre-commit.hg-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ if [ "$NO_VERIFY" != "" ]; then
exit 0
fi

hg status --change $HG_NODE | cut -b 3- | tr '\n' '\0' |
xargs --null --no-run-if-empty git-lint;
DIFF=$(hg status --change $HG_NODE | cut -b 3- | tr '\n' '\0')
if [ -z "$DIFF" ]
then
exit 0;
else
git lint;
fi

if [ "$?" != "0" ]; then
echo "There are some problems with the modified files.";
Expand Down