Browse Source

dib-lint: Ignore editor temp files for linting run

When running dib-lint vi temp files .*.sw? files are included which leads to
false positives.  ALso all editor files are checked when looking at indents,
again this results in false positives.

Exclude those files by checking if they're in the user/project's
.gitignore setup.

Change-Id: I0a48174f22a8dad9e8f15bf3f70835d021a2d46f
tags/2.7.0
Tony Breeds 1 year ago
parent
commit
f12b1310ef
2 changed files with 12 additions and 5 deletions
  1. 1
    0
      .gitignore
  2. 11
    5
      bin/dib-lint

+ 1
- 0
.gitignore View File

@@ -4,6 +4,7 @@ cover/*
4 4
 *~
5 5
 .testrepository
6 6
 *.sw?
7
+#*#
7 8
 *.pyc
8 9
 .tox
9 10
 *.egg

+ 11
- 5
bin/dib-lint View File

@@ -73,14 +73,15 @@ trap "rm -rf $TMPDIR" EXIT
73 73
 
74 74
 # note .py files are run through flake8 directly in tox.ini
75 75
 for i in $(find $ELEMENTS_DIR -type f \
76
-                -not -name \*~        \
77
-                -not -name \#\*\#     \
78
-                -not -name \*.orig    \
79 76
                 -not -name \*.rst     \
80 77
                 -not -name \*.yaml    \
81
-                -not -name \*.py      \
82
-                -not -name \*.pyc); do
78
+                -not -name \*.py); do
83 79
 
80
+    # Skip files in .gitignore
81
+    if git check-ignore -q "$i" ; then
82
+        echo Skipping $i
83
+        continue
84
+    fi
84 85
     echo "Checking $i"
85 86
 
86 87
     exclusions=("$(parse_exclusions $i)")
@@ -232,6 +233,11 @@ echo "Checking indents..."
232 233
 
233 234
 for i in $(find $ELEMENTS_DIR -type f -and -name '*.rst' -or -type f -executable) \
234 235
              $(find $LIB_DIR -type f); do
236
+    # Skip files in .gitignore
237
+    if git check-ignore -q "$i" ; then
238
+        echo Skipping $i
239
+        continue
240
+    fi
235 241
     # Check for tab indentation
236 242
     if ! excluded tabindent; then
237 243
         if grep -q $'^ *\t' ${i}; then

Loading…
Cancel
Save