1
- import git .objects .base
2
- from util import *
1
+ import util
2
+ from util import (
3
+ mkhead ,
4
+ sm_name ,
5
+ sm_section ,
6
+ unbare_repo ,
7
+ SubmoduleConfigParser ,
8
+ find_first_remote_branch
9
+ )
3
10
from git .objects .util import Traversable
4
11
from StringIO import StringIO # need a dict to set bloody .name field
5
- from git .util import Iterable , join_path_native , to_native_path_linux
12
+ from git .util import (
13
+ Iterable ,
14
+ join_path_native ,
15
+ to_native_path_linux
16
+ )
6
17
from git .config import SectionConstraint
7
- from git .exc import InvalidGitRepositoryError , NoSuchPathError
18
+ from git .exc import (
19
+ InvalidGitRepositoryError ,
20
+ NoSuchPathError
21
+ )
8
22
import stat
9
23
import git
10
24
13
27
14
28
import shutil
15
29
16
- __all__ = ( "Submodule" , "RootModule" )
30
+ __all__ = [ "Submodule" ]
17
31
18
32
19
-
20
- class Submodule (git .objects .base .IndexObject , Iterable , Traversable ):
33
+ # IndexObject comes via util module, its a 'hacky' fix thanks to pythons import
34
+ # mechanism which cause plenty of trouble of the only reason for packages and
35
+ # modules is refactoring - subpackages shoudn't depend on parent packages
36
+ class Submodule (util .IndexObject , Iterable , Traversable ):
21
37
"""Implements access to a git submodule. They are special in that their sha
22
38
represents a commit in the submodule's repository which is to be checked out
23
39
at the path of this instance.
@@ -41,6 +57,7 @@ class Submodule(git.objects.base.IndexObject, Iterable, Traversable):
41
57
def __init__ (self , repo , binsha , mode = None , path = None , name = None , parent_commit = None , url = None , branch = None ):
42
58
"""Initialize this instance with its attributes. We only document the ones
43
59
that differ from ``IndexObject``
60
+
44
61
:param repo: Our parent repository
45
62
:param binsha: binary sha referring to a commit in the remote repository, see url parameter
46
63
:param parent_commit: see set_parent_commit()
@@ -163,6 +180,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
163
180
as well as the .gitmodules file, but will not create a new commit.
164
181
If the submodule already exists, no matter if the configuration differs
165
182
from the one provided, the existing submodule will be returned.
183
+
166
184
:param repo: Repository instance which should receive the submodule
167
185
:param name: The name/identifier for the submodule
168
186
:param path: repository-relative or absolute path at which the submodule
@@ -260,6 +278,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
260
278
def update (self , recursive = False , init = True , to_latest_revision = False ):
261
279
"""Update the repository of this submodule to point to the checkout
262
280
we point at with the binsha of this instance.
281
+
263
282
:param recursive: if True, we will operate recursively and update child-
264
283
modules as well.
265
284
:param init: if True, the module repository will be cloned into place if necessary
@@ -382,6 +401,7 @@ def move(self, module_path, configuration=True, module=True):
382
401
"""Move the submodule to a another module path. This involves physically moving
383
402
the repository at our current path, changing the configuration, as well as
384
403
adjusting our index entry accordingly.
404
+
385
405
:param module_path: the path to which to move our module, given as
386
406
repository-relative path. Intermediate directories will be created
387
407
accordingly. If the path already exists, it must be empty.
@@ -484,6 +504,7 @@ def move(self, module_path, configuration=True, module=True):
484
504
def remove (self , module = True , force = False , configuration = True , dry_run = False ):
485
505
"""Remove this submodule from the repository. This will remove our entry
486
506
from the .gitmodules file and the entry in the .git/config file.
507
+
487
508
:param module: If True, the module we point to will be deleted
488
509
as well. If the module is currently on a commit which is not part
489
510
of any branch in the remote, if the currently checked out branch
@@ -588,6 +609,7 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False):
588
609
def set_parent_commit (self , commit , check = True ):
589
610
"""Set this instance to use the given commit whose tree is supposed to
590
611
contain the .gitmodules blob.
612
+
591
613
:param commit: Commit'ish reference pointing at the root_tree
592
614
:param check: if True, relatively expensive checks will be performed to verify
593
615
validity of the submodule.
0 commit comments