summaryrefslogtreecommitdiff
path: root/tools/u_boot_pylib/gitutil.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-05-08 05:23:41 +0200
committerSimon Glass <sjg@chromium.org>2025-05-27 10:07:42 +0100
commit3724cbade41a1dd0ec94cd9b511afe005ebf4804 (patch)
treebe036445fce8fde18eb3b139b7bef6f669ae7a99 /tools/u_boot_pylib/gitutil.py
parent9302d672a5e63cdb56371eb55dc560fef97c059f (diff)
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.
Diffstat (limited to 'tools/u_boot_pylib/gitutil.py')
-rw-r--r--tools/u_boot_pylib/gitutil.py18
1 files changed, 18 insertions, 0 deletions
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