Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BF: Let save -a commit modified submodules too (closes: gh-636) #739

Merged
merged 2 commits into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion datalad/interface/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ def __call__(message=None, files=None, dataset=None,
ds.repo.add(absf)
ds.repo.add(absf, git=True)

# anything should be staged by now
# now however, that staged submodule changes are not considered as
# `index`, hence `submodules` needs to be True too
if ds.repo.repo.is_dirty(
index=True,
working_tree=False,
untracked_files=False,
submodules=False):
submodules=True):
ds.repo.commit(message)
else:
lgr.info(
Expand Down
21 changes: 17 additions & 4 deletions datalad/interface/tests/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
from os.path import join as opj

from datalad.distribution.dataset import Dataset
from datalad.api import create
from datalad.api import save
from datalad.support.annexrepo import AnnexRepo
from datalad.tests.utils import ok_
from datalad import api as _
from datalad.tests.utils import with_testrepos
from datalad.tests.utils import ok_clean_git

Expand All @@ -27,8 +26,6 @@
def test_save(path):

ds = Dataset(path)
if isinstance(ds.repo, AnnexRepo):
ds.repo._init()

with open(opj(path, "new_file.tst"), "w") as f:
f.write("something")
Expand All @@ -54,3 +51,19 @@ def test_save(path):

ds.save("set of new files", files=[opj(path, f) for f in files])
ok_clean_git(path, annex=isinstance(ds.repo, AnnexRepo))

# create subdataset
subds = Dataset(opj(ds.path, 'subds')).create(add_to_super=True)
ok_(ds.repo.dirty)
# auto save it
ds.save(auto_add_changes=True)
ok_clean_git(path, annex=isinstance(ds.repo, AnnexRepo))
# modify subds
with open(opj(subds.path, "some_file.tst"), "w") as f:
f.write("something")
subds.save(auto_add_changes=True)
ok_clean_git(subds.path, annex=isinstance(ds.repo, AnnexRepo))
ok_(ds.repo.dirty)
# ensure modified subds is commited
ds.save(auto_add_changes=True)
ok_clean_git(path, annex=isinstance(ds.repo, AnnexRepo))