@@ -190,4 +190,5 @@ if __name__ == '__main__':
remotes = kernel_sec.branch.get_remotes(args.remote_name,
mainline=args.mainline_remote_name,
stable=args.stable_remote_name)
+ kernel_sec.branch.check_git_repo(args.git_repo, remotes)
main(args.git_repo, remotes, args.debug)
@@ -4,10 +4,12 @@
# Public License, Version 3 or later. See http://www.gnu.org/copyleft/gpl.html
# for details.
+import argparse
import io
import os
import re
import subprocess
+import sys
import time
import urllib.error
import urllib.request
@@ -219,3 +221,22 @@ def get_remotes(mappings, mainline=None, stable=None):
if stable:
remotes['stable']['git_name'] = stable
return remotes
+
+
+def check_git_repo(git_repo, remotes):
+ if not os.path.isdir(git_repo):
+ msg = "directory %r not present" % git_repo
+ raise argparse.ArgumentError(None, msg)
+ # .git could be a regular file (worktrees) or a directory
+ if not os.path.exists(os.path.join(git_repo, '.git')):
+ msg = "directory %r is not a git repository" % git_repo
+ raise argparse.ArgumentError(None, msg)
+
+ current_remotes = subprocess.check_output(
+ ['git', 'remote', 'show'], cwd=git_repo).decode(
+ sys.stdout.encoding).strip().split('\n')
+ for key in remotes.keys():
+ remote = remotes[key] # __getitem__ will add git_name
+ if remote['git_name'] not in current_remotes:
+ msg = "remote %r not in git repository" % remote['git_name']
+ raise argparse.ArgumentError(None, msg)
@@ -100,5 +100,6 @@ if __name__ == '__main__':
remotes = kernel_sec.branch.get_remotes(args.remote_name,
mainline=args.mainline_remote_name,
stable=args.stable_remote_name)
+ kernel_sec.branch.check_git_repo(args.git_repo, remotes)
main(args.git_repo, remotes,
args.only_fixed_upstream, args.include_ignored, *args.branches)
@@ -219,6 +219,7 @@ if __name__ == '__main__':
remotes = kernel_sec.branch.get_remotes(args.remote_name,
mainline=args.mainline_remote_name,
stable=args.stable_remote_name)
+ kernel_sec.branch.check_git_repo(args.git_repo, remotes)
conf = {
'/static/style.css': {
Add checks to make sure that the local repository exists and has the configured remotes in place. Signed-off-by: Daniel Sangorrin <daniel.sangorrin@toshiba.co.jp> --- scripts/import_stable.py | 1 + scripts/kernel_sec/branch.py | 21 +++++++++++++++++++++ scripts/report_affected.py | 1 + scripts/webview.py | 1 + 4 files changed, 24 insertions(+)