diff mbox series

scripts: patchreview: fix failure when running from a different folder

Message ID 20241119094109.2648950-1-nicolas.dechesne@oss.qualcomm.com
State New
Headers show
Series scripts: patchreview: fix failure when running from a different folder | expand

Commit Message

Nicolas Dechesne Nov. 19, 2024, 9:41 a.m. UTC
When running patchreview with --blame, the scripts runs a git log
command on the analyzed patch. When trying to analyse a layer which is
not in poky tree, we might be running the git log command from outside
the git workspace where the file is located, which results in such
failures:

Missing Signed-off-by tag ([truncated]/meta-qcom-hwe/recipes-devtools/partition-utils/qcom-ptool/0001-ptool.py-Generate-zero-files-in-output-folder-when-s.patch)
fatal: not a git repository (or any parent up to mount point /local/mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Fix this situation by setting the current work dir inside the git
workspace of the patch when running git log.

Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
---
 scripts/contrib/patchreview.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/scripts/contrib/patchreview.py b/scripts/contrib/patchreview.py
index bceae06561..f976f2f822 100755
--- a/scripts/contrib/patchreview.py
+++ b/scripts/contrib/patchreview.py
@@ -47,7 +47,7 @@  def blame_patch(patch):
     return subprocess.check_output(("git", "log",
                                     "--follow", "--find-renames", "--diff-filter=A",
                                     "--format=%s (%aN <%aE>)",
-                                    "--", patch)).decode("utf-8").splitlines()
+                                    "--", patch), cwd=os.path.dirname(patch)).decode("utf-8").splitlines()
 
 def patchreview(patches):