summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/patman/func_test.py9
-rw-r--r--tools/patman/requirements.txt2
-rw-r--r--tools/u_boot_pylib/gitutil.py18
3 files changed, 27 insertions, 2 deletions
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 9c7d5d8c381..61df82312ba 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -503,7 +503,7 @@ better than before''')
target = repo.revparse_single('HEAD~2')
# pylint doesn't seem to find this
# pylint: disable=E1101
- repo.reset(target.oid, pygit2.GIT_CHECKOUT_FORCE)
+ repo.reset(target.oid, pygit2.enums.ResetMode.HARD)
self.make_commit_with_file('video: Some video improvements', '''
Fix up the video so that
it looks more purple. Purple is
@@ -543,6 +543,13 @@ complicated as possible''')
repo.config.set_multivar('branch.second.merge', '', 'refs/heads/base')
repo.branches.local.create('base', base_target)
+
+ target = repo.lookup_reference('refs/heads/first')
+ repo.checkout(target, strategy=pygit2.GIT_CHECKOUT_FORCE)
+ target = repo.revparse_single('HEAD')
+ repo.reset(target.oid, pygit2.enums.ResetMode.HARD)
+
+ self.assertFalse(gitutil.check_dirty(self.gitdir, self.tmpdir))
return repo
def test_branch(self):
diff --git a/tools/patman/requirements.txt b/tools/patman/requirements.txt
index 57a284d23f2..ce9a3854527 100644
--- a/tools/patman/requirements.txt
+++ b/tools/patman/requirements.txt
@@ -1,6 +1,6 @@
aiohttp==3.9.1
ConfigParser==7.1.0
importlib_resources==6.5.2
-pygit2==1.13.3
+pygit2==1.14.1
Requests==2.32.3
setuptools==75.8.0
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