gitlabber 1.2.4__tar.gz → 1.2.5__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.
- {gitlabber-1.2.4/gitlabber.egg-info → gitlabber-1.2.5}/PKG-INFO +1 -1
- gitlabber-1.2.5/gitlabber/__init__.py +1 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber/cli.py +7 -2
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber/gitlab_tree.py +17 -3
- {gitlabber-1.2.4 → gitlabber-1.2.5/gitlabber.egg-info}/PKG-INFO +1 -1
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_cli.cpython-311-pytest-8.2.2.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_e2e.cpython-311-pytest-8.2.2.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test_cli.py +4 -4
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test_e2e.py +10 -1
- gitlabber-1.2.4/gitlabber/__init__.py +0 -1
- {gitlabber-1.2.4 → gitlabber-1.2.5}/LICENSE.txt +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/MANIFEST.in +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/README.rst +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber/__main__.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber/archive.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber/format.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber/git.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber/method.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber/naming.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber/progress.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber.egg-info/SOURCES.txt +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber.egg-info/dependency_links.txt +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber.egg-info/entry_points.txt +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber.egg-info/requires.txt +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/gitlabber.egg-info/top_level.txt +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/setup.cfg +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/setup.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__init__.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/__init__.cpython-311.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/gitlab_test_utils.cpython-311.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/io_test_util.cpython-311.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_archive.cpython-311-pytest-8.2.2.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_format.cpython-311-pytest-8.2.2.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_git.cpython-311-pytest-8.2.2.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_gitlab_tree.cpython-311-pytest-8.2.2.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_integration.cpython-311-pytest-8.2.2.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_method.cpython-311-pytest-8.2.2.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_naming.cpython-311-pytest-8.2.2.pyc +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/gitlab_test_utils.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/io_test_util.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test-input.yaml +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test-output.json +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test-output.tree +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test-output.yaml +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test_archive.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test_format.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test_git.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test_gitlab_tree.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test_integration.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test_method.py +0 -0
- {gitlabber-1.2.4 → gitlabber-1.2.5}/tests/test_naming.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '1.2.5'
|
|
@@ -43,8 +43,7 @@ def main():
|
|
|
43
43
|
|
|
44
44
|
tree = GitlabTree(args.url, args.token, args.method, args.naming, args.archived.api_value, includes,
|
|
45
45
|
excludes, args.file, args.concurrency, args.recursive, args.verbose,
|
|
46
|
-
args.use_fetch, args.hide_token, group_search=args.group_search)
|
|
47
|
-
log.debug("Reading projects tree from gitlab at [%s]", args.url)
|
|
46
|
+
args.include_shared, args.use_fetch, args.hide_token, args.user_projects, group_search=args.group_search)
|
|
48
47
|
tree.load_tree()
|
|
49
48
|
|
|
50
49
|
if tree.is_empty():
|
|
@@ -211,6 +210,12 @@ def parse_args(argv=None):
|
|
|
211
210
|
'--group-search',
|
|
212
211
|
metavar=('term'),
|
|
213
212
|
help='only include groups matching the search term, filtering done at the API level (useful for large projects, see: https://docs.gitlab.com/ee/api/groups.html#search-for-group works with partial names of path or name)')
|
|
213
|
+
parser.add_argument(
|
|
214
|
+
'-U',
|
|
215
|
+
'--user-projects',
|
|
216
|
+
action='store_true',
|
|
217
|
+
default=False,
|
|
218
|
+
help='fetch only user personal projects (skips the group tree altogether, group related parameters are ignored). Clones personal projects to \'{gitlab-username}-personal-projects\'')
|
|
214
219
|
parser.add_argument(
|
|
215
220
|
'--version',
|
|
216
221
|
action='store_true',
|
|
@@ -17,9 +17,8 @@ log = logging.getLogger(__name__)
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class GitlabTree:
|
|
20
|
-
|
|
21
20
|
def __init__(self, url, token, method, naming=None, archived=None, includes=[], excludes=[], in_file=None, concurrency=1, recursive=False, disable_progress=False,
|
|
22
|
-
include_shared=True, use_fetch=False, hide_token=False, group_search=None):
|
|
21
|
+
include_shared=True, use_fetch=False, hide_token=False, user_projects=False, group_search=None):
|
|
23
22
|
self.includes = includes
|
|
24
23
|
self.excludes = excludes
|
|
25
24
|
self.url = url
|
|
@@ -38,6 +37,7 @@ class GitlabTree:
|
|
|
38
37
|
self.include_shared = include_shared
|
|
39
38
|
self.use_fetch = use_fetch
|
|
40
39
|
self.hide_token = hide_token
|
|
40
|
+
self.user_projects = user_projects
|
|
41
41
|
self.group_search = group_search
|
|
42
42
|
|
|
43
43
|
@staticmethod
|
|
@@ -160,12 +160,26 @@ class GitlabTree:
|
|
|
160
160
|
dct = yaml.safe_load(stream)
|
|
161
161
|
self.root = DictImporter().import_(dct)
|
|
162
162
|
|
|
163
|
+
def load_user_tree(self):
|
|
164
|
+
log.debug(f"Starting user project search with archived: {self.archived}")
|
|
165
|
+
self.gitlab.auth()
|
|
166
|
+
user = self.gitlab.users.get(self.gitlab.user.id)
|
|
167
|
+
username = user.username
|
|
168
|
+
projects = user.projects.list(as_list=False, archived=self.archived, get_all=True)
|
|
169
|
+
self.progress.init_progress(len(projects))
|
|
170
|
+
root = self.make_node("group", f"{username}-prsonal-projects", self.root, url=f"{self.url}/users/{username}/projects")
|
|
171
|
+
self.add_projects(root, projects)
|
|
172
|
+
|
|
173
|
+
|
|
163
174
|
def load_tree(self):
|
|
164
175
|
if self.in_file:
|
|
165
176
|
log.debug("Loading tree from file [%s]", self.in_file)
|
|
166
177
|
self.load_file_tree()
|
|
178
|
+
elif self.user_projects:
|
|
179
|
+
log.debug("Loading user personal projects from gitlab server [%s]", self.url)
|
|
180
|
+
self.load_user_tree()
|
|
167
181
|
else:
|
|
168
|
-
log.debug("Loading projects tree gitlab server [%s]", self.url)
|
|
182
|
+
log.debug("Loading projects tree from gitlab server [%s]", self.url)
|
|
169
183
|
self.load_gitlab_tree()
|
|
170
184
|
|
|
171
185
|
log.debug("Fetched root node with [%d] projects" % len(
|
|
Binary file
|
|
Binary file
|
|
@@ -36,7 +36,7 @@ def test_args_version():
|
|
|
36
36
|
def test_args_logging(mock_tree, mock_log, mock_os, mock_sys, mock_logging):
|
|
37
37
|
args_mock = mock.Mock()
|
|
38
38
|
args_mock.return_value = Node(
|
|
39
|
-
type="test", name="test", version=None, verbose=True, include="", exclude="", url="test_url", token="test_token", method=CloneMethod.SSH, naming=FolderNaming.PATH, archived=ArchivedResults.INCLUDE, file=None, concurrency=1, recursive=False, disble_progress=True, print=None, dest=".", include_shared=True, use_fetch=None, hide_token=None, group_search=None)
|
|
39
|
+
type="test", name="test", version=None, verbose=True, include="", exclude="", url="test_url", token="test_token", method=CloneMethod.SSH, naming=FolderNaming.PATH, archived=ArchivedResults.INCLUDE, file=None, concurrency=1, recursive=False, disble_progress=True, print=None, dest=".", include_shared=True, use_fetch=None, hide_token=None, user_projects=None, group_search=None)
|
|
40
40
|
cli.parse_args = args_mock
|
|
41
41
|
|
|
42
42
|
mock_streamhandler = mock.Mock()
|
|
@@ -57,7 +57,7 @@ def test_args_include(mock_tree):
|
|
|
57
57
|
exc_groups = "/exc**,/exc**"
|
|
58
58
|
args_mock = mock.Mock()
|
|
59
59
|
args_mock.return_value = Node(
|
|
60
|
-
type="test", name="test", version=None, debug=None, include=inc_groups, exclude=exc_groups, url="test_url", token="test_token", method=CloneMethod.SSH, naming=FolderNaming.NAME, archived=ArchivedResults.INCLUDE, file=None, concurrency=1, recursive=False, disble_progress=True, print=None, dest=".", use_fetch=None, hide_token=None, group_search=None)
|
|
60
|
+
type="test", name="test", version=None, debug=None, include=inc_groups, exclude=exc_groups, url="test_url", token="test_token", method=CloneMethod.SSH, naming=FolderNaming.NAME, archived=ArchivedResults.INCLUDE, file=None, concurrency=1, recursive=False, disble_progress=True, print=None, dest=".", use_fetch=None, hide_token=None, user_projects=None, group_search=None)
|
|
61
61
|
cli.parse_args = args_mock
|
|
62
62
|
|
|
63
63
|
split_mock = mock.Mock()
|
|
@@ -73,7 +73,7 @@ def test_args_include(mock_tree):
|
|
|
73
73
|
def test_args_include(mock_tree):
|
|
74
74
|
args_mock = mock.Mock()
|
|
75
75
|
args_mock.return_value = Node(
|
|
76
|
-
type="test", name="test", version=None, verbose=None, include="", exclude="", url="test_url", token="test_token", method=CloneMethod.SSH, naming=FolderNaming.NAME, archived=ArchivedResults.INCLUDE, file=None, concurrency=1, recursive=False, disble_progress=True, print=True, dest=".", print_format=PrintFormat.YAML, include_shared=True, use_fetch=None, hide_token=None, group_search=None)
|
|
76
|
+
type="test", name="test", version=None, verbose=None, include="", exclude="", url="test_url", token="test_token", method=CloneMethod.SSH, naming=FolderNaming.NAME, archived=ArchivedResults.INCLUDE, file=None, concurrency=1, recursive=False, disble_progress=True, print=True, dest=".", print_format=PrintFormat.YAML, include_shared=True, use_fetch=None, hide_token=None, user_projects=None, group_search=None)
|
|
77
77
|
cli.parse_args = args_mock
|
|
78
78
|
|
|
79
79
|
print_tree_mock = mock.Mock()
|
|
@@ -116,7 +116,7 @@ def test_missing_url(mock_tree):
|
|
|
116
116
|
def test_empty_tree(mock_tree):
|
|
117
117
|
args_mock = mock.Mock()
|
|
118
118
|
args_mock.return_value = Node(
|
|
119
|
-
type="test", name="test", version=None, verbose=None, include="", exclude="", url="test_url", token="test_token", method=CloneMethod.SSH, naming=FolderNaming.NAME, archived=ArchivedResults.INCLUDE, file=None, concurrency=1, recursive=False, disble_progress=True, print=True, dest=".", include_shared=True, use_fetch=None, hide_token=None, group_search=None)
|
|
119
|
+
type="test", name="test", version=None, verbose=None, include="", exclude="", url="test_url", token="test_token", method=CloneMethod.SSH, naming=FolderNaming.NAME, archived=ArchivedResults.INCLUDE, file=None, concurrency=1, recursive=False, disble_progress=True, print=True, dest=".", include_shared=True, use_fetch=None, hide_token=None, user_projects=None, group_search=None)
|
|
120
120
|
cli.parse_args = args_mock
|
|
121
121
|
|
|
122
122
|
with pytest.raises(SystemExit):
|
|
@@ -58,11 +58,20 @@ def test_clone_subgroup_naming_path():
|
|
|
58
58
|
@pytest.mark.slow_integration_test
|
|
59
59
|
def test_large_groups():
|
|
60
60
|
os.environ['GITLAB_URL'] = 'https://gitlab.com/'
|
|
61
|
-
output = io_util.execute(['-p', '--print-format', 'json', '-n', 'path', '--group-search', 'large-group-test'
|
|
61
|
+
output = io_util.execute(['-p', '--print-format', 'json', '-n', 'path', '--group-search', 'large-group-test'], 60)
|
|
62
62
|
obj = json.loads(output)
|
|
63
63
|
assert obj['children'][0]['name'] == 'large-group-test'
|
|
64
64
|
assert obj['children'][0]['children'][0]['name'] == 'many-subgroups'
|
|
65
65
|
assert len(obj['children'][0]['children'][0]['children']) == 21
|
|
66
66
|
assert obj['children'][0]['children'][1]['name'] == 'gitlab-many-projects'
|
|
67
67
|
assert len(obj['children'][0]['children'][1]['children']) == 21
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@pytest.mark.slow_integration_test
|
|
71
|
+
def test_user_personal_projects():
|
|
72
|
+
os.environ['GITLAB_URL'] = 'https://gitlab.com/'
|
|
73
|
+
output = io_util.execute(['-p', '--print-format', 'json', '-n', 'path', '--user-projects'], 60)
|
|
74
|
+
obj = json.loads(output)
|
|
75
|
+
assert obj['children'][0]['name'] == 'erezmazor-prsonal-projects'
|
|
76
|
+
assert obj['children'][0]['children'][0]['name'] == 'gitlabber-personal-project'
|
|
68
77
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '1.2.4'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_archive.cpython-311-pytest-8.2.2.pyc
RENAMED
|
File without changes
|
{gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_format.cpython-311-pytest-8.2.2.pyc
RENAMED
|
File without changes
|
|
File without changes
|
{gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_gitlab_tree.cpython-311-pytest-8.2.2.pyc
RENAMED
|
File without changes
|
{gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_integration.cpython-311-pytest-8.2.2.pyc
RENAMED
|
File without changes
|
{gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_method.cpython-311-pytest-8.2.2.pyc
RENAMED
|
File without changes
|
{gitlabber-1.2.4 → gitlabber-1.2.5}/tests/__pycache__/test_naming.cpython-311-pytest-8.2.2.pyc
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|