Accepting request 1181735 from devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/1181735
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pygit2?expand=0&rev=39
This commit is contained in:
Ana Guerrero 2024-06-20 14:47:12 +00:00 committed by Git OBS Bridge
commit fd073f52b5
9 changed files with 49 additions and 456 deletions

View File

@ -1,67 +0,0 @@
From 51d35d010b9dcee199be5eb3785246ca9ef418e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= <jdavid.ibp@gmail.com>
Date: Thu, 21 Mar 2024 10:53:59 +0100
Subject: [PATCH] Fix CI
(cherry picked from commit 3eba911fb5fcc4d431d31848a66f117df8275af2)
---
src/blob.c | 1 +
src/filter.c | 1 +
test/test_credentials.py | 10 ++++++----
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/blob.c b/src/blob.c
index e69a8f7..a1f40df 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -28,6 +28,7 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <git2.h>
+#include <git2/sys/errors.h>
#include "diff.h"
#include "error.h"
#include "object.h"
diff --git a/src/filter.c b/src/filter.c
index a1b220e..5e51a20 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -28,6 +28,7 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <git2.h>
+#include <git2/sys/errors.h>
#include <git2/sys/filter.h>
#include "diff.h"
#include "error.h"
diff --git a/test/test_credentials.py b/test/test_credentials.py
index 2d1166c..04e2185 100644
--- a/test/test_credentials.py
+++ b/test/test_credentials.py
@@ -26,6 +26,7 @@
"""Tests for credentials"""
from pathlib import Path
+import platform
import pytest
@@ -161,10 +162,11 @@ def test_fetch_certificate_check(testrepo):
remote.fetch(callbacks=MyCallbacks())
# libgit2 uses different error message for Linux and Windows
- # TODO test one or the other depending on the platform
- assert str(exc.value) in (
- 'user rejected certificate for github.com', # httpclient
- 'user cancelled certificate check') # winhttp
+ value = str(exc.value)
+ if platform.system() == 'Windows':
+ assert value == 'user cancelled certificate check' # winhttp
+ else:
+ assert value == 'user rejected certificate for github.com' # httpclient
# TODO Add GitError.error_code
#assert exc.value.error_code == pygit2.GIT_ERROR_HTTP
--
2.44.0

View File

