gitlabber 1.2.5__tar.gz → 1.2.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.
Files changed (52) hide show
  1. {gitlabber-1.2.5/gitlabber.egg-info → gitlabber-1.2.6}/PKG-INFO +12 -3
  2. {gitlabber-1.2.5 → gitlabber-1.2.6}/README.rst +11 -2
  3. gitlabber-1.2.6/gitlabber/__init__.py +1 -0
  4. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber/cli.py +14 -1
  5. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber/git.py +6 -3
  6. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber/gitlab_tree.py +2 -1
  7. {gitlabber-1.2.5 → gitlabber-1.2.6/gitlabber.egg-info}/PKG-INFO +12 -3
  8. gitlabber-1.2.6/tests/__pycache__/gitlab_test_utils.cpython-311.pyc +0 -0
  9. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/test_cli.cpython-311-pytest-8.2.2.pyc +0 -0
  10. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/test_e2e.cpython-311-pytest-8.2.2.pyc +0 -0
  11. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/test_git.cpython-311-pytest-8.2.2.pyc +0 -0
  12. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/test_gitlab_tree.cpython-311-pytest-8.2.2.pyc +0 -0
  13. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/test_integration.cpython-311-pytest-8.2.2.pyc +0 -0
  14. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/gitlab_test_utils.py +6 -4
  15. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test_cli.py +5 -5
  16. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test_git.py +38 -0
  17. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test_gitlab_tree.py +9 -1
  18. gitlabber-1.2.5/gitlabber/__init__.py +0 -1
  19. gitlabber-1.2.5/tests/__pycache__/gitlab_test_utils.cpython-311.pyc +0 -0
  20. {gitlabber-1.2.5 → gitlabber-1.2.6}/LICENSE.txt +0 -0
  21. {gitlabber-1.2.5 → gitlabber-1.2.6}/MANIFEST.in +0 -0
  22. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber/__main__.py +0 -0
  23. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber/archive.py +0 -0
  24. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber/format.py +0 -0
  25. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber/method.py +0 -0
  26. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber/naming.py +0 -0
  27. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber/progress.py +0 -0
  28. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber.egg-info/SOURCES.txt +0 -0
  29. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber.egg-info/dependency_links.txt +0 -0
  30. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber.egg-info/entry_points.txt +0 -0
  31. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber.egg-info/requires.txt +0 -0
  32. {gitlabber-1.2.5 → gitlabber-1.2.6}/gitlabber.egg-info/top_level.txt +0 -0
  33. {gitlabber-1.2.5 → gitlabber-1.2.6}/setup.cfg +0 -0
  34. {gitlabber-1.2.5 → gitlabber-1.2.6}/setup.py +0 -0
  35. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__init__.py +0 -0
  36. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/__init__.cpython-311.pyc +0 -0
  37. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/io_test_util.cpython-311.pyc +0 -0
  38. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/test_archive.cpython-311-pytest-8.2.2.pyc +0 -0
  39. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/test_format.cpython-311-pytest-8.2.2.pyc +0 -0
  40. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/test_method.cpython-311-pytest-8.2.2.pyc +0 -0
  41. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/__pycache__/test_naming.cpython-311-pytest-8.2.2.pyc +0 -0
  42. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/io_test_util.py +0 -0
  43. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test-input.yaml +0 -0
  44. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test-output.json +0 -0
  45. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test-output.tree +0 -0
  46. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test-output.yaml +0 -0
  47. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test_archive.py +0 -0
  48. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test_e2e.py +0 -0
  49. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test_format.py +0 -0
  50. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test_integration.py +0 -0
  51. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test_method.py +0 -0
  52. {gitlabber-1.2.5 → gitlabber-1.2.6}/tests/test_naming.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gitlabber
3
- Version: 1.2.5
3
+ Version: 1.2.6
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
@@ -46,7 +46,7 @@ License-File: LICENSE.txt
46
46
  Gitlabber
47
47
  =========
48
48
 
