Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
95183eb5
Verified
Commit
95183eb5
authored
4 years ago
by
Robert Rosca
Browse files
Options
Downloads
Patches
Plain Diff
Add a script for easy execution of diff-only pre-commit checks
parent
b98fed75
No related branches found
No related tags found
2 merge requests
!433
Fix/pre commit whitespace
,
!417
Feat/pre commit checks
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/pre-commit-diff.sh
+12
-0
12 additions, 0 deletions
bin/pre-commit-diff.sh
with
12 additions
and
0 deletions
bin/pre-commit-diff.sh
0 → 100755
+
12
−
0
View file @
95183eb5
#!/bin/bash
# We'd like to run the pre-commit hooks only on files that are being modified by
# this merge request, however `CI_MERGE_REQUEST_TARGET_BRANCH_SHA` is a'premium'
# feature according to GitLab... so this is a workaround for extracting the hash
CI_MERGE_REQUEST_TARGET_BRANCH_NAME
=
"
${
1
:-
master
}
"
# Set to master or 1st input
CI_COMMIT_SHA
=
$(
git rev-parse HEAD
)
CI_MERGE_REQUEST_TARGET_BRANCH_SHA
=
$(
git ls-remote origin
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
|
cut
-d
$'
\t
'
-f1
)
FILES
=
$(
git diff
$CI_COMMIT_SHA
$CI_MERGE_REQUEST_TARGET_BRANCH_SHA
--name-only
|
tr
'\n'
' '
)
echo
"Running pre-commit on diff from
$CI_COMMIT_SHA
to
$CI_MERGE_REQUEST_TARGET_BRANCH_SHA
(
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
)"
# Pass list of modified files to pre-commit so that it only checks them
echo
$FILES
| xargs pre-commit run
--color
=
always
--files
This diff is collapsed.
Click to expand it.
Robert Rosca
@roscar
mentioned in commit
e49dcbcf
·
4 years ago
mentioned in commit
e49dcbcf
mentioned in commit e49dcbcf1a5ec882c994fc35228951f82e9e5942
Toggle commit list
Robert Rosca
@roscar
mentioned in commit
385d6aab
·
4 years ago
mentioned in commit
385d6aab
mentioned in commit 385d6aab246bf6e7ed04575a5c42a4265b1cd788
Toggle commit list
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