| 183 | @utils.requires_network |
| 184 | @pytest.mark.parametrize('depth', [0, 1]) |
| 185 | def test_oneshot_update(repo: Repository, depth: int) -> None: |
| 186 | status = repo.submodules.status(SUBM_NAME) |
| 187 | assert status == (SS.IN_HEAD | SS.IN_INDEX | SS.IN_CONFIG | SS.WD_UNINITIALIZED) |
| 188 | |
| 189 | subrepo_file_path = Path(repo.workdir) / SUBM_PATH / 'master.txt' |
| 190 | assert not subrepo_file_path.exists() |
| 191 | repo.submodules.update(init=True, depth=depth) |
| 192 | assert subrepo_file_path.exists() |
| 193 | |
| 194 | status = repo.submodules.status(SUBM_NAME) |
| 195 | assert status == (SS.IN_HEAD | SS.IN_INDEX | SS.IN_CONFIG | SS.IN_WD) |
| 196 | |
| 197 | sm_repo = repo.submodules[SUBM_NAME].open() |
| 198 | if depth == 0: |
| 199 | sm_repo[SUBM_BOTTOM_SHA] # full history must be available |
| 200 | else: |
| 201 | with pytest.raises(KeyError): |
| 202 | sm_repo[SUBM_BOTTOM_SHA] # shallow clone |
| 203 | |
| 204 | |
| 205 | @utils.requires_network |