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
68735c7c
Commit
68735c7c
authored
Apr 13, 2016
by
Antti Tanhuanpää
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add get_linter
parent
0685ba08
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
gitlint
gitlint
+15
-6
No files found.
gitlint
View file @
68735c7c
...
@@ -12,17 +12,26 @@ linters = {
...
@@ -12,17 +12,26 @@ linters = {
}
}
def
lint
(
filename
,
fail_on_keyerror
=
False
):
class
NoLinterFound
(
Exception
):
pass
def
get_linter
(
filename
):
try
:
try
:
_
,
extension
=
filename
.
rsplit
(
'.'
,
1
)
_
,
extension
=
filename
.
rsplit
(
'.'
,
1
)
except
ValueError
:
linter_args
=
linters
[
extension
]
return
True
except
(
KeyError
,
ValueError
):
raise
NoLinterFound
return
linter_args
def
lint
(
filename
,
require_linter
=
False
):
try
:
try
:
linter_args
=
linters
[
extension
]
linter_args
=
get_linter
(
filename
)
except
KeyError
:
except
NoLinterFound
:
print
(
'Not linter found for'
,
filename
,
file
=
sys
.
stderr
)
print
(
'Not linter found for'
,
filename
,
file
=
sys
.
stderr
)
return
not
fail_on_keyerro
r
return
not
require_linte
r
print
(
filename
)
print
(
filename
)
git_args
=
(
'/usr/bin/git'
,
'show'
,
shlex
.
quote
(
':
%
s'
%
filename
))
git_args
=
(
'/usr/bin/git'
,
'show'
,
shlex
.
quote
(
':
%
s'
%
filename
))
...
...
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