]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
patman: Clean up creation of the git tree
authorSimon Glass <sjg@chromium.org>
Thu, 8 May 2025 03:23:41 +0000 (05:23 +0200)
committerSimon Glass <sjg@chromium.org>
Tue, 27 May 2025 09:07:42 +0000 (10:07 +0100)
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/patman/func_test.py
tools/patman/requirements.txt
tools/u_boot_pylib/gitutil.py

index 9c7d5d8c381da4a771fed428a64a5b79eee35ae1..61df82312ba759297cff5df781b45ebd53550b47 100644 (file)
@@ -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):
index 57a284d23f2202e030f5f544277eb8fef046f7a2..ce9a3854527580273f5e39ebc387a76bbd6672a5 100644 (file)
@@ -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
index cc57e7b7f7392a1095d587a29f86d474bfda7d59..3c52cce232c1140bb7ffe6cbd4b696f021d3eab1 100644 (file)
@@ -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