mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-13 07:02:53 +00:00
pre-commit: add a helper script to check commits individually
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5192>
This commit is contained in:
parent
2e11649264
commit
8c1ffd09d1
1 changed files with 20 additions and 0 deletions
20
scripts/check-commits.py
Executable file
20
scripts/check-commits.py
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
def run_pre_commit(start_commit:str):
|
||||
if start_commit == 'HEAD':
|
||||
start_commit = 'HEAD~1'
|
||||
try:
|
||||
subprocess.run(['git', 'rebase', start_commit, '--exec', f"pre-commit run --from-ref HEAD~1 --to-ref HEAD"])
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f'pre-commit failed with exit code {e.returncode}.')
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Checks a range of commits one by one with pre-commit.")
|
||||
parser.add_argument('start_commit', nargs='?', default='HEAD~1', type=str,
|
||||
help='Initial commit (refspec) to start the check.')
|
||||
args = parser.parse_args()
|
||||
run_pre_commit(args.start_commit or 'HEAD~1')
|
Loading…
Reference in a new issue