Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gitlint
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Antti Tanhuanpää
gitlint
Commits
0685ba08
Commit
0685ba08
authored
Apr 13, 2016
by
Antti Tanhuanpää
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial dump
parents
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
gitlint
gitlint
+48
-0
No files found.
gitlint
0 → 100755
View file @
0685ba08
#!/usr/bin/env python3
import
shlex
import
subprocess
import
sys
linters
=
{
'js'
:
(
'/usr/bin/eslint'
,
'--stdin'
),
'py'
:
(
'/usr/bin/flake8'
,
'--ignore=E121,E123,E126,E266,E501,E704,E731'
,
'-'
),
'scss'
:
(
'/usr/bin/scss-lint'
,
'-'
),
}
def
lint
(
filename
,
fail_on_keyerror
=
False
):
try
:
_
,
extension
=
filename
.
rsplit
(
'.'
,
1
)
except
ValueError
:
return
True
try
:
linter_args
=
linters
[
extension
]
except
KeyError
:
print
(
'Not linter found for'
,
filename
,
file
=
sys
.
stderr
)
return
not
fail_on_keyerror
print
(
filename
)
git_args
=
(
'/usr/bin/git'
,
'show'
,
shlex
.
quote
(
':
%
s'
%
filename
))
with
subprocess
.
Popen
(
git_args
,
stdout
=
subprocess
.
PIPE
)
as
pipe
:
ret
=
subprocess
.
call
(
linter_args
,
stdin
=
pipe
.
stdout
)
return
ret
==
0
def
main
(
*
args
):
ret
=
True
while
True
:
line
=
sys
.
stdin
.
readline
()
if
not
line
:
break
filename
=
line
.
strip
()
ret
&=
lint
(
filename
)
return
1
^
ret
if
__name__
==
'__main__'
:
sys
.
exit
(
main
(
*
sys
.
argv
[
1
:]))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment