1 |
Support sync-clone-depth with the default set to 1. This allows the user |
2 |
to reduce the number of historical commits fetched along with the |
3 |
repository (git --depth). |
4 |
--- |
5 |
man/portage.5 | 4 ++++ |
6 |
pym/portage/repository/config.py | 19 ++++++++++++++++++- |
7 |
pym/portage/sync/modules/git/git.py | 6 +++++- |
8 |
3 files changed, 27 insertions(+), 2 deletions(-) |
9 |
|
10 |
diff --git a/man/portage.5 b/man/portage.5 |
11 |
index f0b0e20..3fb511c 100644 |
12 |
--- a/man/portage.5 |
13 |
+++ b/man/portage.5 |
14 |
@@ -903,6 +903,10 @@ since operations performed by these tools are inherently |
15 |
.B priority |
16 |
Specifies priority of given repository. |
17 |
.TP |
18 |
+.B sync\-clone\-depth |
19 |
+Specifies clone depth to use for DVCS repositories. Defaults to 1 (only |
20 |
+the newest commit). If set to 0, the depth is unlimited. |
21 |
+.TP |
22 |
.B sync\-cvs\-repo |
23 |
Specifies CVS repository. |
24 |
.TP |
25 |
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py |
26 |
index 7e17e02..2c4ce8a 100644 |
27 |
--- a/pym/portage/repository/config.py |
28 |
+++ b/pym/portage/repository/config.py |
29 |
@@ -88,7 +88,8 @@ class RepoConfig(object): |
30 |
'profile_formats', 'sign_commit', 'sign_manifest', 'sync_cvs_repo', |
31 |
'sync_type', 'sync_umask', 'sync_uri', 'sync_user', 'thin_manifest', |
32 |
'update_changelog', 'user_location', '_eapis_banned', |
33 |
- '_eapis_deprecated', '_masters_orig') |
34 |
+ '_eapis_deprecated', '_masters_orig', |
35 |
+ 'sync_clone_depth') |
36 |
|
37 |
def __init__(self, name, repo_opts, local_config=True): |
38 |
"""Build a RepoConfig with options in repo_opts |
39 |
@@ -176,6 +177,21 @@ class RepoConfig(object): |
40 |
auto_sync = auto_sync.strip().lower() |
41 |
self.auto_sync = auto_sync |
42 |
|
43 |
+ sync_clone_depth = None |
44 |
+ if self.sync_type in ('git',): |
45 |
+ sync_clone_depth = repo_opts.get('sync-clone-depth') |
46 |
+ if sync_clone_depth is not None: |
47 |
+ try: |
48 |
+ sync_clone_depth = int(sync_clone_depth) |
49 |
+ except ValueError: |
50 |
+ sync_clone_depth = None |
51 |
+ else: |
52 |
+ if sync_clone_depth == 0: |
53 |
+ sync_clone_depth = None |
54 |
+ else: |
55 |
+ sync_clone_depth = 1 |
56 |
+ self.sync_clone_depth = sync_clone_depth |
57 |
+ |
58 |
# Not implemented. |
59 |
format = repo_opts.get('format') |
60 |
if format is not None: |
61 |
@@ -489,6 +505,7 @@ class RepoConfigLoader(object): |
62 |
for k in ('aliases', 'auto_sync', 'eclass_overrides', |
63 |
'force', 'masters', 'priority', 'sync_cvs_repo', |
64 |
'sync_type', 'sync_umask', 'sync_uri', 'sync_user', |
65 |
+ 'sync_clone_depth', |
66 |
): |
67 |
v = getattr(repos_conf_opts, k, None) |
68 |
if v is not None: |
69 |
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py |
70 |
index 35943dd..b97d501 100644 |
71 |
--- a/pym/portage/sync/modules/git/git.py |
72 |
+++ b/pym/portage/sync/modules/git/git.py |
73 |
@@ -63,9 +63,13 @@ class GitSync(SyncBase): |
74 |
sync_uri = self.repo.sync_uri |
75 |
if sync_uri.startswith("file://"): |
76 |
sync_uri = sync_uri[6:] |
77 |
- exitcode = portage.process.spawn_bash("cd %s ; %s clone %s ." % \ |
78 |
+ depth_arg = '' |
79 |
+ if self.repo.sync_clone_depth is not None: |
80 |
+ depth_arg = '--depth %d ' % self.repo.sync_clone_depth |
81 |
+ exitcode = portage.process.spawn_bash("cd %s ; %s clone %s%s ." % \ |
82 |
(portage._shell_quote(self.repo.location), |
83 |
self.bin_command, |
84 |
+ depth_arg, |
85 |
portage._shell_quote(sync_uri)), |
86 |
**portage._native_kwargs(self.spawn_kwargs)) |
87 |
if exitcode != os.EX_OK: |
88 |
-- |
89 |
2.2.1 |