49
- * A utility to clone and pull GitLab groups, subgroups, projects based on path selection
49
+ * A utility to clone and pull GitLab groups, subgroups, group projects or personal user projects based on path selection
50
50
 
51
51
 
52
52
  Purpose
@@ -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] [-o options] [--version]
119
119
  [dest]
120
120
 
121
121
  Gitlabber - clones or pulls entire groups/projects tree from gitlab
@@ -149,6 +149,9 @@ 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'
153
+ -o options, --git-options options
154
+ provide additional options as csv for the git command (e.g., --depth=1). See: clone/multi_options https://gitpython.readthedocs.io/en/stable/reference.html#
152
155
  --version print the version
153
156
 
154
157
  examples:
@@ -171,6 +174,12 @@ Usage
171
174
  clone projects that start with a case insensitive 'w' using a regular expression:
172
175
  gitlabber -i '/{[w].*}' .
173
176
 
177
+ clone a user's personal projects to username-personal-projects
178
+ gitlabber -U .
179
+
180
+ perform a shallow clone of the git repositories
181
+ gitlabber -o "\-\-depth=1," .
182
+
174
183
 
175
184
 
176
185
  Debugging
@@ -20,7 +20,7 @@
20
20
  Gitlabber
21
21
  =========
22
22
 
23
- * A utility to clone and pull GitLab groups, subgroups, projects based on path selection
23
+ * A utility to clone and pull GitLab groups, subgroups, group projects or personal user projects based on path selection
24
24
 
25
25
 
26
26
  Purpose
@@ -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] [-o options] [--version]
93
93
  [dest]
94
94
 
95
95
  Gitlabber - clones or pulls entire groups/projects tree from gitlab
@@ -123,6 +123,9 @@ 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'
127
+ -o options, --git-options options
128
+ provide additional options as csv for the git command (e.g., --depth=1). See: clone/multi_options https://gitpython.readthedocs.io/en/stable/reference.html#
126
129
  --version print the version
127
130
 
128
131
  examples:
@@ -145,6 +148,12 @@ Usage
145
148
  clone projects that start with a case insensitive 'w' using a regular expression:
146
149
  gitlabber -i '/{[w].*}' .
147
150
 
151
+ clone a user's personal projects to username-personal-projects
152
+ gitlabber -U .
153
+
154
+ perform a shallow clone of the git repositories
155
+ gitlabber -o "\-\-depth=1," .
156
+
148
157
 
149
158
 
150
159
  Debugging
@@ -0,0 +1 @@
1
+ __version__ = '1.2.6'
@@ -43,7 +43,8 @@ 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.include_shared, args.use_fetch, args.hide_token, args.user_projects, group_search=args.group_search)
46
+ args.include_shared, args.use_fetch, args.hide_token, args.user_projects,
47
+ group_search=args.group_search, git_options=args.git_options)
47
48
  tree.load_tree()
48
49
 
49
50
  if tree.is_empty():
@@ -91,6 +92,12 @@ def parse_args(argv=None):
91
92
 
92
93
  clone projects that start with a case insensitive 'w' using a regular expression:
93
94
  gitlabber -i '/{[w].*}' .
