1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2026-03-02 03:49:29 +00:00

Change handling of submodules at upgrade

Start with doing "submodule absorbgitdirs" as otherwise "submodule
deinit" will fail if a module has been cloned first and later added as
a submodule (as it will then contain the .git dir instead of it being
under the superprojects .git dir).

Then try to deinit the submodules before moving the repo and abort the
upgrade if it fails for any submodule. Then do the move and finally
initialize the submodules that were initialized before the upgrade.

See #285
This commit is contained in:
Erik Flodin
2021-01-04 00:33:38 +01:00
parent 0675bc9240
commit 5818eeb9dd
2 changed files with 37 additions and 17 deletions

View File

@@ -59,12 +59,16 @@ def test_upgrade(tmpdir, runner, yadm, condition):
yadm_legacy.join(path).write(path, ensure=True)
mock_git = ""
if condition in ['tracked', 'submodules']:
if condition != 'no-paths':
mock_git = f'''
function git() {{
echo "$@"
if [[ "$*" == *.gitmodules* ]]; then
return { '0' if condition == 'submodules' else '1' }
if [[ "$*" = *"submodule status" ]]; then
{ 'echo " 1234567 mymodule (1.0)"'
if condition == 'submodules' else ':' }
fi
if [[ "$*" = *ls-files* ]]; then
return { 1 if condition == 'untracked' else 0 }
fi
return 0
}}
@@ -111,8 +115,9 @@ def test_upgrade(tmpdir, runner, yadm, condition):
assert expected in run.out
assert 'files tracked by yadm have been renamed' in run.out
if condition == 'submodules':
assert 'submodule deinit -f .' in run.out
assert 'submodule update --init --recursive' in run.out
assert 'submodule deinit -- mymodule' in run.out
assert 'submodule update --init --recursive -- mymodule' \
in run.out
else:
assert 'submodule deinit -f .' not in run.out
assert 'submodule deinit' not in run.out
assert 'submodule update --init --recursive' not in run.out