pygit2 1.16.0__cp313-cp313-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pygit2/__init__.py +225 -0
- pygit2/_build.py +74 -0
- pygit2/_libgit2.pyd +0 -0
- pygit2/_pygit2.cp313-win32.pyd +0 -0
- pygit2/_pygit2.pyi +569 -0
- pygit2/_run.py +107 -0
- pygit2/blame.py +147 -0
- pygit2/blob.py +155 -0
- pygit2/branches.py +99 -0
- pygit2/callbacks.py +785 -0
- pygit2/config.py +366 -0
- pygit2/credentials.py +125 -0
- pygit2/decl/attr.h +31 -0
- pygit2/decl/blame.h +49 -0
- pygit2/decl/buffer.h +7 -0
- pygit2/decl/callbacks.h +67 -0
- pygit2/decl/checkout.h +87 -0
- pygit2/decl/clone.h +44 -0
- pygit2/decl/commit.h +16 -0
- pygit2/decl/common.h +10 -0
- pygit2/decl/config.h +55 -0
- pygit2/decl/describe.h +48 -0
- pygit2/decl/diff.h +91 -0
- pygit2/decl/errors.h +51 -0
- pygit2/decl/graph.h +1 -0
- pygit2/decl/index.h +74 -0
- pygit2/decl/indexer.h +11 -0
- pygit2/decl/merge.h +96 -0
- pygit2/decl/net.h +5 -0
- pygit2/decl/oid.h +16 -0
- pygit2/decl/pack.h +18 -0
- pygit2/decl/proxy.h +18 -0
- pygit2/decl/refspec.h +9 -0
- pygit2/decl/remote.h +151 -0
- pygit2/decl/repository.h +94 -0
- pygit2/decl/revert.h +21 -0
- pygit2/decl/stash.h +90 -0
- pygit2/decl/strarray.h +6 -0
- pygit2/decl/submodule.h +43 -0
- pygit2/decl/transport.h +61 -0
- pygit2/decl/types.h +70 -0
- pygit2/enums.py +1299 -0
- pygit2/errors.py +72 -0
- pygit2/ffi.py +27 -0
- pygit2/filter.py +109 -0
- pygit2/git2.dll +0 -0
- pygit2/index.py +491 -0
- pygit2/legacyenums.py +113 -0
- pygit2/packbuilder.py +79 -0
- pygit2/py.typed +1 -0
- pygit2/references.py +104 -0
- pygit2/refspec.py +95 -0
- pygit2/remotes.py +422 -0
- pygit2/repository.py +1619 -0
- pygit2/settings.py +193 -0
- pygit2/submodules.py +372 -0
- pygit2/utils.py +177 -0
- pygit2-1.16.0.dist-info/AUTHORS.md +227 -0
- pygit2-1.16.0.dist-info/COPYING +361 -0
- pygit2-1.16.0.dist-info/METADATA +76 -0
- pygit2-1.16.0.dist-info/RECORD +63 -0
- pygit2-1.16.0.dist-info/WHEEL +5 -0
- pygit2-1.16.0.dist-info/top_level.txt +1 -0
pygit2/__init__.py
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Copyright 2010-2024 The pygit2 contributors
|
|
2
|
+
#
|
|
3
|
+
# This file is free software; you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License, version 2,
|
|
5
|
+
# as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# In addition to the permissions in the GNU General Public License,
|
|
8
|
+
# the authors give you unlimited permission to link the compiled
|
|
9
|
+
# version of this file into combinations with other programs,
|
|
10
|
+
# and to distribute those combinations without any restriction
|
|
11
|
+
# coming from the use of this file. (The General Public License
|
|
12
|
+
# restrictions do apply in other respects; for example, they cover
|
|
13
|
+
# modification of the file, and distribution when not linked into
|
|
14
|
+
# a combined executable.)
|
|
15
|
+
#
|
|
16
|
+
# This file is distributed in the hope that it will be useful, but
|
|
17
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
19
|
+
# General Public License for more details.
|
|
20
|
+
#
|
|
21
|
+
# You should have received a copy of the GNU General Public License
|
|
22
|
+
# along with this program; see the file COPYING. If not, write to
|
|
23
|
+
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
24
|
+
# Boston, MA 02110-1301, USA.
|
|
25
|
+
|
|
26
|
+
# Standard Library
|
|
27
|
+
import functools
|
|
28
|
+
from os import PathLike
|
|
29
|
+
import typing
|
|
30
|
+
|
|
31
|
+
# Low level API
|
|
32
|
+
from ._pygit2 import *
|
|
33
|
+
from ._pygit2 import _cache_enums
|
|
34
|
+
|
|
35
|
+
# High level API
|
|
36
|
+
from . import enums
|
|
37
|
+
from ._build import __version__
|
|
38
|
+
from .blame import Blame, BlameHunk
|
|
39
|
+
from .blob import BlobIO
|
|
40
|
+
from .callbacks import Payload, RemoteCallbacks, CheckoutCallbacks, StashApplyCallbacks
|
|
41
|
+
from .callbacks import git_clone_options, git_fetch_options, get_credentials
|
|
42
|
+
from .config import Config
|
|
43
|
+
from .credentials import *
|
|
44
|
+
from .errors import check_error, Passthrough
|
|
45
|
+
from .ffi import ffi, C
|
|
46
|
+
from .filter import Filter
|
|
47
|
+
from .index import Index, IndexEntry
|
|
48
|
+
from .legacyenums import *
|
|
49
|
+
from .packbuilder import PackBuilder
|
|
50
|
+
from .remotes import Remote
|
|
51
|
+
from .repository import Repository
|
|
52
|
+
from .settings import Settings
|
|
53
|
+
from .submodules import Submodule
|
|
54
|
+
from .utils import to_bytes, to_str
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Features
|
|
58
|
+
features = enums.Feature(C.git_libgit2_features())
|
|
59
|
+
|
|
60
|
+
# libgit version tuple
|
|
61
|
+
LIBGIT2_VER = (LIBGIT2_VER_MAJOR, LIBGIT2_VER_MINOR, LIBGIT2_VER_REVISION)
|
|
62
|
+
|
|
63
|
+
# Let _pygit2 cache references to Python enum types.
|
|
64
|
+
# This is separate from PyInit__pygit2() to avoid a circular import.
|
|
65
|
+
_cache_enums()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def init_repository(
|
|
69
|
+
path: typing.Union[str, bytes, PathLike, None],
|
|
70
|
+
bare: bool = False,
|
|
71
|
+
flags: enums.RepositoryInitFlag = enums.RepositoryInitFlag.MKPATH,
|
|
72
|
+
mode: typing.Union[
|
|
73
|
+
int, enums.RepositoryInitMode
|
|
74
|
+
] = enums.RepositoryInitMode.SHARED_UMASK,
|
|
75
|
+
workdir_path: typing.Optional[str] = None,
|
|
76
|
+
description: typing.Optional[str] = None,
|
|
77
|
+
template_path: typing.Optional[str] = None,
|
|
78
|
+
initial_head: typing.Optional[str] = None,
|
|
79
|
+
origin_url: typing.Optional[str] = None,
|
|
80
|
+
) -> Repository:
|
|
81
|
+
"""
|
|
82
|
+
Creates a new Git repository in the given *path*.
|
|
83
|
+
|
|
84
|
+
If *bare* is True the repository will be bare, i.e. it will not have a
|
|
85
|
+
working copy.
|
|
86
|
+
|
|
87
|
+
The *flags* may be a combination of enums.RepositoryInitFlag constants:
|
|
88
|
+
|
|
89
|
+
- BARE (overriden by the *bare* parameter)
|
|
90
|
+
- NO_REINIT
|
|
91
|
+
- NO_DOTGIT_DIR
|
|
92
|
+
- MKDIR
|
|
93
|
+
- MKPATH (set by default)
|
|
94
|
+
- EXTERNAL_TEMPLATE
|
|
95
|
+
|
|
96
|
+
The *mode* parameter may be any of the predefined modes in
|
|
97
|
+
enums.RepositoryInitMode (SHARED_UMASK being the default), or a custom int.
|
|
98
|
+
|
|
99
|
+
The *workdir_path*, *description*, *template_path*, *initial_head* and
|
|
100
|
+
*origin_url* are all strings.
|
|
101
|
+
|
|
102
|
+
See libgit2's documentation on git_repository_init_ext for further details.
|
|
103
|
+
"""
|
|
104
|
+
# Pre-process input parameters
|
|
105
|
+
if path is None:
|
|
106
|
+
raise TypeError('Expected string type for path, found None.')
|
|
107
|
+
|
|
108
|
+
if bare:
|
|
109
|
+
flags |= enums.RepositoryInitFlag.BARE
|
|
110
|
+
|
|
111
|
+
# Options
|
|
112
|
+
options = ffi.new('git_repository_init_options *')
|
|
113
|
+
C.git_repository_init_options_init(options, C.GIT_REPOSITORY_INIT_OPTIONS_VERSION)
|
|
114
|
+
options.flags = int(flags)
|
|
115
|
+
options.mode = mode
|
|
116
|
+
|
|
117
|
+
if workdir_path:
|
|
118
|
+
workdir_path_ref = ffi.new('char []', to_bytes(workdir_path))
|
|
119
|
+
options.workdir_path = workdir_path_ref
|
|
120
|
+
|
|
121
|
+
if description:
|
|
122
|
+
description_ref = ffi.new('char []', to_bytes(description))
|
|
123
|
+
options.description = description_ref
|
|
124
|
+
|
|
125
|
+
if template_path:
|
|
126
|
+
template_path_ref = ffi.new('char []', to_bytes(template_path))
|
|
127
|
+
options.template_path = template_path_ref
|
|
128
|
+
|
|
129
|
+
if initial_head:
|
|
130
|
+
initial_head_ref = ffi.new('char []', to_bytes(initial_head))
|
|
131
|
+
options.initial_head = initial_head_ref
|
|
132
|
+
|
|
133
|
+
if origin_url:
|
|
134
|
+
origin_url_ref = ffi.new('char []', to_bytes(origin_url))
|
|
135
|
+
options.origin_url = origin_url_ref
|
|
136
|
+
|
|
137
|
+
# Call
|
|
138
|
+
crepository = ffi.new('git_repository **')
|
|
139
|
+
err = C.git_repository_init_ext(crepository, to_bytes(path), options)
|
|
140
|
+
check_error(err)
|
|
141
|
+
|
|
142
|
+
# Ok
|
|
143
|
+
return Repository(to_str(path))
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def clone_repository(
|
|
147
|
+
url,
|
|
148
|
+
path,
|
|
149
|
+
bare=False,
|
|
150
|
+
repository=None,
|
|
151
|
+
remote=None,
|
|
152
|
+
checkout_branch=None,
|
|
153
|
+
callbacks=None,
|
|
154
|
+
depth=0,
|
|
155
|
+
):
|
|
156
|
+
"""
|
|
157
|
+
Clones a new Git repository from *url* in the given *path*.
|
|
158
|
+
|
|
159
|
+
Returns: a Repository class pointing to the newly cloned repository.
|
|
160
|
+
|
|
161
|
+
Parameters:
|
|
162
|
+
|
|
163
|
+
url : str
|
|
164
|
+
URL of the repository to clone.
|
|
165
|
+
path : str
|
|
166
|
+
Local path to clone into.
|
|
167
|
+
bare : bool
|
|
168
|
+
Whether the local repository should be bare.
|
|
169
|
+
remote : callable
|
|
170
|
+
Callback for the remote to use.
|
|
171
|
+
|
|
172
|
+
The remote callback has `(Repository, name, url) -> Remote` as a
|
|
173
|
+
signature. The Remote it returns will be used instead of the default
|
|
174
|
+
one.
|
|
175
|
+
repository : callable
|
|
176
|
+
Callback for the repository to use.
|
|
177
|
+
|
|
178
|
+
The repository callback has `(path, bare) -> Repository` as a
|
|
179
|
+
signature. The Repository it returns will be used instead of creating a
|
|
180
|
+
new one.
|
|
181
|
+
checkout_branch : str
|
|
182
|
+
Branch to checkout after the clone. The default is to use the remote's
|
|
183
|
+
default branch.
|
|
184
|
+
callbacks : RemoteCallbacks
|
|
185
|
+
Object which implements the callbacks as methods.
|
|
186
|
+
|
|
187
|
+
The callbacks should be an object which inherits from
|
|
188
|
+
`pyclass:RemoteCallbacks`.
|
|
189
|
+
depth : int
|
|
190
|
+
Number of commits to clone.
|
|
191
|
+
|
|
192
|
+
If greater than 0, creates a shallow clone with a history truncated to
|
|
193
|
+
the specified number of commits.
|
|
194
|
+
The default is 0 (full commit history).
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
if callbacks is None:
|
|
198
|
+
callbacks = RemoteCallbacks()
|
|
199
|
+
|
|
200
|
+
# Add repository and remote to the payload
|
|
201
|
+
payload = callbacks
|
|
202
|
+
payload.repository = repository
|
|
203
|
+
payload.remote = remote
|
|
204
|
+
|
|
205
|
+
with git_clone_options(payload):
|
|
206
|
+
opts = payload.clone_options
|
|
207
|
+
opts.bare = bare
|
|
208
|
+
opts.fetch_opts.depth = depth
|
|
209
|
+
|
|
210
|
+
if checkout_branch:
|
|
211
|
+
checkout_branch_ref = ffi.new('char []', to_bytes(checkout_branch))
|
|
212
|
+
opts.checkout_branch = checkout_branch_ref
|
|
213
|
+
|
|
214
|
+
with git_fetch_options(payload, opts=opts.fetch_opts):
|
|
215
|
+
crepo = ffi.new('git_repository **')
|
|
216
|
+
err = C.git_clone(crepo, to_bytes(url), to_bytes(path), opts)
|
|
217
|
+
payload.check_error(err)
|
|
218
|
+
|
|
219
|
+
# Ok
|
|
220
|
+
return Repository._from_c(crepo[0], owned=True)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
tree_entry_key = functools.cmp_to_key(tree_entry_cmp)
|
|
224
|
+
|
|
225
|
+
settings = Settings()
|
pygit2/_build.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Copyright 2010-2024 The pygit2 contributors
|
|
2
|
+
#
|
|
3
|
+
# This file is free software; you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License, version 2,
|
|
5
|
+
# as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# In addition to the permissions in the GNU General Public License,
|
|
8
|
+
# the authors give you unlimited permission to link the compiled
|
|
9
|
+
# version of this file into combinations with other programs,
|
|
10
|
+
# and to distribute those combinations without any restriction
|
|
11
|
+
# coming from the use of this file. (The General Public License
|
|
12
|
+
# restrictions do apply in other respects; for example, they cover
|
|
13
|
+
# modification of the file, and distribution when not linked into
|
|
14
|
+
# a combined executable.)
|
|
15
|
+
#
|
|
16
|
+
# This file is distributed in the hope that it will be useful, but
|
|
17
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
19
|
+
# General Public License for more details.
|
|
20
|
+
#
|
|
21
|
+
# You should have received a copy of the GNU General Public License
|
|
22
|
+
# along with this program; see the file COPYING. If not, write to
|
|
23
|
+
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
24
|
+
# Boston, MA 02110-1301, USA.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
This is an special module, it provides stuff used by setup.py at build time.
|
|
28
|
+
But also used by pygit2 at run time.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
import os
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
|
|
34
|
+
#
|
|
35
|
+
# The version number of pygit2
|
|
36
|
+
#
|
|
37
|
+
__version__ = '1.16.0'
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
#
|
|
41
|
+
# Utility functions to get the paths required for bulding extensions
|
|
42
|
+
#
|
|
43
|
+
def _get_libgit2_path():
|
|
44
|
+
# LIBGIT2 environment variable takes precedence
|
|
45
|
+
libgit2_path = os.getenv('LIBGIT2')
|
|
46
|
+
if libgit2_path is not None:
|
|
47
|
+
return Path(libgit2_path)
|
|
48
|
+
|
|
49
|
+
# Default
|
|
50
|
+
if os.name == 'nt':
|
|
51
|
+
return Path(r'%s\libgit2' % os.getenv('ProgramFiles'))
|
|
52
|
+
return Path('/usr/local')
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def get_libgit2_paths():
|
|
56
|
+
# Base path
|
|
57
|
+
path = _get_libgit2_path()
|
|
58
|
+
|
|
59
|
+
# Library dirs
|
|
60
|
+
libgit2_lib = os.getenv('LIBGIT2_LIB')
|
|
61
|
+
if libgit2_lib is None:
|
|
62
|
+
library_dirs = [path / 'lib', path / 'lib64']
|
|
63
|
+
else:
|
|
64
|
+
library_dirs = [libgit2_lib]
|
|
65
|
+
|
|
66
|
+
include_dirs = [path / 'include']
|
|
67
|
+
return (
|
|
68
|
+
path / 'bin',
|
|
69
|
+
{
|
|
70
|
+
'libraries': ['git2'],
|
|
71
|
+
'include_dirs': [str(x) for x in include_dirs],
|
|
72
|
+
'library_dirs': [str(x) for x in library_dirs],
|
|
73
|
+
},
|
|
74
|
+
)
|
pygit2/_libgit2.pyd
ADDED
|
Binary file
|
|
Binary file
|