95
+
96
+ clone a user's personal projects to username-personal-projects
97
+ gitlabber -U .
98
+
99
+ perform a shallow clone of the git repositories
100
+ gitlabber -o "\-\-depth=1," .
94
101
  '''
95
102
 
96
103
  parser = ArgumentParser(
@@ -216,6 +223,12 @@ def parse_args(argv=None):
216
223
  action='store_true',
217
224
  default=False,
218
225
  help='fetch only user personal projects (skips the group tree altogether, group related parameters are ignored). Clones personal projects to \'{gitlab-username}-personal-projects\'')
226
+ parser.add_argument(
227
+ '-o',
228
+ '--git-options',
229
+ nargs=1,
230
+ metavar=('options'),
231
+ help='provide additional options as csv for the git command (e.g., --depth=1). See: clone/multi_options https://gitpython.readthedocs.io/en/stable/reference.html#')
219
232
  parser.add_argument(
220
233
  '--version',
221
234
  action='store_true',
@@ -12,14 +12,15 @@ progress = ProgressBar('* syncing projects')
12
12
 
13
13
 
14
14
  class GitAction:
15
- def __init__(self, node, path, recursive=False, use_fetch=False, hide_token=False):
15
+ def __init__(self, node, path, recursive=False, use_fetch=False, hide_token=False, git_options=None):
16
16
  self.node = node
17
17
  self.path = path
18
18
  self.recursive = recursive
19
19
  self.use_fetch = use_fetch
20
20
  self.hide_token = hide_token
21
+ self.git_options = git_options
21
22
 
22
- def sync_tree(root, dest, concurrency=1, disable_progress=False, recursive=False, use_fetch=False, hide_token=False):
23
+ def sync_tree(root, dest, concurrency=1, disable_progress=False, recursive=False, use_fetch=False, hide_token=False, git_options=None):
23
24
  if not disable_progress:
24
25
  progress.init_progress(len(root.leaves))
25
26
  actions = get_git_actions(root, dest, recursive, use_fetch, hide_token)
@@ -71,7 +72,7 @@ def clone_or_pull_project(action):
71
72
  log.fatal("User interrupted")
72
73
  sys.exit(0)
73
74
  except Exception as e:
74
- log.debug("Error pulling project %s", action.path, exc_info=True)
75
+ log.error("Error pulling project %s", action.path, exc_info=True)
75
76
  else:
76
77
  '''
77
78
  Clone new project
@@ -86,6 +87,8 @@ def clone_or_pull_project(action):
86
87
  multi_options.append('--recursive')
87
88
  if(action.use_fetch):
88
89
  multi_options.append('--mirror')
90
+ if(action.git_options):
91
+ multi_options += action.git_options.split(',')
89
92
  try:
90
93
  git.Repo.clone_from(action.node.url, action.path, multi_options=multi_options)
91
94
 
@@ -18,7 +18,7 @@ log = logging.getLogger(__name__)
18
18
 
19
19
  class GitlabTree:
20
20
  def __init__(self, url, token, method, naming=None, archived=None, includes=[], excludes=[], in_file=None, concurrency=1, recursive=False, disable_progress=False,
21
- include_shared=True, use_fetch=False, hide_token=False, user_projects=False, group_search=None):
21
+ include_shared=True, use_fetch=False, hide_token=False, user_projects=False, group_search=None, git_options=None):
22
22
  self.includes = includes
23
23
  self.excludes = excludes
24
24
  self.url = url
@@ -39,6 +39,7 @@ class GitlabTree:
39
39
  self.hide_token = hide_token
40
40
  self.user_projects = user_projects
41
41
  self.group_search = group_search
42
+ self.git_options = git_options
42
43
 
43
44
  @staticmethod
44
45
  def get_ca_path():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gitlabber
3
- Version: 1.2.5
3
+ Version: 1.2.6
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
@@ -46,7 +46,7 @@ License-File: LICENSE.txt
46
46
  Gitlabber
47
47
  =========
48
48
 
49
- * A utility to clone and pull GitLab groups, subgroups, projects based on path selection
49
+ * A utility to clone and pull GitLab groups, subgroups, group projects or personal user projects based on path selection
50
50
 
51
51
 
52
52
  Purpose
@@ -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] [-o options] [--version]
119
119
  [dest]
120
120
 
121
121
  Gitlabber - clones or pulls entire groups/projects tree from gitlab
@@ -149,6 +149,9 @@ 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'
153
+ -o options, --git-options options
154
+ provide additional options as csv for the git command (e.g., --depth=1). See: clone/multi_options https://gitpython.readthedocs.io/en/stable/reference.html#
152
155
  --version print the version
153
156
 
154
157
  examples:
@@ -171,6 +174,12 @@ Usage
171
174
  clone projects that start with a case insensitive 'w' using a regular expression:
