summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrevor Gamblin <tgamblin@baylibre.com>2023-10-19 09:47:10 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-10-19 17:01:04 +0100
commita98b1229df8d614beeb452d7a0d8a145862cbab0 (patch)
treeb368a1d7ee10bf1caad9b4b2ff47156b94d788db
parent8159c17bdd9a6e35382bb3467cd21a2d2a72a729 (diff)
downloadpoky-a98b1229df8d614beeb452d7a0d8a145862cbab0.tar.gz
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 <tgamblin@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/patchtest6
1 files changed, 6 insertions, 0 deletions
diff --git a/scripts/patchtest b/scripts/patchtest
index 642486b8c7..be40e4b2a4 100755
--- a/scripts/patchtest
+++ b/scripts/patchtest
@@ -171,6 +171,12 @@ def main():
171 log_path = None 171 log_path = None
172 patch_list = None 172 patch_list = None
173 173
174 git_status = os.popen("(cd %s && git status)" % PatchTestInput.repodir).read()
175 status_matches = ["Changes not staged for commit", "Changes to be committed"]
176 if any([match in git_status for match in status_matches]):
177 logger.error("patchtest: there are uncommitted changes in the target repo that would be overwritten. Please commit or restore them before running patchtest")
178 return 1
179
174 if os.path.isdir(patch_path): 180 if os.path.isdir(patch_path):
175 patch_list = [os.path.join(patch_path, filename) for filename in os.listdir(patch_path)] 181 patch_list = [os.path.join(patch_path, filename) for filename in os.listdir(patch_path)]
176 else: 182 else: