1
0
mirror of synced 2026-02-09 17:21:11 +00:00

Add a gitignore coherency test

This tests helps to maintain .gitignore up to date, by :
 - testing if all ignored files have to be ignored, and
 - testing if all untracked files are ignored.

[ Note : second version ]
Make test work on older git versions
I.e. the git version used on Debian stable.
This commit is contained in:
Stéphane Jourdois
2010-07-18 15:40:41 +02:00
committed by Stéphane Jourdois
parent c59eb9aba4
commit 85acd315bd
2 changed files with 47 additions and 3 deletions

5
.gitignore vendored
View File

@@ -1,6 +1,5 @@
# Note! Please use 'git ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
# Note! Please run 'prove t/gitignore.t' after changing
# this file, to check its coherency
# all dotfiles
.*

45
t/gitignore.t Normal file
View File

@@ -0,0 +1,45 @@
#!/usr/bin/perl -w
#
# Test that .gitignore is coherent
#
# Stéphane (kwisatz) Jourdois
# --
#
use strict;
use Test::More tests => 3;
BEGIN { use_ok( 'Git' ); }
# First, check that no tracked files are ignored
my $cmd = Git::command_output_pipe('ls-files', '--ignored', '--exclude-standard');
my $output;
while (<$cmd>) { $output .= "--> $_" }
close $cmd;
ok(!defined $output, 'No tracked file is ignored')
or diag(<<EOF
Check that the following tracked files _have_to_ be ignored, and then either :
- 'git rm' them
- modify .gitignore to not ignore them
EOF
. $output . "\n");
# Now, check that no untracked files are present
$cmd = Git::command_output_pipe('ls-files', '--others', '--exclude-standard');
undef $output;
while (<$cmd>) { $output .= "--> $_" }
close $cmd;
ok(!defined $output, 'No untracked file is present')
or diag(<<EOF
Check whether the following untracked files have to be ignored or
tracked, and either :
- 'git add' them
- modify .gitignore to ignore them
EOF
. $output . "\n");