Browse Source

Merge branch 'actions'

Jelmer Vernooij 4 years ago
parent
commit
11de711310

+ 32 - 0
.github/workflows/pythonpackage.yml

@@ -0,0 +1,32 @@
+name: Python package
+
+on: [push, pull_request]
+
+jobs:
+  build:
+
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        os: [ubuntu-latest, macos-latest, windows-latest]
+        python-version: [3.6, 3.7, 3.8, pypy3]
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install -U pip coverage codecov flake8 fastimport
+    - name: Style checks
+      run: |
+        python -m flake8
+    - name: Build
+      run: |
+        python setup.py build_ext -i
+    - name: Coverage test suite run
+      run: |
+        python -m coverage run -p -m unittest dulwich.tests.test_suite

+ 32 - 0
.github/workflows/pythonpublish.yml

@@ -0,0 +1,32 @@
+name: Upload Python Package
+
+on:
+  release:
+    types: [created]
+
+jobs:
+  deploy:
+
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        os: [ubuntu-latest, macos-latest, windows-latest]
+        python-version: ['3.x']
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install setuptools wheel twine
+    - name: Build and publish
+      env:
+        TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
+        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
+      run: |
+        python setup.py sdist bdist_wheel
+        twine upload dist/*

+ 2 - 2
Makefile

@@ -1,7 +1,7 @@
 PYTHON = python3
-PYFLAKES = pyflakes
+PYFLAKES = $(PYTHON) -m pyflakes
 PEP8 = pep8
-FLAKE8 ?= flake8
+FLAKE8 ?= $(PYTHON) -m flake8
 SETUP = $(PYTHON) setup.py
 TESTRUNNER ?= unittest
 RUNTEST = PYTHONHASHSEED=random PYTHONPATH=$(shell pwd)$(if $(PYTHONPATH),:$(PYTHONPATH),) $(PYTHON) -m $(TESTRUNNER) $(TEST_OPTIONS)

+ 5 - 0
dulwich/_diff_tree.c

@@ -270,6 +270,11 @@ done:
 	return result;
 }
 
+/* Not all environments define S_ISDIR */
+#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+
 static PyObject *py_is_tree(PyObject *self, PyObject *args)
 {
 	PyObject *entry, *mode, *result;

+ 5 - 0
dulwich/_objects.c

@@ -141,6 +141,11 @@ struct tree_item {
 	PyObject *tuple;
 };
 
+/* Not all environments define S_ISDIR */
+#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+
 int cmp_tree_item(const void *_a, const void *_b)
 {
 	const struct tree_item *a = _a, *b = _b;

+ 5 - 4
dulwich/client.py

@@ -741,11 +741,11 @@ def check_wants(wants, refs):
 def remote_error_from_stderr(stderr):
     if stderr is None:
         return HangupException()
-    for l in stderr.readlines():
-        if l.startswith(b'ERROR: '):
+    for line in stderr.readlines():
+        if line.startswith(b'ERROR: '):
             return GitProtocolError(
-                l[len(b'ERROR: '):].decode('utf-8', 'replace'))
-        return GitProtocolError(l.decode('utf-8', 'replace'))
+                line[len(b'ERROR: '):].decode('utf-8', 'replace'))
+        return GitProtocolError(line.decode('utf-8', 'replace'))
     return HangupException()
 
 
@@ -1877,6 +1877,7 @@ DEFAULT_GIT_CREDENTIALS_PATHS = [
     os.path.expanduser('~/.git-credentials'),
     get_xdg_config_home_path('git', 'credentials')]
 
+
 def get_credentials_from_store(scheme, hostname, username=None,
                                fnames=DEFAULT_GIT_CREDENTIALS_PATHS):
     for fname in fnames:

+ 0 - 1
dulwich/objects.py

@@ -79,7 +79,6 @@ class EmptyFileException(FileFormatException):
     """An unexpectedly empty file was encountered."""
 
 
-
 def S_ISGITLINK(m):
     """Check if a mode indicates a submodule.
 

+ 1 - 1
dulwich/porcelain.py

@@ -699,7 +699,7 @@ def log(repo=".", paths=None, outstream=sys.stdout, max_entries=None,
             print_commit(entry.commit, decode, outstream)
             if name_status:
                 outstream.writelines(
-                    [l+'\n' for l in print_name_status(entry.changes())])
+                    [line+'\n' for line in print_name_status(entry.changes())])
 
 
 # TODO(jelmer): better default for encoding?

+ 2 - 2
dulwich/reflog.py

@@ -75,5 +75,5 @@ def read_reflog(f):
       f: File-like object
     Returns: Iterator over Entry objects
     """
-    for l in f:
-        yield parse_reflog_line(l)
+    for line in f:
+        yield parse_reflog_line(line)

+ 8 - 8
dulwich/refs.py

@@ -472,8 +472,8 @@ class InfoRefsContainer(RefsContainer):
     def __init__(self, f):
         self._refs = {}
         self._peeled = {}
-        for l in f.readlines():
-            sha, name = l.rstrip(b'\n').split(b'\t')
+        for line in f.readlines():
+            sha, name = line.rstrip(b'\n').split(b'\t')
             if name.endswith(ANNOTATED_TAG_SUFFIX):
                 name = name[:-3]
                 if not check_ref_format(name):
@@ -873,14 +873,14 @@ def read_packed_refs(f):
       f: file-like object to read from
     Returns: Iterator over tuples with SHA1s and ref names.
     """
-    for l in f:
-        if l.startswith(b'#'):
+    for line in f:
+        if line.startswith(b'#'):
             # Comment
             continue
-        if l.startswith(b'^'):
+        if line.startswith(b'^'):
             raise PackedRefsException(
               "found peeled ref in packed-refs without peeled")
-        yield _split_ref_line(l)
+        yield _split_ref_line(line)
 
 
 def read_packed_refs_with_peeled(f):
@@ -935,8 +935,8 @@ def write_packed_refs(f, packed_refs, peeled_refs=None):
 
 def read_info_refs(f):
     ret = {}
-    for l in f.readlines():
-        (sha, name) = l.rstrip(b"\r\n").split(b"\t", 1)
+    for line in f.readlines():
+        (sha, name) = line.rstrip(b"\r\n").split(b"\t", 1)
         ret[name] = sha
     return ret
 

+ 4 - 4
dulwich/repo.py

@@ -212,8 +212,8 @@ def parse_graftpoints(graftpoints):
     https://git.wiki.kernel.org/index.php/GraftPoint
     """
     grafts = {}
-    for l in graftpoints:
-        raw_graft = l.split(None, 1)
+    for line in graftpoints:
+        raw_graft = line.split(None, 1)
 
         commit = raw_graft[0]
         if len(raw_graft) == 2:
@@ -605,7 +605,7 @@ class BaseRepo(object):
         if f is None:
             return set()
         with f:
-            return set(l.strip() for l in f)
+            return set(line.strip() for line in f)
 
     def update_shallow(self, new_shallow, new_unshallow):
         """Update the list of shallow objects.
@@ -769,7 +769,7 @@ class BaseRepo(object):
         if f is None:
             return []
         with f:
-            return [l.strip() for l in f.readlines() if l.strip()]
+            return [line.strip() for line in f.readlines() if line.strip()]
 
     def do_commit(self, message=None, committer=None,
                   author=None, commit_timestamp=None,

+ 1 - 2
dulwich/tests/compat/test_client.py

@@ -31,7 +31,6 @@ import sys
 import tarfile
 import tempfile
 import threading
-import unittest
 
 from urllib.parse import unquote
 
@@ -133,7 +132,7 @@ class DulwichClientTestBase(object):
                 local.refs.set_if_equals(r[0], None, r[1])
             tree_id = local[local.head()].tree
             for filename, contents in [('bar', 'bar contents'),
-                                   ('zop', 'zop contents')]:
+                                       ('zop', 'zop contents')]:
                 tree_id = self._add_file(local, tree_id, filename, contents)
                 commit_id = local.do_commit(
                     message=b"add " + filename.encode('utf-8'),

+ 1 - 1
dulwich/tests/test_porcelain.py

@@ -1287,7 +1287,7 @@ class ReceivePackTests(PorcelainTestCase):
             b'0091319b56ce3aee2d489f759736a79cc552c9bb86d9 HEAD\x00 report-status '  # noqa: E501
             b'delete-refs quiet ofs-delta side-band-64k '
             b'no-done symref=HEAD:refs/heads/master',
-           b'003f319b56ce3aee2d489f759736a79cc552c9bb86d9 refs/heads/master',
+            b'003f319b56ce3aee2d489f759736a79cc552c9bb86d9 refs/heads/master',
             b'0000'], outlines)
         self.assertEqual(0, exitcode)
 

+ 2 - 2
dulwich/tests/test_refs.py

@@ -506,8 +506,8 @@ class DiskRefsContainerTests(RefsContainerTests, TestCase):
         refs_data = f.read()
         f.close()
         f = GitFile(refs_file, 'wb')
-        f.write(b'\n'.join(l for l in refs_data.split(b'\n')
-                           if not l or l[0] not in b'#^'))
+        f.write(b'\n'.join(line for line in refs_data.split(b'\n')
+                           if not line or line[0] not in b'#^'))
         f.close()
         self._repo = Repo(self._repo.path)
         refs = self._repo.refs