From a98b1229df8d614beeb452d7a0d8a145862cbab0 Mon Sep 17 00:00:00 2001 From: Trevor Gamblin Date: Thu, 19 Oct 2023 09:47:10 -0400 Subject: patchtest: check for untracked changes [YOCTO #15243] Avoid overwriting local changes when running patchtest by checking for anything unstaged or uncommitted in the target repo, and logging an error if something is found. This will provide the user helpful feedback if (for example) they forgot to commit a change for their patch under test, and will leave the target repository in a reasonable state (rather than a temporary branch created by patchtest). (From OE-Core rev: 2d24ff9568d729b17cfc746d0948e63c78d9f3ae) Signed-off-by: Trevor Gamblin Signed-off-by: Richard Purdie --- scripts/patchtest | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/patchtest b/scripts/patchtest index 642486b8c7..be40e4b2a4 100755 --- a/scripts/patchtest +++ b/scripts/patchtest @@ -171,6 +171,12 @@ def main(): log_path = None patch_list = None + git_status = os.popen("(cd %s && git status)" % PatchTestInput.repodir).read() + status_matches = ["Changes not staged for commit", "Changes to be committed"] + if any([match in git_status for match in status_matches]): + logger.error("patchtest: there are uncommitted changes in the target repo that would be overwritten. Please commit or restore them before running patchtest") + return 1 + if os.path.isdir(patch_path): patch_list = [os.path.join(patch_path, filename) for filename in os.listdir(patch_path)] else: -- cgit v1.2.3-54-g00ecf