Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SBo-bits
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
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
David Spencer
SBo-bits
Compare Revisions
cae012f926f032332e60038b4f5ebd405a7c6643...3afa3395d69dbffae6d42e79f82fe22a6e1ea4f2
Source
3afa3395d69dbffae6d42e79f82fe22a6e1ea4f2
Select Git revision
...
Target
cae012f926f032332e60038b4f5ebd405a7c6643
Select Git revision
Compare
Commits (2)
parse_info.py: accept both utf-8 and latin-1 encoding.
· 70b4d622
David Spencer
authored
Sep 17, 2018
70b4d622
hooks/pre-commit: Complain about broken .info files and commits in multiple directories.
· 3afa3395
David Spencer
authored
Sep 17, 2018
3afa3395
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
pre-commit
hooks/pre-commit
+13
-0
parse_info.py
parsers/parse_info.py
+7
-2
No files found.
hooks/pre-commit
View file @
3afa3395
...
...
@@ -48,6 +48,7 @@
ERROR
=
"no"
FILES
=
$(
git diff-index
--cached
--name-only
HEAD
)
HAS_INFO
=
$(
git diff-index
--cached
--name-only
HEAD |
grep
"
\.
info"
)
DIR
=
""
if
!
[
-z
"
$FILES
"
]
;
then
for
i
in
$FILES
;
do
...
...
@@ -58,6 +59,18 @@ if ! [ -z "$FILES" ]; then
ERROR
=
"yes"
fi
fi
if
[
"
${
i
##*.
}
"
=
"info"
]
;
then
if
!
msg
=
$(
.
$i
2>&1
)
;
then
echo
"
$msg
"
ERROR
=
"yes"
fi
fi
if
[
-z
"
$DIR
"
]
;
then
DIR
=
$(
dirname
$i
)
elif
[
"
$DIR
"
!=
"
$(
dirname
$i
)
"
]
;
then
echo
"Don't commit in multiple directories"
ERROR
=
"yes"
fi
done
fi
...
...
parsers/parse_info.py
View file @
3afa3395
...
...
@@ -345,8 +345,13 @@ def parse_info(infopath):
Returns: a dict, as described in the "Implementation Note".
"""
with
open
(
infopath
)
as
infofile
:
Infodict
=
parser
.
parse
(
infofile
.
read
())
try
:
with
open
(
infofile
,
"r"
,
encoding
=
"utf-8"
)
as
infofile
:
Infodict
=
parser
.
parse
(
infofile
.
read
())
except
:
with
open
(
infofile
,
"r"
,
encoding
=
"latin-1"
)
as
infofile
:
Infodict
=
parser
.
parse
(
infofile
.
read
())
return
Infodict
#-------------------------------------------------------------------------------