Home Home > GIT Browse > packaging
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Poirier <bpoirier@suse.com>2019-03-25 10:12:17 +0900
committerBenjamin Poirier <bpoirier@suse.com>2019-05-02 17:33:21 +0900
commit50602bdd4045e1c3626f438ea7a801482ff6efd1 (patch)
tree06191a7a8bf9a6aca55153d7747866cf77c6a131
parent4f437ad1a664e03ca3925c925861729a547d3b45 (diff)
git-sort: Always explicitely handle a pygit2 import error
As pointed out by Michal Suchanek, the limitation in commit 6d67b1042a73 ("series_sort: Catch pygit2 import failure.") is wrong; given that there is no explicit installation step of the git-sort scripts and that they are "just there" in the kernel-source repository, every user-callable script needs to check that the user followed installation requirements.
-rwxr-xr-xscripts/git_sort/git_sort.py3
-rw-r--r--scripts/git_sort/lib.py3
-rwxr-xr-xscripts/git_sort/merge_tool.py3
-rw-r--r--scripts/git_sort/pygit2_wrapper.py30
-rwxr-xr-xscripts/git_sort/qcp.py3
-rwxr-xr-xscripts/git_sort/qdupcheck.py3
-rwxr-xr-xscripts/git_sort/series_insert.py3
-rwxr-xr-xscripts/git_sort/series_sort.py9
-rw-r--r--scripts/git_sort/tests/support.py3
-rwxr-xr-xscripts/git_sort/tests/test_git_sort.py3
-rwxr-xr-xscripts/git_sort/tests/test_quilt_mode.py3
-rwxr-xr-xscripts/git_sort/tests/test_series_insert.py3
-rwxr-xr-xscripts/git_sort/tests/test_series_sort.py3
-rwxr-xr-xscripts/git_sort/update_clone.py3
14 files changed, 55 insertions, 20 deletions
diff --git a/scripts/git_sort/git_sort.py b/scripts/git_sort/git_sort.py
index 27c40e57c1..979bb3435c 100755
--- a/scripts/git_sort/git_sort.py
+++ b/scripts/git_sort/git_sort.py
@@ -27,13 +27,14 @@ import operator
import os
import os.path
import pprint
-import pygit2
import re
import shelve
import subprocess
import sys
import types
+import pygit2_wrapper as pygit2
+
class GSException(BaseException):
pass
diff --git a/scripts/git_sort/lib.py b/scripts/git_sort/lib.py
index f029267b7e..1b882c1858 100644
--- a/scripts/git_sort/lib.py
+++ b/scripts/git_sort/lib.py
@@ -22,12 +22,13 @@ import collections
import operator
import os
import os.path
-import pygit2
import re
import signal
import subprocess
import sys
+import pygit2_wrapper as pygit2
+
import exc
import git_sort
from patch import Patch
diff --git a/scripts/git_sort/merge_tool.py b/scripts/git_sort/merge_tool.py
index f3a148d946..fda4c3478f 100755
--- a/scripts/git_sort/merge_tool.py
+++ b/scripts/git_sort/merge_tool.py
@@ -33,11 +33,12 @@ git mergetool --tool=git-sort series.conf
"""
import os.path
-import pygit2
import shutil
import subprocess
import sys
+import pygit2_wrapper as pygit2
+
import exc
import lib
import series_conf
diff --git a/scripts/git_sort/pygit2_wrapper.py b/scripts/git_sort/pygit2_wrapper.py
new file mode 100644
index 0000000000..0fff6a16b7
--- /dev/null
+++ b/scripts/git_sort/pygit2_wrapper.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2019 SUSE LLC
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+import sys
+
+try:
+ from pygit2 import *
+except ImportError as err:
+ print("Error: %s" % (err,), file=sys.stderr)
+ print("Please install the \"pygit2\" python3 module. For more details, "
+ "please refer to the \"Installation Requirements\" section of "
+ "\"scripts/git_sort/README.md\".", file=sys.stderr)
+ sys.exit(1)
diff --git a/scripts/git_sort/qcp.py b/scripts/git_sort/qcp.py
index 34ab8b35f5..7ac02514df 100755
--- a/scripts/git_sort/qcp.py
+++ b/scripts/git_sort/qcp.py
@@ -22,12 +22,13 @@ import argparse
import io
import os
import os.path
-import pygit2
import shutil
import subprocess
import sys
import tempfile
+import pygit2_wrapper as pygit2
+
import exc
import lib
from patch import Patch
diff --git a/scripts/git_sort/qdupcheck.py b/scripts/git_sort/qdupcheck.py
index d8c7920feb..a82ff49af1 100755
--- a/scripts/git_sort/qdupcheck.py
+++ b/scripts/git_sort/qdupcheck.py
@@ -21,10 +21,11 @@
import argparse
import os
import os.path
-import pygit2
import subprocess
import sys
+import pygit2_wrapper as pygit2
+
import exc
import lib
import series_conf
diff --git a/scripts/git_sort/series_insert.py b/scripts/git_sort/series_insert.py
index d55d7d0d79..91297d2f17 100755
--- a/scripts/git_sort/series_insert.py
+++ b/scripts/git_sort/series_insert.py
@@ -25,9 +25,10 @@ commits that the patches backport.
import argparse
import collections
-import pygit2
import sys
+import pygit2_wrapper as pygit2
+
import exc
import git_sort
import lib
diff --git a/scripts/git_sort/series_sort.py b/scripts/git_sort/series_sort.py
index 7fbfbcb9b0..444a24d0e7 100755
--- a/scripts/git_sort/series_sort.py
+++ b/scripts/git_sort/series_sort.py
@@ -37,14 +37,7 @@ import argparse
import os
import sys
-try:
- import pygit2
-except ImportError as err:
- print("Error: %s" % (err,), file=sys.stderr)
- print("Please install the \"pygit2\" python3 module. For more details, "
- "please refer to the \"Installation Requirements\" section of "
- "\"scripts/git_sort/README.md\".", file=sys.stderr)
- sys.exit(1)
+import pygit2_wrapper as pygit2
import exc
import git_sort
diff --git a/scripts/git_sort/tests/support.py b/scripts/git_sort/tests/support.py
index dfff2b855f..31e4c5e45a 100644
--- a/scripts/git_sort/tests/support.py
+++ b/scripts/git_sort/tests/support.py
@@ -3,7 +3,8 @@
import datetime
import os.path
-import pygit2
+
+import pygit2_wrapper as pygit2
# from http://www.pygit2.org/recipes/git-show.html
diff --git a/scripts/git_sort/tests/test_git_sort.py b/scripts/git_sort/tests/test_git_sort.py
index 187b38cfbd..5d6b82395c 100755
--- a/scripts/git_sort/tests/test_git_sort.py
+++ b/scripts/git_sort/tests/test_git_sort.py
@@ -4,7 +4,6 @@
import collections
import os
import os.path
-import pygit2
import shelve
import shutil
import subprocess
@@ -12,6 +11,8 @@ import sys
import tempfile
import unittest
+import pygit2_wrapper as pygit2
+
import git_sort
import lib
diff --git a/scripts/git_sort/tests/test_quilt_mode.py b/scripts/git_sort/tests/test_quilt_mode.py
index 95f35a74b4..1b32e4aa95 100755
--- a/scripts/git_sort/tests/test_quilt_mode.py
+++ b/scripts/git_sort/tests/test_quilt_mode.py
@@ -3,13 +3,14 @@
import os
import os.path
-import pygit2
import shutil
import subprocess
import sys
import tempfile
import unittest
+import pygit2_wrapper as pygit2
+
import git_sort
import lib
import series_conf
diff --git a/scripts/git_sort/tests/test_series_insert.py b/scripts/git_sort/tests/test_series_insert.py
index c93489a0c9..9be2e1ee6a 100755
--- a/scripts/git_sort/tests/test_series_insert.py
+++ b/scripts/git_sort/tests/test_series_insert.py
@@ -2,13 +2,14 @@
# -*- coding: utf-8 -*-
import os
-import pygit2
import shutil
import subprocess
import tempfile
import unittest
import sys
+import pygit2_wrapper as pygit2
+
import git_sort
import lib
import tests.support
diff --git a/scripts/git_sort/tests/test_series_sort.py b/scripts/git_sort/tests/test_series_sort.py
index 66317c2025..67e2e4ae56 100755
--- a/scripts/git_sort/tests/test_series_sort.py
+++ b/scripts/git_sort/tests/test_series_sort.py
@@ -3,13 +3,14 @@
import os
import os.path
-import pygit2
import shutil
import subprocess
import sys
import tempfile
import unittest
+import pygit2_wrapper as pygit2
+
import git_sort
import lib
import tests.support
diff --git a/scripts/git_sort/update_clone.py b/scripts/git_sort/update_clone.py
index 0223235dfa..098fff56ee 100755
--- a/scripts/git_sort/update_clone.py
+++ b/scripts/git_sort/update_clone.py
@@ -20,10 +20,11 @@
import argparse
import collections
-import pygit2
import re
import shlex
+import pygit2_wrapper as pygit2
+
import git_sort
import lib