File: gitignore.t

package info (click to toggle)
xen-tools 4.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 1,476 kB
  • sloc: perl: 4,942; sh: 1,690; makefile: 268
file content (55 lines) | stat: -rwxr-xr-x 1,288 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!perl -w
#
#  Test that .gitignore is coherent
#
# Stéphane (kwisatz) Jourdois
# --
#

use strict;
use Test::More;
use File::Which;

if ( $ENV{TRAVIS} ) {
    plan( skip_all => "these tests don't make sense on a fresh checkout" );
}

if (which('git') and -d '.git') {
    plan tests => 3;
} else {
    plan skip_all => 'gitignore test is only thought for release testing.';
}

use_ok( 'Git' );

# First, check that no tracked files are ignored
my $cmd = Git::command_output_pipe('ls-files', '--cached', '--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");