@@ -266,8 +266,8 @@ def _clear_cache(self) -> None:
266
266
def _sio_modules (cls , parent_commit : Commit_ish ) -> BytesIO :
267
267
"""
268
268
:return:
269
- Configuration file as BytesIO - we only access it through the respective
270
- blob's data
269
+ Configuration file as :class:`~io. BytesIO` - we only access it through the
270
+ respective blob's data
271
271
"""
272
272
sio = BytesIO (parent_commit .tree [cls .k_modules_file ].data_stream .read ())
273
273
sio .name = cls .k_modules_file
@@ -354,7 +354,7 @@ def _to_relative_path(cls, parent_repo: "Repo", path: PathLike) -> PathLike:
354
354
""":return: a path guaranteed to be relative to the given parent repository
355
355
356
356
:raise ValueError:
357
- If path is not contained in the parent repository's working tree
357
+ If path is not contained in the parent repository's working tree.
358
358
"""
359
359
path = to_native_path_linux (path )
360
360
if path .endswith ("/" ):
@@ -378,8 +378,8 @@ def _to_relative_path(cls, parent_repo: "Repo", path: PathLike) -> PathLike:
378
378
379
379
@classmethod
380
380
def _write_git_file_and_module_config (cls , working_tree_dir : PathLike , module_abspath : PathLike ) -> None :
381
- """Write a .git file containing a (preferably) relative path to the actual git
382
- module repository.
381
+ """Write a `` .git`` file containing a (preferably) relative path to the actual
382
+ git module repository.
383
383
384
384
It is an error if the `module_abspath` cannot be made into a relative path,
385
385
relative to the `working_tree_dir`.
@@ -430,10 +430,10 @@ def add(
430
430
allow_unsafe_options : bool = False ,
431
431
allow_unsafe_protocols : bool = False ,
432
432
) -> "Submodule" :
433
- """Add a new submodule to the given repository. This will alter the index
434
- as well as the ``.gitmodules`` file, but will not create a new commit.
435
- If the submodule already exists, no matter if the configuration differs
436
- from the one provided, the existing submodule will be returned.
433
+ """Add a new submodule to the given repository. This will alter the index as
434
+ well as the ``.gitmodules`` file, but will not create a new commit. If the
435
+ submodule already exists, no matter if the configuration differs from the one
436
+ provided, the existing submodule will be returned.
437
437
438
438
:param repo:
439
439
Repository instance which should receive the submodule.
@@ -448,23 +448,23 @@ def add(
448
448
449
449
:param url:
450
450
git-clone compatible URL, see git-clone reference for more information.
451
- If None, the repository is assumed to exist, and the url of the first remote
452
- is taken instead. This is useful if you want to make an existing repository
453
- a submodule of another one.
451
+ If `` None``` , the repository is assumed to exist, and the url of the first
452
+ remote is taken instead. This is useful if you want to make an existing
453
+ repository a submodule of another one.
454
454
455
455
:param branch:
456
456
Name of branch at which the submodule should (later) be checked out. The
457
457
given branch must exist in the remote repository, and will be checked out
458
458
locally as a tracking branch.
459
- It will only be written into the configuration if it not None, which is when
460
- the checked out branch will be the one the remote HEAD pointed to.
459
+ It will only be written into the configuration if it not `` None`` , which is
460
+ when the checked out branch will be the one the remote HEAD pointed to.
461
461
The result you get in these situation is somewhat fuzzy, and it is
462
462
recommended to specify at least ``master`` here.
463
463
Examples are ``master`` or ``feature/new``.
464
464
465
465
:param no_checkout:
466
- If True, and if the repository has to be cloned manually, no checkout will
467
- be performed.
466
+ If `` True`` , and if the repository has to be cloned manually, no checkout
467
+ will be performed.
468
468
469
469
:param depth:
470
470
Create a shallow clone with a history truncated to the specified number of
@@ -479,7 +479,8 @@ def add(
479
479
want to unset some variable, consider providing an empty string as its
480
480
value.
481
481
482
- :param clone_multi_options: A list of Clone options. Please see
482
+ :param clone_multi_options:
483
+ A list of clone options. Please see
483
484
:meth:`Repo.clone <git.repo.base.Repo.clone>` for details.
484
485
485
486
:param allow_unsafe_protocols:
@@ -632,44 +633,49 @@ def update(
632
633
with the binsha of this instance.
633
634
634
635
:param recursive:
635
- If True, we will operate recursively and update child modules as well.
636
+ If `` True`` , we will operate recursively and update child modules as well.
636
637
637
638
:param init:
638
- If True, the module repository will be cloned into place if necessary.
639
+ If `` True`` , the module repository will be cloned into place if necessary.
639
640
640
641
:param to_latest_revision:
641
- If True, the submodule's sha will be ignored during checkout. Instead, the
642
- remote will be fetched, and the local tracking branch updated. This only
642
+ If `` True`` , the submodule's sha will be ignored during checkout. Instead,
643
+ the remote will be fetched, and the local tracking branch updated. This only
643
644
works if we have a local tracking branch, which is the case if the remote
644
- repository had a master branch, or of the ' branch' option was specified for
645
- this submodule and the branch existed remotely.
645
+ repository had a master branch, or of the `` branch`` option was specified
646
+ for this submodule and the branch existed remotely.
646
647
647
648
:param progress:
648
- :class:`UpdateProgress` instance, or None if no progress should be shown.
649
+ :class:`UpdateProgress` instance, or ``None`` if no progress should be
650
+ shown.
649
651
650
652
:param dry_run:
651
- If True, the operation will only be simulated, but not performed.
653
+ If `` True`` , the operation will only be simulated, but not performed.
652
654
All performed operations are read-only.
653
655
654
656
:param force:
655
- If True, we may reset heads even if the repository in question is dirty.
657
+ If `` True`` , we may reset heads even if the repository in question is dirty.
656
658
Additionally we will be allowed to set a tracking branch which is ahead of
657
659
its remote branch back into the past or the location of the remote branch.
658
660
This will essentially 'forget' commits.
659
- If False, local tracking branches that are in the future of their respective
660
- remote branches will simply not be moved.
661
+
662
+ If ``False``, local tracking branches that are in the future of their
663
+ respective remote branches will simply not be moved.
661
664
662
665
:param keep_going:
663
- If True, we will ignore but log all errors, and keep going recursively.
666
+ If `` True`` , we will ignore but log all errors, and keep going recursively.
664
667
Unless `dry_run` is set as well, `keep_going` could cause
665
668
subsequent/inherited errors you wouldn't see otherwise.
666
669
In conjunction with `dry_run`, it can be useful to anticipate all errors
667
670
when updating submodules.
668
671
669
- :param env: Optional dictionary containing the desired environment variables.
672
+ :param env:
673
+ Optional dictionary containing the desired environment variables.
674
+
670
675
Note: Provided variables will be used to update the execution environment
671
676
for ``git``. If some variable is not specified in `env` and is defined in
672
677
attr:`os.environ`, value from attr:`os.environ` will be used.
678
+
673
679
If you want to unset some variable, consider providing the empty string as
674
680
its value.
675
681
@@ -688,7 +694,7 @@ def update(
688
694
Does nothing in bare repositories.
689
695
690
696
:note:
691
- This method is definitely not atomic if `recursive` is True.
697
+ This method is definitely not atomic if `recursive` is `` True`` .
692
698
693
699
:return:
694
700
self
@@ -950,18 +956,18 @@ def move(self, module_path: PathLike, configuration: bool = True, module: bool =
950
956
951
957
:param module_path:
952
958
The path to which to move our module in the parent repository's working
953
- tree, given as repository - relative or absolute path. Intermediate
959
+ tree, given as repository- relative or absolute path. Intermediate
954
960
directories will be created accordingly. If the path already exists, it must
955
961
be empty. Trailing (back)slashes are removed automatically.
956
962
957
963
:param configuration:
958
- If True, the configuration will be adjusted to let the submodule point to
959
- the given path.
964
+ If `` True`` , the configuration will be adjusted to let the submodule point
965
+ to the given path.
960
966
961
967
:param module:
962
- If True, the repository managed by this submodule will be moved as well. If
963
- False, we don't move the submodule's checkout, which may leave the parent
964
- repository in an inconsistent state.
968
+ If `` True`` , the repository managed by this submodule will be moved as well.
969
+ If `` False`` , we don't move the submodule's checkout, which may leave the
970
+ parent repository in an inconsistent state.
965
971
966
972
:return:
967
973
self
@@ -1074,12 +1080,13 @@ def remove(
1074
1080
from the ``.gitmodules`` file and the entry in the ``.git/config`` file.
1075
1081
1076
1082
:param module:
1077
- If True, the checked out module we point to will be deleted as well. If that
1078
- module is currently on a commit outside any branch in the remote, or if it
1079
- is ahead of its tracking branch, or if there are modified or untracked files
1080
- in its working tree, then the removal will fail. In case the removal of the
1081
- repository fails for these reasons, the submodule status will not have been
1082
- altered.
1083
+ If ``True``, the checked out module we point to will be deleted as well. If
1084
+ that module is currently on a commit outside any branch in the remote, or if
1085
+ it is ahead of its tracking branch, or if there are modified or untracked
1086
+ files in its working tree, then the removal will fail. In case the removal
1087
+ of the repository fails for these reasons, the submodule status will not
1088
+ have been altered.
1089
+
1083
1090
If this submodule has child modules of its own, these will be deleted prior
1084
1091
to touching the direct submodule.
1085
1092
@@ -1088,12 +1095,12 @@ def remove(
1088
1095
This basically enforces a brute-force file system based deletion.
1089
1096
1090
1097
:param configuration:
1091
- If True, the submodule is deleted from the configuration, otherwise it
1098
+ If `` True`` , the submodule is deleted from the configuration, otherwise it
1092
1099
isn't. Although this should be enabled most of the time, this flag enables
1093
1100
you to safely delete the repository of your submodule.
1094
1101
1095
1102
:param dry_run:
1096
- If True, we will not actually do anything, but throw the errors we would
1103
+ If `` True`` , we will not actually do anything, but throw the errors we would
1097
1104
usually throw.
1098
1105
1099
1106
:return:
@@ -1239,12 +1246,12 @@ def set_parent_commit(self, commit: Union[Commit_ish, None], check: bool = True)
1239
1246
contain the ``.gitmodules`` blob.
1240
1247
1241
1248
:param commit:
1242
- Commit-ish reference pointing at the root_tree, or None to always point to
1243
- the most recent commit
1249
+ Commit-ish reference pointing at the root_tree, or `` None`` to always point
1250
+ to the most recent commit.
1244
1251
1245
1252
:param check:
1246
- If True, relatively expensive checks will be performed to verify validity of
1247
- the submodule.
1253
+ If `` True`` , relatively expensive checks will be performed to verify
1254
+ validity of the submodule.
1248
1255
1249
1256
:raise ValueError:
1250
1257
If the commit's tree didn't contain the ``.gitmodules`` blob.
@@ -1297,8 +1304,9 @@ def config_writer(
1297
1304
to this submodule into the ``.gitmodules`` file.
1298
1305
1299
1306
:param index:
1300
- If not None, an IndexFile instance which should be written.
1301
- Defaults to the index of the Submodule's parent repository.
1307
+ If not ``None``, an :class:`~git.index.base.IndexFile` instance which should
1308
+ be written. Defaults to the index of the :class:`Submodule`'s parent
1309
+ repository.
1302
1310
1303
1311
:param write:
1304
1312
If True, the index will be written each time a configuration value changes.
@@ -1380,7 +1388,9 @@ def rename(self, new_name: str) -> "Submodule":
1380
1388
@unbare_repo
1381
1389
def module (self ) -> "Repo" :
1382
1390
"""
1383
- :return: Repo instance initialized from the repository at our submodule path
1391
+ :return:
1392
+ :class:`~git.repo.base.Repo` instance initialized from the repository at our
1393
+ submodule path
1384
1394
1385
1395
:raise git.exc.InvalidGitRepositoryError:
1386
1396
If a repository was not available.
@@ -1401,7 +1411,7 @@ def module(self) -> "Repo":
1401
1411
def module_exists (self ) -> bool :
1402
1412
"""
1403
1413
:return:
1404
- True if our module exists and is a valid git repository.
1414
+ `` True`` if our module exists and is a valid git repository.
1405
1415
See the :meth:`module` method.
1406
1416
"""
1407
1417
try :
@@ -1414,7 +1424,7 @@ def module_exists(self) -> bool:
1414
1424
def exists (self ) -> bool :
1415
1425
"""
1416
1426
:return:
1417
- True if the submodule exists, False otherwise.
1427
+ `` True`` if the submodule exists, `` False`` otherwise.
1418
1428
Please note that a submodule may exist (in the ``.gitmodules`` file) even
1419
1429
though its module doesn't exist on disk.
1420
1430
"""
@@ -1480,14 +1490,15 @@ def branch_name(self) -> str:
1480
1490
1481
1491
@property
1482
1492
def url (self ) -> str :
1483
- """:return: The url to the repository which our module - repository refers to"""
1493
+ """:return: The url to the repository our submodule's repository refers to"""
1484
1494
return self ._url
1485
1495
1486
1496
@property
1487
1497
def parent_commit (self ) -> "Commit_ish" :
1488
1498
"""
1489
1499
:return:
1490
- Commit instance with the tree containing the ``.gitmodules`` file
1500
+ :class:`~git.objects.commit.Commit` instance with the tree containing the
1501
+ ``.gitmodules`` file
1491
1502
1492
1503
:note:
1493
1504
Will always point to the current head's commit if it was not set explicitly.
@@ -1531,8 +1542,9 @@ def config_reader(self) -> SectionConstraint[SubmoduleConfigParser]:
1531
1542
def children (self ) -> IterableList ["Submodule" ]:
1532
1543
"""
1533
1544
:return:
1534
- IterableList(Submodule, ...) An iterable list of submodules instances which
1535
- are children of this submodule or 0 if the submodule is not checked out.
1545
+ IterableList(Submodule, ...) An iterable list of :class:`Submodule`
1546
+ instances which are children of this submodule or 0 if the submodule is not
1547
+ checked out.
1536
1548
"""
1537
1549
return self ._get_intermediate_items (self )
1538
1550
0 commit comments