From 7ac9005c3790e2fa173a67eb6bb8ddb32fc9faa9 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 9 Nov 2023 11:57:25 +0000 Subject: [PATCH] Revert "Support git safe directory for manifest in subdirectory" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7d6496d2b71f1b970cee3a5574d23af1155ca6ce. As described in https://github.com/flathub/flatpak-external-data-checker/issues/395 we cannot use `git rev-parse --show-toplevel` to find the root directory of the repository in order to mark it as safe – because `git` refuses to operate on a directory with dubious ownership, which is what we are trying to fix! We will need an alternative solution but for the meantime, revert this change to fix the common case where the manifest is in the root directory. --- src/main.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main.py b/src/main.py index c0a4ce87..286d6519 100755 --- a/src/main.py +++ b/src/main.py @@ -128,15 +128,6 @@ def check_call(args): subprocess.check_call(args) -def get_manifest_git_checkout(manifest: t.Union[Path, str]) -> str: - manifest_dir = os.path.dirname(manifest) - output = subprocess.check_output( - ["git", "rev-parse", "--show-toplevel"], - cwd=manifest_dir, - ) - return output.decode("utf-8").strip() - - def ensure_git_safe_directory(checkout: t.Union[Path, str]): uid = os.getuid() checkout_uid = os.stat(checkout).st_uid @@ -460,7 +451,7 @@ async def run_with_args(args: argparse.Namespace) -> t.Tuple[int, int, bool]: if should_update and outdated_num > 0: changes = manifest_checker.update_manifests() if changes and not args.edit_only: - git_checkout = get_manifest_git_checkout(args.manifest) + git_checkout = os.path.dirname(args.manifest) ensure_git_safe_directory(git_checkout) with indir(git_checkout): committed_changes = commit_changes(changes)