172
175
  gitlabber -i '/{[w].*}' .
173
176
 
177
+ clone a user's personal projects to username-personal-projects
178
+ gitlabber -U .
179
+
180
+ perform a shallow clone of the git repositories
181
+ gitlabber -o "\-\-depth=1," .
182
+
174
183
 
175
184
 
176
185
  Debugging
@@ -2,6 +2,7 @@ import pytest
2
2
  import json
3
3
  from unittest import mock
4
4
  from gitlabber import gitlab_tree
5
+ from gitlabber.method import CloneMethod
5
6
 
6
7
  URL = "http://gitlab.my.com/"
7
8
  TOKEN = "MOCK_TOKEN"
@@ -12,6 +13,7 @@ SUBGROUP_URL = "http://gitlab.my.com/group/subgroup"
12
13
  SUBGROUP_NAME = "subgroup"
13
14
 
14
15
  PROJECT_URL = "http://gitlab.my.com/group/subgroup/project/project.git"
16
+ PROJECT_URL_WITH_TOKEN = "http://gitlab-token:xxx@gitlab.my.com/group/subgroup/project/project.git"
15
17
  PROJECT_NAME = "project"
16
18
 
17
19
  YAML_TEST_INPUT_FILE = "tests/test-input.yaml"
@@ -21,7 +23,7 @@ TREE_TEST_OUTPUT_FILE = "tests/test-output.tree"
21
23
 
22
24
 
23
25
  class MockNode:
24
- def __init__(self, type, id, name, url, subgroups=mock.MagicMock(), projects=mock.MagicMock(), parent_id=None, archived=0, shared=False, group_search=None):
26
+ def __init__(self, type, id, name, url, subgroups=mock.MagicMock(), projects=mock.MagicMock(), parent_id=None, archived=0, shared=False, group_search=None, git_options=None):
25
27
  self.type = type
26
28
  self.id = id
27
29
  self.name = name
@@ -117,10 +119,10 @@ def validate_tree(root):
117
119
  validate_subgroup(root.children[0].children[0])
118
120
  validate_project(root.children[0].children[0].children[0])
119
121
 
120
- def create_test_gitlab(monkeypatch, includes=None, excludes=None, in_file=None):
122
+ def create_test_gitlab(monkeypatch, includes=None, excludes=None, in_file=None, hide_token=True, method=CloneMethod.SSH):
121
123
  gl = gitlab_tree.GitlabTree(
122
- URL, TOKEN, "ssh", "name", includes=includes, excludes=excludes, in_file=in_file)
123
- projects = Listable(MockNode("project", 2, PROJECT_NAME, PROJECT_URL))
124
+ URL, TOKEN, "ssh", "name", includes=includes, excludes=excludes, in_file=in_file, hide_token=hide_token)
125
+ projects = Listable(MockNode("project", 2, PROJECT_NAME, PROJECT_URL if hide_token else PROJECT_URL_WITH_TOKEN))
124
126
  groups = Listable(
125
127
  MockNode("group", 2, GROUP_NAME, GROUP_URL, subgroups=Listable(
126
128
  MockNode("subgroup", 3, SUBGROUP_NAME, SUBGROUP_URL, projects=projects)
@@ -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, user_projects=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, git_options=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, user_projects=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, git_options=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, user_projects=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, git_options=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, user_projects=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, git_options=None)
120
120
  cli.parse_args = args_mock
121
121
 
122
122
  with pytest.raises(SystemExit):
@@ -127,7 +127,7 @@ def test_empty_tree(mock_tree):
127
127
  def test_missing_dest(mock_tree, capsys):
128
128
  args_mock = mock.Mock()
129
129
  args_mock.return_value = Node(
130
- 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=False, dest=None, group_search=None)
130
+ 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=False, dest=None, group_search=None, git_options=None)
131
131
  cli.parse_args = args_mock
132
132
  mock_tree.return_value.is_empty = mock.Mock(return_value=False)
133
133
 
@@ -115,6 +115,20 @@ def test_pull_repo_exception(mock_git):
115
115
 
116
116
  mock_git.Repo.assert_called_once_with("dummy_dir")
117
117
  repo_instance.remotes.origin.pull.assert_called_once()
118
+
119
+ @mock.patch('gitlabber.git.git')
120
+ def test_clone_repo_exception(mock_git):
121
+ mock_repo = mock.Mock()
122
+ mock_git.Repo = mock_repo
123
+ git.is_git_repo = mock.MagicMock(return_value=False)
124
+
125
+ repo_instance = mock_git.Repo.return_value
126
+ repo_instance.clone_from.side_effect=Exception('clone test exception')
127
+
128
+ git.clone_or_pull_project(
129
+ GitAction(Node(type="project", name="dummy_url", url="dummy_url"), "dummy_dir"))
130
+ mock_git.Repo.clone_from.assert_called_once_with('dummy_url', 'dummy_dir', multi_options=[])
131
+ mock_git.Repo.clone_from.assert_called_once()
118
132
 
119
133
  @mock.patch('gitlabber.git.git')
120
134
  def test_pull_repo_interrupt(mock_git):
@@ -144,3 +158,27 @@ def test_clone_repo_interrupt(mock_git):
144
158
  Node(type="project", name="dummy_url", url="dummy_url"), "dummy_dir"))
