gitlabber 1.2.4__tar.gz → 1.2.5.1__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.
Files changed (51) hide show
  1. {gitlabber-1.2.4/gitlabber.egg-info → gitlabber-1.2.5.1}/PKG-INFO +3 -2
  2. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/README.rst +2 -1
  3. gitlabber-1.2.5.1/gitlabber/__init__.py +1 -0
  4. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber/cli.py +7 -2
  5. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber/gitlab_tree.py +17 -3
  6. {gitlabber-1.2.4 → gitlabber-1.2.5.1/gitlabber.egg-info}/PKG-INFO +3 -2
  7. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/test_cli.cpython-311-pytest-8.2.2.pyc +0 -0
  8. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/test_e2e.cpython-311-pytest-8.2.2.pyc +0 -0
  9. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test_cli.py +4 -4
  10. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test_e2e.py +10 -1
  11. gitlabber-1.2.4/gitlabber/__init__.py +0 -1
  12. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/LICENSE.txt +0 -0
  13. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/MANIFEST.in +0 -0
  14. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber/__main__.py +0 -0
  15. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber/archive.py +0 -0
  16. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber/format.py +0 -0
  17. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber/git.py +0 -0
  18. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber/method.py +0 -0
  19. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber/naming.py +0 -0
  20. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber/progress.py +0 -0
  21. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber.egg-info/SOURCES.txt +0 -0
  22. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber.egg-info/dependency_links.txt +0 -0
  23. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber.egg-info/entry_points.txt +0 -0
  24. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber.egg-info/requires.txt +0 -0
  25. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/gitlabber.egg-info/top_level.txt +0 -0
  26. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/setup.cfg +0 -0
  27. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/setup.py +0 -0
  28. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__init__.py +0 -0
  29. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/__init__.cpython-311.pyc +0 -0
  30. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/gitlab_test_utils.cpython-311.pyc +0 -0
  31. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/io_test_util.cpython-311.pyc +0 -0
  32. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/test_archive.cpython-311-pytest-8.2.2.pyc +0 -0
  33. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/test_format.cpython-311-pytest-8.2.2.pyc +0 -0
  34. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/test_git.cpython-311-pytest-8.2.2.pyc +0 -0
  35. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/test_gitlab_tree.cpython-311-pytest-8.2.2.pyc +0 -0
  36. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/test_integration.cpython-311-pytest-8.2.2.pyc +0 -0
  37. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/test_method.cpython-311-pytest-8.2.2.pyc +0 -0
  38. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/__pycache__/test_naming.cpython-311-pytest-8.2.2.pyc +0 -0
  39. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/gitlab_test_utils.py +0 -0
  40. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/io_test_util.py +0 -0
  41. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test-input.yaml +0 -0
  42. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test-output.json +0 -0
  43. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test-output.tree +0 -0
  44. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test-output.yaml +0 -0
  45. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test_archive.py +0 -0
  46. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test_format.py +0 -0
  47. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test_git.py +0 -0
  48. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test_gitlab_tree.py +0 -0
  49. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test_integration.py +0 -0
  50. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test_method.py +0 -0
  51. {gitlabber-1.2.4 → gitlabber-1.2.5.1}/tests/test_naming.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gitlabber
3
- Version: 1.2.4
3
+ Version: 1.2.5.1
4
4
  Summary: A Gitlab clone/pull utility for backing up or cloning Gitlab groups
5
5
  Home-page: https://github.com/ezbz/gitlabber
6
6
  Download-URL: https://github.com/ezbz/gitlabber/archive/main.zip
@@ -115,7 +115,7 @@ Usage
115
115
  .. code-block:: bash
116
116
 
117
117
  usage: gitlabber [-h] [-t token] [-T] [-u url] [--verbose] [-p] [--print-format {json,yaml,tree}] [-n {name,path}] [-m {ssh,http}]
118
- [-a {include,exclude,only}] [-i csv] [-x csv] [-r] [-F] [-d] [-s] [-g term] [--version]
118
+ [-a {include,exclude,only}] [-i csv] [-x csv] [-r] [-F] [-d] [-s] [-g term] [-U] [--version]
119
119
  [dest]
120
120
 
121
121
  Gitlabber - clones or pulls entire groups/projects tree from gitlab
@@ -149,6 +149,7 @@ Usage
149
149
  -s, --include-shared include shared projects in the results
150
150
  -g term, --group-search term
151
151
  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)
152
+ -U, --user-projects fetch only user personal projects (skips the group tree altogether, group related parameters are ignored). Clones personal projects to '{gitlab-username}-personal-projects'
152
153
  --version print the version
153
154
 
154
155
  examples:
@@ -89,7 +89,7 @@ Usage
89
89
  .. code-block:: bash
90
90
 
91
91
  usage: gitlabber [-h] [-t token] [-T] [-u url] [--verbose] [-p] [--print-format {json,yaml,tree}] [-n {name,path}] [-m {ssh,http}]
92
- [-a {include,exclude,only}] [-i csv] [-x csv] [-r] [-F] [-d] [-s] [-g term] [--version]
92
+ [-a {include,exclude,only}] [-i csv] [-x csv] [-r] [-F] [-d] [-s] [-g term] [-U] [--version]
93
93
  [dest]
94
94
 
95
95
  Gitlabber - clones or pulls entire groups/projects tree from gitlab
@@ -123,6 +123,7 @@ Usage
123
123
  -s, --include-shared include shared projects in the results
124
124
  -g term, --group-search term
125
125
  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)
126
+ -U, --user-projects fetch only user personal projects (skips the group tree altogether, group related parameters are ignored). Clones personal projects to '{gitlab-username}-personal-projects'
126
127
  --version print the version
127
128
 
128
129
  examples:
@@ -0,0 +1 @@
1
+ __version__ = '1.2.5.1'
@@ -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(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gitlabber
3
- Version: 1.2.4
3
+ Version: 1.2.5.1
4
4
  Summary: A Gitlab clone/pull utility for backing up or cloning Gitlab groups
5
5
  Home-page: https://github.com/ezbz/gitlabber
6
6
  Download-URL: https://github.com/ezbz/gitlabber/archive/main.zip
@@ -115,7 +115,7 @@ Usage
115
115
  .. code-block:: bash
116
116
 
117
117
  usage: gitlabber [-h] [-t token] [-T] [-u url] [--verbose] [-p] [--print-format {json,yaml,tree}] [-n {name,path}] [-m {ssh,http}]
118
- [-a {include,exclude,only}] [-i csv] [-x csv] [-r] [-F] [-d] [-s] [-g term] [--version]
118
+ [-a {include,exclude,only}] [-i csv] [-x csv] [-r] [-F] [-d] [-s] [-g term] [-U] [--version]
119
119
  [dest]
120
120
 
121
121
  Gitlabber - clones or pulls entire groups/projects tree from gitlab
@@ -149,6 +149,7 @@ Usage
149
149
  -s, --include-shared include shared projects in the results
150
150
  -g term, --group-search term
151
151
  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)
152
+ -U, --user-projects fetch only user personal projects (skips the group tree altogether, group related parameters are ignored). Clones personal projects to '{gitlab-username}-personal-projects'
152
153
  --version print the version
153
154
 
154
155
  examples:
@@ -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', '--verbose'], 60)
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