From 33abee0e2ab27dcea235a247bf7768cc6ef03db6 Mon Sep 17 00:00:00 2001 From: parazyd Date: Sat, 26 Mar 2022 19:34:34 +0100 Subject: [PATCH] contrib/cargo-outdated: chdir to project root when looking for files. --- contrib/cargo-outdated | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/contrib/cargo-outdated b/contrib/cargo-outdated index 37d23e920..8ef766908 100755 --- a/contrib/cargo-outdated +++ b/contrib/cargo-outdated @@ -1,10 +1,10 @@ -#!/usr/bin/env python3.9 +#!/usr/bin/env python3 import json import pickle import subprocess from argparse import ArgumentParser -from os import getenv +from os import chdir, getenv from os.path import exists, join from subprocess import PIPE @@ -132,6 +132,12 @@ def main(): ["git", "-C", CRATESIO_INDEX, "reset", "--hard", "origin/master"], capture_output=False) + # chdir to the root of the project + toplevel = subprocess.run(["git", "rev-parse", "--show-toplevel"], + capture_output=True) + toplevel = toplevel.stdout.decode().strip() + chdir(toplevel) + find_output = subprocess.run( ["find", ".", "-type", "f", "-name", "Cargo.toml"], stdout=PIPE) files = [i.strip() for i in find_output.stdout.decode().split("\n")][:-1]