| 45 | |
| 46 | |
| 47 | class Submodule: |
| 48 | _repo: BaseRepository |
| 49 | _subm: 'GitSubmoduleC' |
| 50 | |
| 51 | @classmethod |
| 52 | def _from_c(cls, repo: BaseRepository, cptr: 'GitSubmoduleC') -> 'Submodule': |
| 53 | subm = cls.__new__(cls) |
| 54 | |
| 55 | subm._repo = repo |
| 56 | subm._subm = cptr |
| 57 | |
| 58 | return subm |
| 59 | |
| 60 | def __del__(self) -> None: |
| 61 | C.git_submodule_free(self._subm) |
| 62 | |
| 63 | def open(self) -> Repository: |
| 64 | """Open the repository for a submodule.""" |
| 65 | crepo = ffi.new('git_repository **') |
| 66 | err = C.git_submodule_open(crepo, self._subm) |
| 67 | check_error(err) |
| 68 | |
| 69 | return self._repo._from_c(crepo[0], True) # type: ignore[attr-defined] |
| 70 | |
| 71 | def init(self, overwrite: bool = False) -> None: |
| 72 | """ |
| 73 | Just like "git submodule init", this copies information about the submodule |
| 74 | into ".git/config". |
| 75 | |
| 76 | Parameters: |
| 77 | |
| 78 | overwrite |
| 79 | By default, existing submodule entries will not be overwritten, |
| 80 | but setting this to True forces them to be updated. |
| 81 | """ |
| 82 | err = C.git_submodule_init(self._subm, int(overwrite)) |
| 83 | check_error(err) |
| 84 | |
| 85 | def update( |
| 86 | self, |
| 87 | init: bool = False, |
| 88 | callbacks: Optional[RemoteCallbacks] = None, |
| 89 | depth: int = 0, |
| 90 | ) -> None: |
| 91 | """ |
| 92 | Update a submodule. This will clone a missing submodule and checkout |
| 93 | the subrepository to the commit specified in the index of the |
| 94 | containing repository. If the submodule repository doesn't contain the |
| 95 | target commit (e.g. because fetchRecurseSubmodules isn't set), then the |
| 96 | submodule is fetched using the fetch options supplied in options. |
| 97 | |
| 98 | Parameters: |
| 99 | |
| 100 | init |
| 101 | If the submodule is not initialized, setting this flag to True will |
| 102 | initialize the submodule before updating. Otherwise, this will raise |
| 103 | an error if attempting to update an uninitialized repository. |
| 104 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…