@ -1,171 +0,0 @@
From 0f8a1a91db0825daa0d25549f15791bcee0f9a94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= <jdavid.ibp@gmail.com>
Date: Sun, 24 Mar 2024 09:09:36 +0100
Subject: [PATCH] Fix leaks in fetch_refspecs and push_refspecs
Also use git_strarray_dispose instead of deprecated git_strarray_free.
And fix a couple of build warnings in git_commit_create.
(cherry picked from commit c7c65cf12547eeadb46cfb30531285e1afcbd708)
---
pygit2/decl/strarray.h | 2 +-
pygit2/remotes.py | 16 +++-------------
pygit2/utils.py | 15 ++++++++++-----
src/repository.c | 10 ++++------
4 files changed, 18 insertions(+), 25 deletions(-)
diff --git a/pygit2/decl/strarray.h b/pygit2/decl/strarray.h
index a9b249f..fdbf2aa 100644
--- a/pygit2/decl/strarray.h
+++ b/pygit2/decl/strarray.h
@@ -3,4 +3,4 @@ typedef struct git_strarray {
size_t count;
} git_strarray;
-void git_strarray_free(git_strarray *array);
+void git_strarray_dispose(git_strarray *array);
diff --git a/pygit2/remotes.py b/pygit2/remotes.py
index 3c4748c..37a6ca3 100644
--- a/pygit2/remotes.py
+++ b/pygit2/remotes.py
@@ -222,7 +222,6 @@ class Remote:
specs = ffi.new('git_strarray *')
err = C.git_remote_get_fetch_refspecs(specs, self._remote)
check_error(err)
-
return strarray_to_strings(specs)
@property
@@ -232,7 +231,6 @@ class Remote:
specs = ffi.new('git_strarray *')
err = C.git_remote_get_push_refspecs(specs, self._remote)
check_error(err)
-
return strarray_to_strings(specs)
def push(self, specs, callbacks=None, proxy=None):
@@ -294,14 +292,12 @@ class RemoteCollection:
def __len__(self):
names = ffi.new('git_strarray *')
-
try:
err = C.git_remote_list(names, self._repo._repo)
check_error(err)
-
return names.count
finally:
- C.git_strarray_free(names)
+ C.git_strarray_dispose(names)
def __iter__(self):
cremote = ffi.new('git_remote **')
@@ -323,15 +319,13 @@ class RemoteCollection:
def _ffi_names(self):
names = ffi.new('git_strarray *')
-
try:
err = C.git_remote_list(names, self._repo._repo)
check_error(err)
-
for i in range(names.count):
yield names.strings[i]
finally:
- C.git_strarray_free(names)
+ C.git_strarray_dispose(names)
def names(self):
"""An iterator over the names of the available remotes."""
@@ -386,11 +380,7 @@ class RemoteCollection:
problems = ffi.new('git_strarray *')
err = C.git_remote_rename(problems, self._repo._repo, to_bytes(name), to_bytes(new_name))
check_error(err)
-
- ret = strarray_to_strings(problems)
- C.git_strarray_free(problems)
-
- return ret
+ return strarray_to_strings(problems)
def delete(self, name):
"""Remove a remote from the configuration
diff --git a/pygit2/utils.py b/pygit2/utils.py
index 638c199..f4e3fc8 100644
--- a/pygit2/utils.py
+++ b/pygit2/utils.py
@@ -26,7 +26,7 @@
import os
# Import from pygit2
-from .ffi import ffi
+from .ffi import ffi, C
def maybe_string(ptr):
@@ -73,11 +73,16 @@ def ptr_to_bytes(ptr_cdata):
def strarray_to_strings(arr):
- l = [None] * arr.count
- for i in range(arr.count):
- l[i] = ffi.string(arr.strings[i]).decode('utf-8')
+ """
+ Return a list of strings from a git_strarray pointer.
- return l
+ Free the strings contained in the git_strarry, this means it won't be usable after
+ calling this function.
+ """
+ try:
+ return [ffi.string(arr.strings[i]).decode('utf-8') for i in range(arr.count)]
+ finally:
+ C.git_strarray_dispose(arr)
class StrArray:
diff --git a/src/repository.c b/src/repository.c
index cf7597c..1f6db24 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1069,8 +1069,7 @@ Repository_create_commit(Repository *self, PyObject *args)
err = git_commit_create(&oid, self->repo, update_ref,
py_author->signature, py_committer->signature,
- encoding, message, tree, parent_count,
- (const git_commit**)parents);
+ encoding, message, tree, parent_count, parents);
if (err < 0) {
Error_set(err);
goto out;
@@ -1152,8 +1151,7 @@ Repository_create_commit_string(Repository *self, PyObject *args)
err = git_commit_create_buffer(&buf, self->repo,
py_author->signature, py_committer->signature,
- encoding, message, tree, parent_count,
- (const git_commit**)parents);
+ encoding, message, tree, parent_count, parents);
if (err < 0) {
Error_set(err);
goto out;
@@ -1313,7 +1311,7 @@ Repository_raw_listall_references(Repository *self, PyObject *args)
}
out:
- git_strarray_free(&c_result);
+ git_strarray_dispose(&c_result);
return py_result;
}
@@ -2182,7 +2180,7 @@ Repository_list_worktrees(Repository *self, PyObject *args)
}
out:
- git_strarray_free(&c_result);
+ git_strarray_dispose(&c_result);
return py_result;
}
--
2.44.0

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ec5958571b82a6351785ca645e5394c31ae45eec5384b2fa9c4e05dde3597ad6
size 765621

3
pygit2-1.15.0.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a635525ffc74128669de2f63460a94c9d5609634a4875c0aafce510fdeec17ac
size 766816

View File

@ -1,133 +0,0 @@
--- pygit2-1.14.1/build.sh 2024-03-31 00:04:31.748162119 +0100
+++ pygit2-1.14.1/build.sh 2024-03-31 00:04:44.734562399 +0100
@@ -22,14 +22,14 @@
#
# sh build.sh
#
-# Build libgit2 1.7.2 (will use libssh2 if available), then build pygit2
+# Build libgit2 1.8.0 (will use libssh2 if available), then build pygit2
# inplace:
#
-# LIBGIT2_VERSION=1.7.2 sh build.sh
+# LIBGIT2_VERSION=1.8.0 sh build.sh
#
-# Build libssh2 1.11.0 and libgit2 1.7.2, then build pygit2 inplace:
+# Build libssh2 1.11.0 and libgit2 1.8.0, then build pygit2 inplace:
#
-# LIBSSH2_VERSION=1.11.0 LIBGIT2_VERSION=1.7.2 sh build.sh
+# LIBSSH2_VERSION=1.11.0 LIBGIT2_VERSION=1.8.0 sh build.sh
#
# Build inplace and run the tests:
#
--- pygit2-1.14.1/Makefile 2024-03-31 00:04:31.748162119 +0100
+++ pygit2-1.14.1/Makefile 2024-03-31 00:04:44.734562399 +0100
@@ -1,7 +1,7 @@
.PHONY: build html
build:
- OPENSSL_VERSION=3.1.5 LIBSSH2_VERSION=1.11.0 LIBGIT2_VERSION=1.7.2 sh build.sh
+ OPENSSL_VERSION=3.1.5 LIBSSH2_VERSION=1.11.0 LIBGIT2_VERSION=1.8.0 sh build.sh
html: build
make -C docs html
--- pygit2-1.14.1/pygit2/decl/config.h 2024-03-31 00:04:31.751495384 +0100
+++ pygit2-1.14.1/pygit2/decl/config.h 2024-03-31 00:04:44.734562399 +0100
@@ -6,17 +6,19 @@
GIT_CONFIG_LEVEL_XDG = 3,
GIT_CONFIG_LEVEL_GLOBAL = 4,
GIT_CONFIG_LEVEL_LOCAL = 5,
- GIT_CONFIG_LEVEL_APP = 6,
- GIT_CONFIG_HIGHEST_LEVEL = -1,
+ GIT_CONFIG_LEVEL_WORKTREE = 6,
+ GIT_CONFIG_LEVEL_APP = 7,
+ GIT_CONFIG_HIGHEST_LEVEL = -1
} git_config_level_t;
typedef struct git_config_entry {
const char *name;
const char *value;
+ const char *backend_type;
+ const char *origin_path;
unsigned int include_depth;
git_config_level_t level;
void (*free)(struct git_config_entry *entry);
- void *payload;
} git_config_entry;
void git_config_entry_free(git_config_entry *);
--- pygit2-1.14.1/pygit2/decl/remote.h 2024-03-31 00:04:31.751495384 +0100
+++ pygit2-1.14.1/pygit2/decl/remote.h 2024-03-31 00:04:44.734562399 +0100
@@ -57,6 +57,7 @@
git_proxy_options proxy_opts;
git_remote_redirect_t follow_redirects;
git_strarray custom_headers;
+ git_strarray remote_push_options;
} git_push_options;
int git_push_options_init(
@@ -80,7 +81,8 @@
int version;
git_remote_callbacks callbacks;
git_fetch_prune_t prune;
- int update_fetchhead;
+ unsigned int update_fetchhead : 1,
+ report_unchanged : 1;
git_remote_autotag_option_t download_tags;
git_proxy_options proxy_opts;
int depth;
--- pygit2-1.14.1/pygit2/enums.py 2024-03-31 00:04:31.751495384 +0100
+++ pygit2-1.14.1/pygit2/enums.py 2024-03-31 00:05:38.713455156 +0100
@@ -65,16 +65,16 @@
"Normal blame, the default"
TRACK_COPIES_SAME_FILE = _pygit2.GIT_BLAME_TRACK_COPIES_SAME_FILE
- "Not yet implemented and reserved for future use (as of libgit2 1.7.1)."
+ "Not yet implemented and reserved for future use (as of libgit2 1.8.0)."
TRACK_COPIES_SAME_COMMIT_MOVES = _pygit2.GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES
- "Not yet implemented and reserved for future use (as of libgit2 1.7.1)."
+ "Not yet implemented and reserved for future use (as of libgit2 1.8.0)."
TRACK_COPIES_SAME_COMMIT_COPIES = _pygit2.GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES
- "Not yet implemented and reserved for future use (as of libgit2 1.7.1)."
+ "Not yet implemented and reserved for future use (as of libgit2 1.8.0)."
TRACK_COPIES_ANY_COMMIT_COPIES = _pygit2.GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES
- "Not yet implemented and reserved for future use (as of libgit2 1.7.1)."
+ "Not yet implemented and reserved for future use (as of libgit2 1.8.0)."
FIRST_PARENT = _pygit2.GIT_BLAME_FIRST_PARENT
"Restrict the search of commits to those reachable following only the first parents."
@@ -251,6 +251,9 @@
LOCAL = _pygit2.GIT_CONFIG_LEVEL_LOCAL
"Repository specific configuration file; $WORK_DIR/.git/config on non-bare repos"
+ WORKTREE = _pygit2.GIT_CONFIG_LEVEL_WORKTREE
+ 'Worktree specific configuration file; $GIT_DIR/config.worktree'
+
APP = _pygit2.GIT_CONFIG_LEVEL_APP
"Application specific configuration file; freely defined by applications"
--- pygit2-1.14.1/src/pygit2.c 2024-03-31 00:04:31.754828649 +0100
+++ pygit2-1.14.1/src/pygit2.c 2024-03-31 00:04:44.734562399 +0100
@@ -792,6 +792,7 @@
ADD_CONSTANT_INT(m, GIT_CONFIG_LEVEL_XDG);
ADD_CONSTANT_INT(m, GIT_CONFIG_LEVEL_GLOBAL);
ADD_CONSTANT_INT(m, GIT_CONFIG_LEVEL_LOCAL);
+ ADD_CONSTANT_INT(m, GIT_CONFIG_LEVEL_WORKTREE);
ADD_CONSTANT_INT(m, GIT_CONFIG_LEVEL_APP);
ADD_CONSTANT_INT(m, GIT_CONFIG_HIGHEST_LEVEL);
--- pygit2-1.14.1/src/types.h 2024-03-31 00:04:31.754828649 +0100
+++ pygit2-1.14.1/src/types.h 2024-03-31 00:04:44.734562399 +0100
@@ -33,8 +33,8 @@
#include <git2.h>
#include <git2/sys/filter.h>
-#if !(LIBGIT2_VER_MAJOR == 1 && LIBGIT2_VER_MINOR == 7)
-#error You need a compatible libgit2 version (1.7.x)
+#if !(LIBGIT2_VER_MAJOR == 1 && LIBGIT2_VER_MINOR == 8)
+#error You need a compatible libgit2 version (1.8.x)
#endif
/*

View File

@ -1,23 +0,0 @@
From dabd40c54fa3a086a5b1b1dd0f2fb86a689eef69 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= <jdavid.ibp@gmail.com>
Date: Fri, 17 May 2024 09:53:05 +0200
Subject: [PATCH] Update to libgit2 1.8.1
---
pygit2/decl/remote.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/pygit2/decl/remote.h b/pygit2/decl/remote.h
index 6a4ee90b..64b96442 100644
--- a/pygit2/decl/remote.h
+++ b/pygit2/decl/remote.h
@@ -81,8 +81,7 @@ typedef struct {
int version;
git_remote_callbacks callbacks;
git_fetch_prune_t prune;
- unsigned int update_fetchhead : 1,
- report_unchanged : 1;
+ unsigned int update_fetchhead;
git_remote_autotag_option_t download_tags;
git_proxy_options proxy_opts;
int depth;

View File

@ -1,46 +0,0 @@
From 31ea782852a318214149d24b73fc0e6ebe4210c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= <jdavid.ibp@gmail.com>
Date: Fri, 17 May 2024 09:29:14 +0200
Subject: [PATCH] Update to libgit2 1.8.1
---
.github/workflows/tests.yml | 8 ++++----
Makefile | 2 +-
appveyor.yml | 2 +-
build.sh | 8 ++++----
docs/install.rst | 14 +++++++-------
pyproject.toml | 4 ++--
6 files changed, 19 insertions(+), 19 deletions(-)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
.PHONY: build html
build:
- OPENSSL_VERSION=3.1.5 LIBSSH2_VERSION=1.11.0 LIBGIT2_VERSION=1.8.0 sh build.sh
+ OPENSSL_VERSION=3.1.5 LIBSSH2_VERSION=1.11.0 LIBGIT2_VERSION=1.8.1 sh build.sh
html: build
make -C docs html
--- a/build.sh
+++ b/build.sh
@@ -22,14 +22,14 @@
#
# sh build.sh
#
-# Build libgit2 1.8.0 (will use libssh2 if available), then build pygit2
+# Build libgit2 1.8.1 (will use libssh2 if available), then build pygit2
# inplace:
#
-# LIBGIT2_VERSION=1.8.0 sh build.sh
+# LIBGIT2_VERSION=1.8.1 sh build.sh
#
-# Build libssh2 1.11.0 and libgit2 1.8.0, then build pygit2 inplace:
+# Build libssh2 1.11.0 and libgit2 1.8.1, then build pygit2 inplace:
#
-# LIBSSH2_VERSION=1.11.0 LIBGIT2_VERSION=1.8.0 sh build.sh
+# LIBSSH2_VERSION=1.11.0 LIBGIT2_VERSION=1.8.1 sh build.sh
#
# Build inplace and run the tests:
#

View File

@ -1,3 +1,44 @@
-------------------------------------------------------------------
Wed Jun 19 10:53:06 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Update to 1.15.1
* Many deprecated features have been removed, see below
* Upgrade to libgit2 v1.8.1
* New `push_options` optional argument in `Repository.push(...)`
* New support comparison of `Oid` with text string
* Fix `CheckoutNotify.IGNORED`
* Use default error handler when decoding/encoding paths
* Remove setuptools runtime dependency
* Coding style with ruff
* Add wheels for ppc64le
* Fix tests on EPEL8 builds for s390x
* Deprecate `IndexEntry.hex`, use `str(IndexEntry.id)`
* Remove deprecated `oid.hex`, use `str(oid)`
* Remove deprecated `object.hex`, use `str(object.id)`
* Remove deprecated `object.oid`, use `object.id`
* Remove deprecated `Repository.add_submodule(...)`, use `Repository.submodules.add(...)`
* Remove deprecated `Repository.lookup_submodule(...)`, use `Repository.submodules[...]`
* Remove deprecated `Repository.init_submodules(...)`, use `Repository.submodules.init(...)`
* Remove deprecated `Repository.update_submodule(...)`, use `Repository.submodules.update(...)`
* Remove deprecated constants `GIT_OBJ_XXX`, use `ObjectType`
* Remove deprecated constants `GIT_REVPARSE_XXX`, use `RevSpecFlag`
* Remove deprecated constants `GIT_REF_XXX`, use `ReferenceType`
* Remove deprecated `ReferenceType.OID`, use instead `ReferenceType.DIRECT`
* Remove deprecated `ReferenceType.LISTALL`, use instead `ReferenceType.ALL`
* Remove deprecated support for passing dicts to repository\'s `merge(...)`,
`merge_commits(...)` and `merge_trees(...)`. Instead pass `MergeFlag` for `flags`, and
`MergeFileFlag` for `file_flags`.
* Remove deprecated support for passing a string for the favor argument to repository\'s
`merge(...)`, `merge_commits(...)` and `merge_trees(...)`. Instead pass `MergeFavor`.
- Drop patches for issues fixed upstream
* Fix-CI.patch
* Fix-leaks-in-fetch_refspecs-and-push_refspecs.patch
* pygit2-Upgrade_to_libgit2_v1_8_0.patch
* pygit2-Upgrade_to_libgit2_v1_8_1-2.patch
* pygit2-Upgrade_to_libgit2_v1_8_1.patch
- Disable test test_push_options which currently segfaults
- Update BuildRequires from setup.py
-------------------------------------------------------------------
Fri May 17 10:57:08 UTC 2024 - Dirk Müller <dmueller@suse.com>

View File

@ -19,24 +19,14 @@
%{?sle15_python_module_pythons}
Name: python-pygit2
Version: 1.14.1
Version: 1.15.0
Release: 0
Summary: Python bindings for libgit2
License: GPL-2.0-only
URL: https://github.com/libgit2/pygit2
Source: https://files.pythonhosted.org/packages/source/p/pygit2/pygit2-%{version}.tar.gz
# PATCH-FIX-UPSTREAM pygit2-Upgrade_to_libgit2_v1_8_0.patch gh#libgit2/pygit2@6d539d76b53b
Patch0: pygit2-Upgrade_to_libgit2_v1_8_0.patch
# PATCH-FIX-UPSTREAM - fixup for the libgit 1.8 support
Patch1: Fix-CI.patch
# PATCH-FIX-UPSTREAM
Patch2: pygit2-Upgrade_to_libgit2_v1_8_1.patch
# PATCH-FIX-UPSTREAM
Patch3: pygit2-Upgrade_to_libgit2_v1_8_1-2.patch
# PATCH-FIX-UPSTREAM - happens to eliminate bogus pointer casts
Patch4: Fix-leaks-in-fetch_refspecs-and-push_refspecs.patch
BuildRequires: %{python_module cached-property}
BuildRequires: %{python_module cffi >= 1.4.0}
BuildRequires: %{python_module cffi >= 1.16.0}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module pytest}
@ -80,7 +70,9 @@ export CFLAGS="%{optflags} -fno-strict-aliasing"
rm -rf pygit2
# test_no_context_lines failing on big endian
# https://github.com/libgit2/pygit2/issues/812
%pytest_arch -k 'not test_no_context_lines'
donttest="test_no_context_lines"
donttest="$donttest or test_push_options"
%pytest_arch -k "not ($donttest)"
%files %{python_files}
%license COPYING