Skip to contentSkip to conversation

run-flake8: Filter out ./.git/ directory

PATCH Applied Petr Lautrbach 3 participants 4 messages May 11, 2020 – May 13, 2020 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 run-flake8: Filter out ./.git/ directory

When a branch has '.py' suffix git creates a file with the same suffix and this file is found by the find . -name '*.py' command. Such files from './git' need to be filtered out.

Fixes:

    $ PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8
    Analyzing 189 Python scripts
    ./.git/logs/refs/heads/semanage-test.py:1:42: E999 SyntaxError: invalid syntax
    ./.git/refs/heads/semanage-test.py:1:4: E999 SyntaxError: invalid syntax
    The command "PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8" exited with 1.
---
 scripts/run-flake8 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/run-flake8 +1 -1
index 24b1202fde99..67cccfe99e5f 100755
@@ -7,7 +7,7 @@ if [ $# -eq 0 ] ; then
 
     # Run on both files ending with .py and Python files without extension
     # shellcheck disable=SC2046
-    set -- $( (find . -name '*.py' ; grep --exclude-dir=.git -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | sort -u )
+    set -- $( (find . -name '*.py' ; grep -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | grep -v '^\./\.git/' | sort -u )
     echo "Analyzing $# Python scripts"
 fi
 
Signature · 1 line
2.26.2
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Petr Lautrbach

When a branch has '.py' suffix git creates a file with the same suffix and this file is found by the find . -name '*.py' command. Such files from './git' need to be filtered out.

Fixes:

Quoted 7 lines
    $ PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8
    Analyzing 189 Python scripts
    ./.git/logs/refs/heads/semanage-test.py:1:42: E999 SyntaxError: invalid syntax
    ./.git/refs/heads/semanage-test.py:1:4: E999 SyntaxError: invalid syntax
    The command "PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8" exited with 1.

Thanks!
Nicolas

Quoted 20 lines
---
 scripts/run-flake8 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/run-flake8 +1 -2
index 24b1202fde99..67cccfe99e5f 100755
@@ -7,7 +7,7 @@ if [ $# -eq 0 ] ; then
 
     # Run on both files ending with .py and Python files without extension
     # shellcheck disable=SC2046
-    set -- $( (find . -name '*.py' ; grep --exclude-dir=.git -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | sort -u )
+    set -- $( (find . -name '*.py' ; grep -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | grep -v '^\./\.git/' | sort -u )
     echo "Analyzing $# Python scripts"
 fi
 
--

2.26.2

author Applied
#2 lore raw
In reply to Petr Lautrbach
Quoted 6 lines · Petr Lautrbach

When a branch has '.py' suffix git creates a file with the same suffix and this file is found by the find . -name '*.py' command. Such files from './git' need to be filtered out.

Fixes:

Quoted 8 lines
    $ PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8
    Analyzing 189 Python scripts
    ./.git/logs/refs/heads/semanage-test.py:1:42: E999 SyntaxError: invalid syntax
    ./.git/refs/heads/semanage-test.py:1:4: E999 SyntaxError: invalid syntax
    The command "PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8" exited with 1.

Applied.

Quoted 17 lines
---
 scripts/run-flake8 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/run-flake8 +1 -1
index 24b1202fde99..67cccfe99e5f 100755
@@ -7,7 +7,7 @@ if [ $# -eq 0 ] ; then
 
     # Run on both files ending with .py and Python files without extension
     # shellcheck disable=SC2046
-    set -- $( (find . -name '*.py' ; grep --exclude-dir=.git -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | sort -u )
+    set -- $( (find . -name '*.py' ; grep -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | grep -v '^\./\.git/' | sort -u )
     echo "Analyzing $# Python scripts"
 fi
 
Signature · 2 lines
()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments
#3 lore raw
Quoted 14 lines · Petr Lautrbach
Quoted 12 lines · Petr Lautrbach

When a branch has '.py' suffix git creates a file with the same suffix and this file is found by the find . -name '*.py' command. Such files from './git' need to be filtered out.

Fixes:

    $ PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8
    Analyzing 189 Python scripts
    ./.git/logs/refs/heads/semanage-test.py:1:42: E999 SyntaxError: invalid syntax
    ./.git/refs/heads/semanage-test.py:1:4: E999 SyntaxError: invalid syntax
    The command "PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8" exited with 1.
Quoted 4 lines
Quoted 2 lines

Applied.

I updated the state to accepted in Patchwork

Quoted 22 lines
Quoted 10 lines
---
 scripts/run-flake8 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/run-flake8 +0 -0
index 24b1202fde99..67cccfe99e5f 100755

scripts/run-flake8 if [ $# -eq 0 ] ; then · line 13

Quoted 8 lines
scripts/run-flake8 +1 -1
@@ -7,7 +7,7 @@ if [ $# -eq 0 ] ; then
 
     # Run on both files ending with .py and Python files without extension
     # shellcheck disable=SC2046
-    set -- $( (find . -name '*.py' ; grep --exclude-dir=.git -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | sort -u )
+    set -- $( (find . -name '*.py' ; grep -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | grep -v '^\./\.git/' | sort -u )
     echo "Analyzing $# Python scripts"
 fi
 

--
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments