public inbox for cip-dev@lists.cip-project.org
 help / color / mirror / Atom feed
From: ben.hutchings@codethink.co.uk (Ben Hutchings)
To: cip-dev@lists.cip-project.org
Subject: [cip-dev] [cip-kernel-sec][PATCH v2 3/3] remotes: check that remotes exist
Date: Thu, 20 Jun 2019 19:07:36 +0100	[thread overview]
Message-ID: <1561054056.21054.48.camel@codethink.co.uk> (raw)
In-Reply-To: <20190620055143.341-3-daniel.sangorrin@toshiba.co.jp>

On Thu, 2019-06-20 at 14:51 +0900, Daniel Sangorrin wrote:
[...]
> --- a/scripts/kernel_sec/branch.py
> +++ b/scripts/kernel_sec/branch.py
[...]
> +def check_git_repo(git_repo, remotes, create=False):
> +????if create:
> +????????if os.path.isdir(git_repo):
> +????????????msg = "directory %r already exists" % git_repo
> +????????????raise argparse.ArgumentTypeError(msg)
> +????????else:
> +????????????os.mkdir(git_repo)
> +????????????subprocess.check_call(['git', 'init', '.'], cwd=git_repo)
> +
> +????????for key in remotes.keys():
> +????????????remote = remotes[key]??# __getitem__ will add git_name
> +????????????remote_add(git_repo, remote['git_name'], remote['git_repo_url'])
> +????else:
> +????????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)

This isn't compatible with the use of git worktrees (which I use).  In
a worktree, .git is a regular file that refers back to the repository.

So I think this check should use exists() instead of isdir().

Also, why does this function raise argparse.ArgumentTypeError?  The
doc-string for that type says it's "An error from trying to convert a
command line string to a type."  It doesn't seem to be suitable for
reporting problems with the thing that an argument refers to.

[...]
> --- /dev/null
> +++ b/scripts/prepare_remotes.py
> @@ -0,0 +1,46 @@
> +#!/usr/bin/python3
> +
> +# Copyright 2019 Toshiba corp.
> +# Based on import_stable.py by Codethink Ltd.
> +#
> +# This script is distributed under the terms and conditions of the GNU General
> +# Public License, Version 3 or later. See?http://www.gnu.org/copyleft/gpl.html
> +# for details.
> +
> +# Helper script that prepares the local git repository with the configured
> +# remote branches
[...]

Perhaps prepare_remotes.py should also run "git remote update"? 
Without that, the repository is still not actually useful.

Ben.

-- 
Ben Hutchings, Software Developer                ?        Codethink Ltd
https://www.codethink.co.uk/                 Dale House, 35 Dale Street
                                     Manchester, M1 2HF, United Kingdom

  reply	other threads:[~2019-06-20 18:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-20  5:51 [cip-dev] [cip-kernel-sec][PATCH v2 1/3] branch: fix remotes mapping Daniel Sangorrin
2019-06-20  5:51 ` [cip-dev] [cip-kernel-sec][PATCH v2 2/3] help:remote_name: use colon instead of equal Daniel Sangorrin
2019-06-20  5:51 ` [cip-dev] [cip-kernel-sec][PATCH v2 3/3] remotes: check that remotes exist Daniel Sangorrin
2019-06-20 18:07   ` Ben Hutchings [this message]
2019-06-20 18:08 ` [cip-dev] [cip-kernel-sec][PATCH v2 1/3] branch: fix remotes mapping 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=1561054056.21054.48.camel@codethink.co.uk \
    --to=ben.hutchings@codethink.co.uk \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox