All of lore.kernel.org
 help / color / mirror / Atom feed
From: daniel.sangorrin@toshiba.co.jp (Daniel Sangorrin)
To: cip-dev@lists.cip-project.org
Subject: [cip-dev] [cip-kernel-sec 2/2] git_repo: add a check for the git_repo directory
Date: Mon, 17 Jun 2019 14:21:27 +0900	[thread overview]
Message-ID: <20190617052127.9571-2-daniel.sangorrin@toshiba.co.jp> (raw)
In-Reply-To: <20190617052127.9571-1-daniel.sangorrin@toshiba.co.jp>

Users are required to prepare a local git repository, by
default "../kernel", however there is no check at the
moment. Alternatively, we could also create a repository
for them (mkdir ../kernel; git init .) but that for
now let's just spit an error.

Signed-off-by: Daniel Sangorrin <daniel.sangorrin@toshiba.co.jp>
---
 scripts/import_stable.py     |  1 +
 scripts/kernel_sec/branch.py | 11 +++++++++++
 scripts/report_affected.py   |  1 +
 scripts/webview.py           |  1 +
 4 files changed, 14 insertions(+)

diff --git a/scripts/import_stable.py b/scripts/import_stable.py
index 26e45a9..2d9b66b 100755
--- a/scripts/import_stable.py
+++ b/scripts/import_stable.py
@@ -179,6 +179,7 @@ if __name__ == '__main__':
                         dest='git_repo', default='../kernel',
                         help=('git repository from which to read commit logs '
                               '(default: ../kernel)'),
+                        type=kernel_sec.branch.check_git_repo,
                         metavar='DIRECTORY')
     parser.add_argument('--remote-name',
                         dest='remote_name', action='append', default=[],
diff --git a/scripts/kernel_sec/branch.py b/scripts/kernel_sec/branch.py
index 3ede64a..0ea5086 100644
--- a/scripts/kernel_sec/branch.py
+++ b/scripts/kernel_sec/branch.py
@@ -219,3 +219,14 @@ def get_remotes(mappings, mainline=None, stable=None):
     if stable:
         remotes['stable']['git_name'] = stable
     return remotes
+
+
+def check_git_repo(git_repo):
+    import argparse
+    if not os.path.isdir(git_repo):
+        msg = "directory %r not present" % git_repo
+        raise argparse.ArgumentTypeError(msg)
+    if not os.path.isdir(os.path.join(git_repo, '.git')):
+        msg = "directory %r is not a git repository" % git_repo
+        raise argparse.ArgumentTypeError(msg)
+    return git_repo
diff --git a/scripts/report_affected.py b/scripts/report_affected.py
index fac0885..bcb8168 100755
--- a/scripts/report_affected.py
+++ b/scripts/report_affected.py
@@ -72,6 +72,7 @@ if __name__ == '__main__':
                         dest='git_repo', default='../kernel',
                         help=('git repository from which to read commit logs '
                               '(default: ../kernel)'),
+                        type=kernel_sec.branch.check_git_repo,
                         metavar='DIRECTORY')
     parser.add_argument('--remote-name',
                         dest='remote_name', action='append', default=[],
diff --git a/scripts/webview.py b/scripts/webview.py
index 9e16a0c..e334371 100755
--- a/scripts/webview.py
+++ b/scripts/webview.py
@@ -202,6 +202,7 @@ if __name__ == '__main__':
                         dest='git_repo', default='../kernel',
                         help=('git repository from which to read commit logs '
                               '(default: ../kernel)'),
+                        type=kernel_sec.branch.check_git_repo,
                         metavar='DIRECTORY')
     parser.add_argument('--remote-name',
                         dest='remote_name', action='append', default=[],
-- 
2.17.1

  reply	other threads:[~2019-06-17  5:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17  5:21 [cip-dev] [cip-kernel-sec 1/2] remotes: automatically add remotes from configuration file Daniel Sangorrin
2019-06-17  5:21 ` Daniel Sangorrin [this message]
2019-06-17 20:54 ` Ben Hutchings
2019-06-18  3:54   ` daniel.sangorrin at toshiba.co.jp
2019-06-18 13:00     ` Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190617052127.9571-2-daniel.sangorrin@toshiba.co.jp \
    --to=daniel.sangorrin@toshiba.co.jp \
    --cc=cip-dev@lists.cip-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.