git2py 0.0.4__tar.gz → 0.0.6__tar.gz

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.
@@ -0,0 +1 @@
1
+ *.ipynb linguist-documentation
@@ -0,0 +1,16 @@
1
+ # wads CI — calls the reusable workflow hosted in i2mint/wads.
2
+ #
3
+ # All configuration comes from this repo's pyproject.toml [tool.wads.ci.*].
4
+ # To customize the workflow itself (rare), replace this file with the
5
+ # full inline template `wads/data/github_ci_uv.yml` from i2mint/wads.
6
+ #
7
+ # Pinning: `@master` floats with wads. If you need version stability for
8
+ # a release-sensitive repo, change `@master` to a wads tag (e.g. `@v0.1.81`).
9
+ # CI failure does not block a published release — it blocks the publish
10
+ # step itself — so floating master is generally safe.
11
+ name: Continuous Integration
12
+ on: [push, pull_request]
13
+ jobs:
14
+ ci:
15
+ uses: i2mint/wads/.github/workflows/uv-ci.yml@master
16
+ secrets: inherit
@@ -0,0 +1,115 @@
1
+ docs/*
2
+ wads_configs.json
3
+ data/wads_configs.json
4
+ wads/data/wads_configs.json
5
+
6
+ # Byte-compiled / optimized / DLL files
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+
11
+
12
+ .DS_Store
13
+ # C extensions
14
+ *.so
15
+
16
+ # Distribution / packaging
17
+ .Python
18
+ build/
19
+ develop-eggs/
20
+ dist/
21
+ downloads/
22
+ eggs/
23
+ .eggs/
24
+ lib/
25
+ lib64/
26
+ parts/
27
+ sdist/
28
+ var/
29
+ wheels/
30
+ *.egg-info/
31
+ .installed.cfg
32
+ *.egg
33
+ MANIFEST
34
+ _build
35
+
36
+ # PyInstaller
37
+ # Usually these files are written by a python script from a template
38
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
39
+ *.manifest
40
+ *.spec
41
+
42
+ # Installer logs
43
+ pip-log.txt
44
+ pip-delete-this-directory.txt
45
+
46
+ # Unit test / coverage reports
47
+ htmlcov/
48
+ .tox/
49
+ .coverage
50
+ .coverage.*
51
+ .cache
52
+ nosetests.xml
53
+ coverage.xml
54
+ *.cover
55
+ .hypothesis/
56
+ .pytest_cache/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # pyenv
84
+ .python-version
85
+
86
+ # celery beat schedule file
87
+ celerybeat-schedule
88
+
89
+ # SageMath parsed files
90
+ *.sage.py
91
+
92
+ # Environments
93
+ .env
94
+ .venv
95
+ env/
96
+ venv/
97
+ ENV/
98
+ env.bak/
99
+ venv.bak/
100
+
101
+ # Spyder project settings
102
+ .spyderproject
103
+ .spyproject
104
+
105
+ # Rope project settings
106
+ .ropeproject
107
+
108
+ # mkdocs documentation
109
+ /site
110
+
111
+ # mypy
112
+ .mypy_cache/
113
+
114
+ # PyCharm
115
+ .idea
git2py-0.0.6/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
git2py-0.0.6/PKG-INFO ADDED
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: git2py
3
+ Version: 0.0.6
4
+ Summary: Mapping git operation to a dict-like Data Object Layer
5
+ Project-URL: Homepage, https://github.com/i2mint/git2py
6
+ License: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: dol
10
+ Requires-Dist: hubcap
11
+ Requires-Dist: i2
12
+ Requires-Dist: py2store
13
+ Requires-Dist: pygithub
14
+ Requires-Dist: python-gitlab
15
+ Requires-Dist: requests
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
18
+ Requires-Dist: pytest>=7.0; extra == 'dev'
19
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
20
+ Provides-Extra: docs
21
+ Requires-Dist: sphinx-rtd-theme>=1.0; extra == 'docs'
22
+ Requires-Dist: sphinx>=6.0; extra == 'docs'
23
+ Description-Content-Type: text/markdown
24
+
25
+
26
+ # git2py
27
+
28
+ Some git (gitlab and github) tools.
29
+
30
+ To install: ```pip install git2py```
31
+
32
+ Note: The intent of this package was to provide a simple, high-level interface to git.
33
+ Namely to github and gitlab, allowing for easy access to the resources of these
34
+ platforms, and that would be easy to extend to other platforms.
35
+
36
+ What ended up happening is that we accumulated some useful tools, but stopped
37
+ development after our main purpose was acheived (migrating from gitlab to github).
38
+
39
+ We may pick this project up again in the future, but for now, it's in a state of
40
+ "good enough for now", and we're keeping it around to use the tools we've built.
41
+
42
+ You may want to check out some other projects that may have more active development:
43
+ - [hubcap](https://github.com/thorwhalen/hubcap): A mapping interface to github
44
+ - [ps](https://github.com/thorwhalen/ps): Call any available system command from python
45
+ - some bits of
46
+ [wads](https://github.com/i2mint/wads/blob/b82a534bfc9c3f20713e0768291c67c9c2467e01/wads/util.py#L39) and
47
+ [isee](https://github.com/i2mint/isee/blob/54fa4b2343cb2510f7a9cc34fe4e512ef6050795/isee/common.py#L17)
git2py-0.0.6/README.md ADDED
@@ -0,0 +1,23 @@
1
+
2
+ # git2py
3
+
4
+ Some git (gitlab and github) tools.
5
+
6
+ To install: ```pip install git2py```
7
+
8
+ Note: The intent of this package was to provide a simple, high-level interface to git.
9
+ Namely to github and gitlab, allowing for easy access to the resources of these
10
+ platforms, and that would be easy to extend to other platforms.
11
+
12
+ What ended up happening is that we accumulated some useful tools, but stopped
13
+ development after our main purpose was acheived (migrating from gitlab to github).
14
+
15
+ We may pick this project up again in the future, but for now, it's in a state of
16
+ "good enough for now", and we're keeping it around to use the tools we've built.
17
+
18
+ You may want to check out some other projects that may have more active development:
19
+ - [hubcap](https://github.com/thorwhalen/hubcap): A mapping interface to github
20
+ - [ps](https://github.com/thorwhalen/ps): Call any available system command from python
21
+ - some bits of
22
+ [wads](https://github.com/i2mint/wads/blob/b82a534bfc9c3f20713e0768291c67c9c2467e01/wads/util.py#L39) and
23
+ [isee](https://github.com/i2mint/isee/blob/54fa4b2343cb2510f7a9cc34fe4e512ef6050795/isee/common.py#L17)
@@ -0,0 +1 @@
1
+ _build/
@@ -0,0 +1,33 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+ GITHUBPAGESDIR = ../docs
11
+ GITLABPAGESDIR = ../public
12
+
13
+ # Put it first so that "make" without argument is like "make help".
14
+ help:
15
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
16
+
17
+ .PHONY: help Makefile
18
+
19
+ github:
20
+ @make html
21
+ @cp -a "$(BUILDDIR)"/html/. $(GITHUBPAGESDIR)
22
+
23
+ gitlab:
24
+ @make html
25
+ @cp -a "$(BUILDDIR)"/html/. $(GITLABPAGESDIR)
26
+
27
+ clean:
28
+ rm -rfv $(BUILDDIR) $(GITHUBPAGESDIR) $(GITLABPAGESDIR)
29
+
30
+ # Catch-all target: route all unknown targets to Sphinx using the new
31
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
32
+ %: Makefile
33
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,60 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # This file only contains a selection of the most common options.
4
+ # For a full list see the documentation:
5
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
6
+
7
+ # -- Path setup --------------------------------------------------------------
8
+
9
+ # If extensions (or modules to document with autodoc) are in another directory,
10
+ # add these directories to sys.path here. If the directory is relative to the
11
+ # documentation root, use os.path.abspath to make it absolute, like shown here.
12
+
13
+ import os
14
+ import sys
15
+
16
+ sys.path.insert(0, os.path.abspath(".."))
17
+
18
+ # -- Project information -----------------------------------------------------
19
+ from epythet.config_parser import parse_config
20
+ from pathlib import Path
21
+
22
+ project, copyright, author, release, display_name = parse_config(
23
+ Path(__file__).absolute().parent.parent / "setup.cfg"
24
+ )
25
+
26
+ # -- General configuration ---------------------------------------------------
27
+
28
+ # Add any Sphinx extension module names here, as strings. They can be
29
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
30
+ # ones.
31
+ extensions = [
32
+ "sphinx.ext.autodoc", # Include documentation from docstrings
33
+ "sphinx.ext.doctest", # Test snippets in the documentation
34
+ "sphinx.ext.githubpages", # This extension creates .nojekyll file
35
+ "sphinx.ext.graphviz", # Add Graphviz graphs
36
+ "sphinx.ext.napoleon", # Support for NumPy and Google style docstrings
37
+ "sphinx.ext.todo", # Support for todo items
38
+ "sphinx.ext.viewcode", # Add links to highlighted source code
39
+ "recommonmark", # Parse .md files
40
+ ]
41
+
42
+ # Add any paths that contain templates here, relative to this directory.
43
+ templates_path = ["_templates"]
44
+
45
+ # List of patterns, relative to source directory, that match files and
46
+ # directories to ignore when looking for source files.
47
+ # This pattern also affects html_static_path and html_extra_path.
48
+ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
49
+
50
+ # -- Options for HTML output -------------------------------------------------
51
+
52
+ # The theme to use for HTML and HTML Help pages. See the documentation for
53
+ # a list of builtin themes.
54
+ #
55
+ html_theme = "alabaster"
56
+
57
+ # Add any paths that contain custom static files (such as style sheets) here,
58
+ # relative to this directory. They are copied after the builtin static files,
59
+ # so a file named "default.css" will overwrite the builtin "default.css".
60
+ html_static_path = ["_static"]
@@ -0,0 +1,13 @@
1
+ Welcome to git2py's documentation!
2
+ ==================================
3
+
4
+
5
+ .. include:: ./table_of_contents.rst
6
+
7
+
8
+ Indices and tables
9
+ ==================
10
+
11
+ * :ref:`genindex`
12
+ * :ref:`modindex`
13
+ * :ref:`search`
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=.
11
+ set BUILDDIR=_build
12
+
13
+ if "%1" == "" goto help
14
+
15
+ %SPHINXBUILD% >NUL 2>NUL
16
+ if errorlevel 9009 (
17
+ echo.
18
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19
+ echo.installed, then set the SPHINXBUILD environment variable to point
20
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
21
+ echo.may add the Sphinx directory to PATH.
22
+ echo.
23
+ echo.If you don't have Sphinx installed, grab it from
24
+ echo.http://sphinx-doc.org/
25
+ exit /b 1
26
+ )
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
@@ -0,0 +1,24 @@
1
+ """
2
+ Git tools.
3
+
4
+ Note: The intent of this package was to provide a simple, high-level interface to git.
5
+ Namely to github and gitlab, allowing for easy access to the resources of these
6
+ platforms, and that would be easy to extend to other platforms.
7
+
8
+ What ended up happening is that we accumulated some useful tools, but stopped
9
+ development after our main purpose was acheived (migrating from gitlab to github).
10
+
11
+ We may pick this project up again in the future, but for now, it's in a state of
12
+ "good enough for now", and we're keeping it around to use the tools we've built.
13
+
14
+ You may want to check out some other projects that may have more active development:
15
+ - [hubcap](https://github.com/thorwhalen/hubcap): A mapping interface to github
16
+ - [ps](https://github.com/thorwhalen/ps): Call any available system command from python
17
+ - some bits of
18
+ [wads](https://github.com/i2mint/wads/blob/b82a534bfc9c3f20713e0768291c67c9c2467e01/wads/util.py#L39) and
19
+ [isee](https://github.com/i2mint/isee/blob/54fa4b2343cb2510f7a9cc34fe4e512ef6050795/isee/common.py#L17)
20
+
21
+ """
22
+
23
+ from git2py import gitlab_utils
24
+ import hubcap as github
@@ -16,6 +16,7 @@ print(
16
16
  ```
17
17
 
18
18
  """
19
+
19
20
  import requests
20
21
  import os
21
22
  from warnings import warn
@@ -29,8 +30,8 @@ from dol import KvReader
29
30
  from py2store.utils.uri_utils import mk_str_making_func
30
31
 
31
32
  url_templates = dict(
32
- project_names="projects/",
33
- branche_names="projects/{project_id}/repository/branches",
33
+ projects="projects/",
34
+ branches="projects/{project_id}/repository/branches",
34
35
  branch="projects/{project_id}/repository/branches/{branch_name}",
35
36
  commit_by_sha="projects/{project_id}/repository/commits/{commit_sha}",
36
37
  commit_message_by_sha="projects/{project_id}/repository/commits/{commit_sha}",
@@ -51,9 +52,7 @@ def mk_url_factory(base_url):
51
52
  pass
52
53
 
53
54
  for name, format in url_templates.items():
54
- func = mk_str_making_func(
55
- base_url + format, module=__name__, name=name
56
- )
55
+ func = mk_str_making_func(base_url + format, module=__name__, name=name)
57
56
  setattr(url_for, name, staticmethod(func))
58
57
 
59
58
  return url_for()
@@ -84,14 +83,14 @@ class GitlabProjectReader(KvReader):
84
83
 
85
84
 
86
85
  # https://docs.gitlab.com/ce/api/README.html
87
- class GitLabAccessor(object):
86
+ class GitLabAccessor:
88
87
  api_url_format = "{base_url}/api/v4/"
89
88
 
90
89
  def __init__(
91
- self,
92
- base_url="http://git.otosense.ai/",
93
- project_name=None,
94
- private_token=dflt_private_token,
90
+ self,
91
+ base_url="http://git.otosense.ai/",
92
+ project_name=None,
93
+ private_token=dflt_private_token,
95
94
  ):
96
95
 
97
96
  self.git_api_url = self.api_url_format.format(base_url=base_url)
@@ -106,7 +105,7 @@ class GitLabAccessor(object):
106
105
  self.request = get_request_constructor()
107
106
 
108
107
  def _get_stuff_from_url(
109
- self, url, output_trans=None, response_attr="json", params=None
108
+ self, url, output_trans=None, response_attr="json", params=None
110
109
  ):
111
110
  response = requests.get(url, headers=self._headers, params=params)
112
111
  if response_attr == "json":
@@ -143,7 +142,7 @@ class GitLabAccessor(object):
143
142
  self._set_project_id()
144
143
 
145
144
  def _set_project_id(self):
146
- url = "{}/projects/".format(self.git_api_url)
145
+ url = f"{self.git_api_url}/projects/"
147
146
  params = {"search": self.project_name}
148
147
  response = requests.get(url, params=params, headers=self._headers)
149
148
 
@@ -153,14 +152,12 @@ class GitLabAccessor(object):
153
152
  projects = response.json()
154
153
 
155
154
  if len(projects) == 0:
156
- raise Exception(
157
- "No Projects with name {} found.".format(self.project_name)
158
- )
155
+ raise Exception(f"No Projects with name {self.project_name} found.")
159
156
 
160
157
  self.project_id = projects[0]["id"]
161
158
 
162
159
  def get_project_names(self):
163
- url = "{}projects/".format(self.git_api_url)
160
+ url = f"{self.git_api_url}projects/"
164
161
  return self._get_json_from_url(
165
162
  url, output_trans=lambda jdict: [x["name"] for x in jdict]
166
163
  )
@@ -261,9 +258,7 @@ class GitLabAccessor(object):
261
258
 
262
259
  def get_project_files(self):
263
260
 
264
- url = "{}projects/{}/repository/tree".format(
265
- self.git_api_url, self.project_id
266
- )
261
+ url = "{}projects/{}/repository/tree".format(self.git_api_url, self.project_id)
267
262
  return self._get_json_from_url(url)
268
263
  # response = requests.get(url, headers=self._headers)
269
264
  #
@@ -273,9 +268,7 @@ class GitLabAccessor(object):
273
268
 
274
269
  def get_tags_list(self):
275
270
 
276
- url = "{}projects/{}/repository/tags".format(
277
- self.git_api_url, self.project_id
278
- )
271
+ url = "{}projects/{}/repository/tags".format(self.git_api_url, self.project_id)
279
272
  return self._get_json_from_url(url)
280
273
  # response = requests.get(url, headers=self._headers)
281
274
  #
@@ -286,4 +279,3 @@ class GitLabAccessor(object):
286
279
 
287
280
  def get_request_constructor():
288
281
  pass
289
-
@@ -0,0 +1,175 @@
1
+ """Migrate git repositories between GitHub and GitLab."""
2
+
3
+ from contextlib import contextmanager
4
+ import os
5
+ import re
6
+ import subprocess
7
+ import tempfile
8
+ import shutil
9
+ from gitlab import Gitlab
10
+ from github import Github, GithubException
11
+
12
+ GITHUB_BASE_URL = "https://github.com"
13
+ GITHUB_API_BASE_URL = "https://api.github.com"
14
+ DFLT_LOCAL_REPO_DIR = "repo"
15
+
16
+
17
+ def run_cmd_line(exe, *args):
18
+ return subprocess.check_output([exe] + list(args)).decode().strip()
19
+
20
+
21
+ def git(*args):
22
+ return run_cmd_line("git", *args)
23
+
24
+
25
+ def npm(*args):
26
+ return run_cmd_line("npm", *args)
27
+
28
+
29
+ @contextmanager
30
+ def cd(path):
31
+ old_path = os.getcwd()
32
+ os.chdir(path)
33
+ try:
34
+ yield
35
+ finally:
36
+ os.chdir(old_path)
37
+
38
+
39
+ def work_under_tmp_dir(func):
40
+ def wrapper(*args, **kwargs):
41
+ tmp_dir = tempfile.mkdtemp()
42
+ with cd(tmp_dir):
43
+ func(*args, **kwargs)
44
+ shutil.rmtree(tmp_dir)
45
+
46
+ return wrapper
47
+
48
+
49
+ @work_under_tmp_dir
50
+ def mirror_repo(gitlab_project, github_repo):
51
+ gitlab_url = gitlab_project.http_url_to_repo
52
+ github_url = github_repo.clone_url
53
+ print(f"Mirroring repo from {gitlab_url} to {github_url} ...")
54
+ git("clone", "--mirror", gitlab_url, ".")
55
+ git("push", "--no-verify", "--mirror", github_url)
56
+ print(f"Repo {github_url} has been mirrored successfully!")
57
+
58
+
59
+ def migrate_project(gitlab_project, github_repo_name, migrate_wikis):
60
+ print(
61
+ f'Migrating project data from "{gitlab_project.path_with_namespace}" to "{github_repo_name}" ...'
62
+ )
63
+ if migrate_wikis:
64
+ create_issues_from_wikis(gitlab_project)
65
+ update_file("settings.ts", r"projectId: \d*", f"projectId: {gitlab_project.id}")
66
+ update_file("settings.ts", r"repo: '.*'", f"repo: '{github_repo_name}'")
67
+ npm("run", "start")
68
+ print(f"Project data have been migrated to {github_repo_name} successfully!")
69
+
70
+
71
+ def create_issues_from_wikis(gitlab_project):
72
+ wikis = gitlab_project.wikis.list(get_all=True)
73
+ issues = gitlab_project.issues.list(get_all=True)
74
+ for wiki in reversed(wikis):
75
+ issue_title = f"(migrated wiki) {wiki.slug}"
76
+ if next((i for i in issues if i.title == issue_title), None) is None:
77
+ wiki_content = gitlab_project.wikis.get(wiki.slug).content
78
+ gitlab_project.issues.create(
79
+ dict(
80
+ title=issue_title,
81
+ description=wiki_content,
82
+ )
83
+ )
84
+
85
+
86
+ def update_file(path, pattern, replace):
87
+ with open(path, "r+") as file:
88
+ content = file.read()
89
+ content_new = re.sub(pattern, replace, content, flags=re.M)
90
+ # if content_new == content:
91
+ # raise RuntimeError(f'Failed to update file "{path}"!')
92
+ file.seek(0)
93
+ file.write(content_new)
94
+ file.truncate()
95
+
96
+
97
+ class Migration:
98
+ def __init__(
99
+ self,
100
+ gitlab_base_url,
101
+ gitlab_token,
102
+ github_token,
103
+ github_org_name,
104
+ node_gitlab_2_github_path,
105
+ name_map=None,
106
+ projects_to_ignore=None,
107
+ ):
108
+ self._gitlab = Gitlab(url=gitlab_base_url, private_token=gitlab_token)
109
+ github = Github(github_token)
110
+ self._github_org = github.get_organization(github_org_name)
111
+ self._node_gitlab_2_github_path = node_gitlab_2_github_path
112
+ self._name_map = name_map or {}
113
+ self._projects_to_ignore = projects_to_ignore or []
114
+
115
+ def migrate(
116
+ self,
117
+ *,
118
+ migrate_repositories=True,
119
+ migrate_project_data=True,
120
+ migrate_wikis=False,
121
+ ):
122
+ gitlab_projects = self._gitlab.projects.list(
123
+ get_all=True,
124
+ # page=10,
125
+ order_by="name",
126
+ sort="asc",
127
+ )
128
+ print(f"Starting migration of {len(gitlab_projects)} Gitlab projects to Github")
129
+ with cd(self._node_gitlab_2_github_path):
130
+ for gitlab_project in gitlab_projects:
131
+ try:
132
+ self._migrate_project(
133
+ gitlab_project,
134
+ migrate_repositories,
135
+ migrate_project_data,
136
+ migrate_wikis,
137
+ )
138
+ except Exception as e:
139
+ print(
140
+ f"Failed migrating {gitlab_project.path_with_namespace}. Error message: {e}"
141
+ )
142
+
143
+ def _migrate_project(
144
+ self, gitlab_project, migrate_repositories, migrate_project_data, migrate_wikis
145
+ ):
146
+ path_with_namespace = gitlab_project.path_with_namespace
147
+ if path_with_namespace in self._projects_to_ignore:
148
+ print(f"Skipping {path_with_namespace}")
149
+ else:
150
+ github_repo_name = (
151
+ self._name_map.get(gitlab_project.path_with_namespace)
152
+ or gitlab_project.path
153
+ )
154
+ if migrate_repositories:
155
+ self._migrate_repo(gitlab_project, github_repo_name)
156
+ if migrate_project_data:
157
+ migrate_project(gitlab_project, github_repo_name, migrate_wikis)
158
+
159
+ def _migrate_repo(self, gitlab_project, github_repo_name):
160
+ try:
161
+ github_repo = self._github_org.get_repo(github_repo_name)
162
+ except GithubException as e:
163
+ print(f"Creating repo {github_repo_name} on Github ...")
164
+ github_repo = self._github_org.create_repo(
165
+ name=github_repo_name,
166
+ description=gitlab_project.description,
167
+ private=True,
168
+ )
169
+ try:
170
+ github_repo.get_contents("/")
171
+ except GithubException as e:
172
+ if not gitlab_project.empty_repo:
173
+ mirror_repo(gitlab_project, github_repo)
174
+
175
+ __call__ = migrate
@@ -0,0 +1,162 @@
1
+ [build-system]
2
+ requires = [
3
+ "hatchling",
4
+ ]
5
+ build-backend = "hatchling.build"
6
+
7
+ [project]
8
+ name = "git2py"
9
+ version = "0.0.6"
10
+ description = "Mapping git operation to a dict-like Data Object Layer"
11
+ readme = "README.md"
12
+ requires-python = ">=3.10"
13
+ keywords = []
14
+ authors = []
15
+ dependencies = [
16
+ "dol",
17
+ "i2",
18
+ "py2store",
19
+ "PyGithub",
20
+ "python-gitlab",
21
+ "requests",
22
+ "hubcap",
23
+ ]
24
+
25
+ [project.license]
26
+ text = "Apache-2.0"
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/i2mint/git2py"
30
+
31
+ [project.optional-dependencies]
32
+ dev = [
33
+ "pytest>=7.0",
34
+ "pytest-cov>=4.0",
35
+ "ruff>=0.1.0",
36
+ ]
37
+ docs = [
38
+ "sphinx>=6.0",
39
+ "sphinx-rtd-theme>=1.0",
40
+ ]
41
+
42
+ [tool.ruff]
43
+ line-length = 88
44
+ target-version = "py310"
45
+ exclude = [
46
+ "**/*.ipynb",
47
+ ".git",
48
+ ".venv",
49
+ "build",
50
+ "dist",
51
+ "tests",
52
+ "examples",
53
+ "scrap",
54
+ ]
55
+
56
+ [tool.ruff.lint]
57
+ select = [
58
+ "D100",
59
+ ]
60
+ ignore = [
61
+ "D203",
62
+ "E501",
63
+ "B905",
64
+ ]
65
+
66
+ [tool.ruff.lint.pydocstyle]
67
+ convention = "google"
68
+
69
+ [tool.ruff.lint.per-file-ignores]
70
+ "**/tests/*" = [
71
+ "D",
72
+ ]
73
+ "**/examples/*" = [
74
+ "D",
75
+ ]
76
+ "**/scrap/*" = [
77
+ "D",
78
+ ]
79
+
80
+ [tool.pytest.ini_options]
81
+ minversion = "6.0"
82
+ testpaths = [
83
+ "tests",
84
+ ]
85
+ doctest_optionflags = [
86
+ "NORMALIZE_WHITESPACE",
87
+ "ELLIPSIS",
88
+ ]
89
+
90
+ [tool.wads.ci]
91
+ project_name = ""
92
+
93
+ [tool.wads.ci.commands]
94
+ pre_test = []
95
+ test = []
96
+ post_test = []
97
+ lint = []
98
+ format = []
99
+
100
+ [tool.wads.ci.env]
101
+ required_envvars = []
102
+ test_envvars = ["GITHUB_TOKEN"]
103
+ extra_envvars = []
104
+
105
+ [tool.wads.ci.env.defaults]
106
+
107
+ [tool.wads.ci.quality.ruff]
108
+ enabled = true
109
+
110
+ [tool.wads.ci.quality.black]
111
+ enabled = false
112
+
113
+ [tool.wads.ci.quality.mypy]
114
+ enabled = false
115
+
116
+ [tool.wads.ci.testing]
117
+ enabled = true
118
+ python_versions = [
119
+ "3.10",
120
+ "3.12",
121
+ ]
122
+ pytest_args = [
123
+ "-v",
124
+ "--tb=short",
125
+ ]
126
+ coverage_enabled = true
127
+ coverage_threshold = 0
128
+ coverage_report_format = [
129
+ "term",
130
+ "xml",
131
+ ]
132
+ exclude_paths = [
133
+ "examples",
134
+ "scrap",
135
+ "docsrc",
136
+ ]
137
+ test_on_windows = true
138
+
139
+ [tool.wads.ci.metrics]
140
+ enabled = true
141
+ config_path = ".github/umpyre-config.yml"
142
+ storage_branch = "code-metrics"
143
+ python_version = "3.10"
144
+ force_run = false
145
+
146
+ [tool.wads.ci.build]
147
+ sdist = true
148
+ wheel = true
149
+
150
+ [tool.wads.ci.publish]
151
+ enabled = true
152
+ skip_ci_marker = "[skip ci]"
153
+ publish_marker = "[publish]"
154
+
155
+ [tool.wads.ci.docs]
156
+ enabled = true
157
+ builder = "epythet"
158
+ ignore_paths = [
159
+ "tests/",
160
+ "scrap/",
161
+ "examples/",
162
+ ]
@@ -0,0 +1,5 @@
1
+ """Smoke test: importing the package shouldn't blow up."""
2
+
3
+
4
+ def test_import():
5
+ import git2py # noqa: F401
git2py-0.0.4/PKG-INFO DELETED
@@ -1,16 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: git2py
3
- Version: 0.0.4
4
- Summary: Mapping git operation to a dict-like Data Object Layer
5
- Home-page: https://github.com/i2mint/git2py
6
- Author: OtoSense
7
- License: apache-2.0
8
- Description:
9
- # git2py
10
- Mapping git operation to a dict-like Data Object Layer
11
-
12
-
13
- To install: ```pip install git2py```
14
-
15
- Platform: any
16
- Description-Content-Type: text/markdown
git2py-0.0.4/README.md DELETED
@@ -1,6 +0,0 @@
1
-
2
- # git2py
3
- Mapping git operation to a dict-like Data Object Layer
4
-
5
-
6
- To install: ```pip install git2py```
@@ -1,2 +0,0 @@
1
- from git2py import gitlab
2
- import hubcap as github
@@ -1,16 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: git2py
3
- Version: 0.0.4
4
- Summary: Mapping git operation to a dict-like Data Object Layer
5
- Home-page: https://github.com/i2mint/git2py
6
- Author: OtoSense
7
- License: apache-2.0
8
- Description:
9
- # git2py
10
- Mapping git operation to a dict-like Data Object Layer
11
-
12
-
13
- To install: ```pip install git2py```
14
-
15
- Platform: any
16
- Description-Content-Type: text/markdown
@@ -1,11 +0,0 @@
1
- README.md
2
- setup.cfg
3
- setup.py
4
- git2py/__init__.py
5
- git2py/gitlab.py
6
- git2py.egg-info/PKG-INFO
7
- git2py.egg-info/SOURCES.txt
8
- git2py.egg-info/dependency_links.txt
9
- git2py.egg-info/not-zip-safe
10
- git2py.egg-info/requires.txt
11
- git2py.egg-info/top_level.txt
@@ -1 +0,0 @@
1
-
@@ -1,3 +0,0 @@
1
- dol
2
- py2store
3
- hubcap
@@ -1 +0,0 @@
1
- git2py
git2py-0.0.4/setup.cfg DELETED
@@ -1,28 +0,0 @@
1
- [metadata]
2
- name = git2py
3
- version = 0.0.4
4
- url = https://github.com/i2mint/git2py
5
- platforms = any
6
- description_file = README.md
7
- root_url = https://github.com/i2mint/
8
- license = apache-2.0
9
- author = OtoSense
10
- description = Mapping git operation to a dict-like Data Object Layer
11
- long_description = file:README.md
12
- long_description_content_type = text/markdown
13
- keywords =
14
- display_name = git2py
15
-
16
- [options]
17
- packages = find:
18
- include_package_data = True
19
- zip_safe = False
20
- install_requires =
21
- dol
22
- py2store
23
- hubcap
24
-
25
- [egg_info]
26
- tag_build =
27
- tag_date = 0
28
-
git2py-0.0.4/setup.py DELETED
@@ -1,3 +0,0 @@
1
- from setuptools import setup
2
-
3
- setup() # Note: Everything should be in the local setup.cfg