145
159
 
146
160
  mock_git.Repo.clone_from.assert_called_once_with("dummy_url", "dummy_dir", multi_options=[])
161
+
162
+
163
+ @mock.patch('gitlabber.git.git')
164
+ def test_clone_repo_options_many_options(mock_git):
165
+ mock_repo = mock.Mock()
166
+ mock_git.Repo = mock_repo
167
+ git.is_git_repo = mock.MagicMock(return_value=False)
168
+
169
+ git.clone_or_pull_project(
170
+ GitAction(Node(type="project", name="dummy_url", url="dummy_url"), "dummy_dir", git_options="--opt1=1,--opt2=2"))
171
+
172
+ mock_git.Repo.clone_from.assert_called_once_with("dummy_url", "dummy_dir", multi_options=['--opt1=1','--opt2=2'])
173
+
174
+
175
+ @mock.patch('gitlabber.git.git')
176
+ def test_clone_repo_options_with_recursive(mock_git):
177
+ mock_repo = mock.Mock()
178
+ mock_git.Repo = mock_repo
179
+ git.is_git_repo = mock.MagicMock(return_value=False)
180
+
181
+ git.clone_or_pull_project(
182
+ GitAction(Node(type="project", name="dummy_url", url="dummy_url"), "dummy_dir", recursive=True, git_options="--opt1=1,--opt2=2"))
183
+
184
+ mock_git.Repo.clone_from.assert_called_once_with("dummy_url", "dummy_dir", multi_options=['--recursive','--opt1=1','--opt2=2'])
@@ -1,4 +1,5 @@
1
1
 
2
+ from gitlabber.method import CloneMethod
2
3
  import tests.gitlab_test_utils as gitlab_util
3
4
  import tests.io_test_util as output_util
4
5
  from gitlabber.archive import ArchivedResults
@@ -164,4 +165,11 @@ def test_shared_excluded(monkeypatch):
164
165
  assert len(gl.root.children) == 1
165
166
  assert len(gl.root.children[0].children) == 1
166
167
 
167
- assert "project" in gl.root.children[0].children[0].name
168
+ assert "project" in gl.root.children[0].children[0].name
169
+
170
+
171
+ def test_hide_token_from_project_url(monkeypatch):
172
+ gl = gitlab_util.create_test_gitlab(monkeypatch, hide_token=True, method=CloneMethod.HTTP)
173
+ gl.load_tree()
174
+ gl.print_tree()
175
+ assert 'gitlab-token:xxx@' not in gl.root.children[0].children[0].children[0].url
@@ -1 +0,0 @@
1
- __version__ = '1.2.5'
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