Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
devtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
codeaster-fra
devtools
Commits
9039e0d2
Commit
9039e0d2
authored
3 months ago
by
Mathieu Courtois
Browse files
Options
Downloads
Patches
Plain Diff
[#34305] add check-prepush option in ~/.gitconfig
parent
da5f6b5f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/aslint/config.py
+2
-0
2 additions, 0 deletions
lib/aslint/config.py
lib/hgaster/hooks/codeaster.py
+40
-21
40 additions, 21 deletions
lib/hgaster/hooks/codeaster.py
lib/hgaster/hooks/generic.py
+1
-1
1 addition, 1 deletion
lib/hgaster/hooks/generic.py
with
43 additions
and
22 deletions
lib/aslint/config.py
+
2
−
0
View file @
9039e0d2
...
...
@@ -95,6 +95,7 @@ class AsterCfgSection(object): # pragma pylint: disable=R0902
"
check_commit
"
,
"
check_submit
"
,
"
check_precommit
"
,
"
check_prepush
"
,
"
docaster_uri
"
,
"
docaster_cafile
"
,
"
clang_format
"
,
...
...
@@ -132,6 +133,7 @@ class AsterCfgSection(object): # pragma pylint: disable=R0902
self
.
check_commit
=
_read
(
"
check-commit
"
,
"
warn
"
)
self
.
check_submit
=
_read
(
"
check-submit
"
,
"
warn
"
)
self
.
check_precommit
=
_read
(
"
check-precommit
"
,
"
undef
"
)
self
.
check_prepush
=
_read
(
"
check-prepush
"
,
"
undef
"
)
# installation root of devtools
self
.
aslint_root
=
get_absolute_dirname
(
__file__
)
self
.
devtools_root
=
get_absolute_dirname
(
osp
.
join
(
self
.
aslint_root
,
os
.
pardir
))
...
...
This diff is collapsed.
Click to expand it.
lib/hgaster/hooks/codeaster.py
+
40
−
21
View file @
9039e0d2
...
...
@@ -54,28 +54,9 @@ def aslint(repopath, paths=(), amend=False):
revs
=
(
"
HEAD~1
"
,)
if
amend
else
None
# logger.title("running aslint...")
choice
=
ASCFG
.
get
(
"
check.precommit
"
)
if
choice
==
"
no
"
:
logger
.
warn
(
"
pre-commit checkings skipped because of
'
check-precommit
'"
"
value in your ~/.gitconfig file
"
)
if
_check_preference
(
"
pre-commit
"
)
==
OK
:
return
OK
elif
choice
==
"
undef
"
:
logger
.
info
(
"
pre-commit: If you don
'
t plan to submit your work
"
"
you can disable these checkings by adding
"
"'
check-precommit = no
'
in the [aster] section in
"
"
your ~/.gitconfig file.
"
)
logger
.
info
(
"
pre-commit: To hide this message you can set the value
"
"'
check-precommit = yes
'
.
"
)
elif
choice
!=
"
yes
"
:
logger
.
warn
(
"
unknown choice {0!r} for
'
check.precommit
'"
"
(see ~/.gitconfig) must be
'
yes
'
or
'
no
'
.
"
.
format
(
choice
)
)
dchg
=
get_changed_files
(
repopath
,
revs
=
revs
,
files
=
paths
)
changes
=
filter_dict
(
dchg
)
report
=
Report
()
...
...
@@ -141,6 +122,8 @@ def run_ctest_minimal(repopath):
checkcontext
.
reponame
=
get_repo_name
(
repopath
)
if
checkcontext
.
reponame
!=
"
src
"
:
return
OK
if
_check_preference
(
"
pre-push
"
)
==
OK
:
return
OK
logger
.
warning
(
"
Run a minimal list of testcases (for about 30 seconds).
"
)
...
...
@@ -166,3 +149,39 @@ def run_ctest_minimal(repopath):
if
call
(
cmd
):
return
NOOK
return
OK
def
_check_preference
(
hook
):
"""
Check if a checking is enabled or disabled in
'
~/.gitconfig
'
.
Arguments:
hook (str): Hook name.
Returns:
bool: OK if the hook should be skipped, NOOK otherwise.
"""
from
aslint.config
import
ASCFG
assert
hook
in
(
"
pre-commit
"
,
"
pre-push
"
),
hook
option
=
f
"
check.
{
hook
.
replace
(
'
-
'
,
''
)
}
"
gitopt
=
option
.
replace
(
"
.
"
,
"
-
"
)
choice
=
ASCFG
.
get
(
option
)
if
choice
==
"
no
"
:
logger
.
warn
(
"
%s checkings skipped because of
'
%s
'"
"
value in your ~/.gitconfig file
"
,
hook
,
gitopt
)
return
OK
elif
choice
in
(
None
,
"
undef
"
):
logger
.
info
(
"
%s: If you want to disable these checkings, just add
"
"'
%s = no
'
in the [aster] section in your ~/.gitconfig file.
"
,
hook
,
gitopt
,
)
logger
.
info
(
"
%s: To hide this message you can set the value
'
%s = yes
'
.
"
,
hook
,
gitopt
)
elif
choice
!=
"
yes
"
:
logger
.
warn
(
"
unknown choice %r for
'
%s
'
(see ~/.gitconfig) must be
'
yes
'
or
'
no
'
.
"
,
choice
,
option
)
return
NOOK
This diff is collapsed.
Click to expand it.
lib/hgaster/hooks/generic.py
+
1
−
1
View file @
9039e0d2
...
...
@@ -14,7 +14,7 @@ from aslint.config import ASCFG
from
aslint.baseutils
import
force_list
from
aslint.logger
import
logger
from
..ext_utils
import
RE_ISSUE
,
get_issues_from_descr
,
is_admin
from
..ext_utils
import
RE_ISSUE
,
get_issues_from_descr
OK
,
NOOK
=
0
,
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment