Просмотр исходного кода

contrib/cargo-outdated: chdir to project root when looking for files.

parazyd 4 лет назад
Родитель
Сommit
33abee0e2a
1 измененных файлов с 8 добавлено и 2 удалено
  1. 8 2
      contrib/cargo-outdated

+ 8 - 2
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]