From 3724cbade41a1dd0ec94cd9b511afe005ebf4804 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 8 May 2025 05:23:41 +0200 Subject: patman: Clean up creation of the git tree The test starts with the HEAD pointing to the wrong place, so that the created files appear to be deleted. Fix this by resetting the tree before tests start. Add a check that the tree is clean. Update pygit2 so that the enums are available. --- tools/u_boot_pylib/gitutil.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tools/u_boot_pylib/gitutil.py') diff --git a/tools/u_boot_pylib/gitutil.py b/tools/u_boot_pylib/gitutil.py index cc57e7b7f73..3c52cce232c 100644 --- a/tools/u_boot_pylib/gitutil.py +++ b/tools/u_boot_pylib/gitutil.py @@ -757,6 +757,24 @@ def get_branch(git_dir=None): return out +def check_dirty(git_dir=None, work_tree=None): + """Check if the tree is dirty + + Args: + git_dir (str): Path to git repository (None to use default) + + Return: + str: List of dirty filenames and state + """ + cmd = ['git'] + if git_dir: + cmd += ['--git-dir', git_dir] + if work_tree: + cmd += ['--work-tree', work_tree] + cmd += ['status', '--porcelain', '--untracked-files=no'] + return command.output(*cmd).splitlines() + + if __name__ == "__main__": import doctest -- cgit v1.2.3