{"action":"created","comment":{"url":"https://api.github.com/repos/datalad/datalad/pulls/comments/77333456","id":77333456,"diff_hunk":"@@ -0,0 +1,82 @@\n+# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-\n+# ex: set sts=4 ts=4 sw=4 noet:\n+# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n+#\n+#   See COPYING file distributed along with the datalad package for the\n+#   copyright and license terms.\n+#\n+# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n+\"\"\"Test dirty dataset handling\n+\n+\"\"\"\n+\n+__docformat__ = 'restructuredtext'\n+\n+from os.path import join as opj\n+from nose.tools import assert_raises, assert_equal\n+from datalad.tests.utils import with_tempfile, assert_not_equal\n+from datalad.interface.utils import handle_dirty_dataset\n+from datalad.distribution.dataset import Dataset\n+\n+_dirty_modes = ('fail', 'ignore', 'save-before')\n+\n+\n+def _check_all_clean(ds, state):\n+    assert state is not None\n+    for mode in _dirty_modes:\n+        # nothing wrong, nothing saved\n+        handle_dirty_dataset(ds, mode)\n+        assert_equal(state, ds.repo.get_hexsha())\n+\n+\n+def _check_auto_save(ds, orig_state):\n+    handle_dirty_dataset(ds, 'ignore')\n+    assert_raises(RuntimeError, handle_dirty_dataset, ds, 'fail')\n+    handle_dirty_dataset(ds, 'save-before')\n+    state = ds.repo.get_hexsha()\n+    assert_not_equal(orig_state, state)\n+    _check_all_clean(ds, state)\n+    return state\n+\n+\n+@with_tempfile(mkdir=True)\n+def test_dirty(path):\n+    for mode in _dirty_modes:\n+        # does nothing without a dataset\n+        handle_dirty_dataset(None, mode)\n+    # placeholder, but not yet created\n+    ds = Dataset(path)\n+    # unknown mode\n+    assert_raises(ValueError, handle_dirty_dataset, ds, 'MADEUP')\n+    # not yet created is very dirty\n+    assert_raises(RuntimeError, handle_dirty_dataset, ds, 'fail')\n+    handle_dirty_dataset(ds, 'ignore')\n+    assert_raises(RuntimeError, handle_dirty_dataset, ds, 'save-before')\n+    # should yield a clean repo\n+    ds.create()\n+    orig_state = ds.repo.get_hexsha()\n+    _check_all_clean(ds, orig_state)\n+    # tainted: untracked\n+    with open(opj(ds.path, 'something'), 'w') as f:\n+        f.write('some')\n+    orig_state = _check_auto_save(ds, orig_state)\n+    # tainted: staged\n+    with open(opj(ds.path, 'staged'), 'w') as f:\n+        f.write('some')\n+    ds.repo.add('staged', git=True)\n+    orig_state = _check_auto_save(ds, orig_state)\n+    # tainted: submodule\n+    # not added to super on purpose!\n+    subds = Dataset(opj(ds.path, 'subds')).create(add_to_super=False)\n+    _check_all_clean(subds, subds.repo.get_hexsha())\n+    orig_state = _check_auto_save(ds, orig_state)\n+    # XXX surprisingly this is added as a submodule, but there is no .gitmodules\n+    # which confused even Git itself (git submodule call now fails with\n+    # \"fatal: no submodule mapping found in .gitmodules for path 'subds'\"","path":"datalad/interface/tests/test_utils.py","position":75,"original_position":75,"commit_id":"1b8f375b15d65f6ab745ff547303f7013697da2e","original_commit_id":"1b8f375b15d65f6ab745ff547303f7013697da2e","user":{"login":"bpoldrack","id":10498301,"avatar_url":"https://avatars.githubusercontent.com/u/10498301?v=3","gravatar_id":"","url":"https://api.github.com/users/bpoldrack","html_url":"https://github.com/bpoldrack","followers_url":"https://api.github.com/users/bpoldrack/followers","following_url":"https://api.github.com/users/bpoldrack/following{/other_user}","gists_url":"https://api.github.com/users/bpoldrack/gists{/gist_id}","starred_url":"https://api.github.com/users/bpoldrack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpoldrack/subscriptions","organizations_url":"https://api.github.com/users/bpoldrack/orgs","repos_url":"https://api.github.com/users/bpoldrack/repos","events_url":"https://api.github.com/users/bpoldrack/events{/privacy}","received_events_url":"https://api.github.com/users/bpoldrack/received_events","type":"User","site_admin":false},"body":"Hold on. I cannot reproduce it manually via cmdline. So maybe this is not a funny behaviour of git, but a bug in `datalad create` ...","created_at":"2016-09-02T11:47:14Z","updated_at":"2016-09-02T11:47:14Z","html_url":"https://github.com/datalad/datalad/pull/752#discussion_r77333456","pull_request_url":"https://api.github.com/repos/datalad/datalad/pulls/752","_links":{"self":{"href":"https://api.github.com/repos/datalad/datalad/pulls/comments/77333456"},"html":{"href":"https://github.com/datalad/datalad/pull/752#discussion_r77333456"},"pull_request":{"href":"https://api.github.com/repos/datalad/datalad/pulls/752"}}},"pull_request":{"url":"https://api.github.com/repos/datalad/datalad/pulls/752","id":83756066,"html_url":"https://github.com/datalad/datalad/pull/752","diff_url":"https://github.com/datalad/datalad/pull/752.diff","patch_url":"https://github.com/datalad/datalad/pull/752.patch","issue_url":"https://api.github.com/repos/datalad/datalad/issues/752","number":752,"state":"open","locked":false,"title":"NF: handle_dirty_dataset()","user":{"login":"mih","id":136479,"avatar_url":"https://avatars.githubusercontent.com/u/136479?v=3","gravatar_id":"","url":"https://api.github.com/users/mih","html_url":"https://github.com/mih","followers_url":"https://api.github.com/users/mih/followers","following_url":"https://api.github.com/users/mih/following{/other_user}","gists_url":"https://api.github.com/users/mih/gists{/gist_id}","starred_url":"https://api.github.com/users/mih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mih/subscriptions","organizations_url":"https://api.github.com/users/mih/orgs","repos_url":"https://api.github.com/users/mih/repos","events_url":"https://api.github.com/users/mih/events{/privacy}","received_events_url":"https://api.github.com/users/mih/received_events","type":"User","site_admin":false},"body":"Check tests inside -- food for thought re subdataset treatment!","created_at":"2016-09-02T07:20:53Z","updated_at":"2016-09-02T11:47:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"635f5ce6972bca1a1d076b50f59e96d5be12097c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/datalad/datalad/pulls/752/commits","review_comments_url":"https://api.github.com/repos/datalad/datalad/pulls/752/comments","review_comment_url":"https://api.github.com/repos/datalad/datalad/pulls/comments{/number}","comments_url":"https://api.github.com/repos/datalad/datalad/issues/752/comments","statuses_url":"https://api.github.com/repos/datalad/datalad/statuses/1b8f375b15d65f6ab745ff547303f7013697da2e","head":{"label":"mih:nf-dealwithdirty","ref":"nf-dealwithdirty","sha":"1b8f375b15d65f6ab745ff547303f7013697da2e","user":{"login":"mih","id":136479,"avatar_url":"https://avatars.githubusercontent.com/u/136479?v=3","gravatar_id":"","url":"https://api.github.com/users/mih","html_url":"https://github.com/mih","followers_url":"https://api.github.com/users/mih/followers","following_url":"https://api.github.com/users/mih/following{/other_user}","gists_url":"https://api.github.com/users/mih/gists{/gist_id}","starred_url":"https://api.github.com/users/mih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mih/subscriptions","organizations_url":"https://api.github.com/users/mih/orgs","repos_url":"https://api.github.com/users/mih/repos","events_url":"https://api.github.com/users/mih/events{/privacy}","received_events_url":"https://api.github.com/users/mih/received_events","type":"User","site_admin":false},"repo":{"id":34503646,"name":"datalad","full_name":"mih/datalad","owner":{"login":"mih","id":136479,"avatar_url":"https://avatars.githubusercontent.com/u/136479?v=3","gravatar_id":"","url":"https://api.github.com/users/mih","html_url":"https://github.com/mih","followers_url":"https://api.github.com/users/mih/followers","following_url":"https://api.github.com/users/mih/following{/other_user}","gists_url":"https://api.github.com/users/mih/gists{/gist_id}","starred_url":"https://api.github.com/users/mih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mih/subscriptions","organizations_url":"https://api.github.com/users/mih/orgs","repos_url":"https://api.github.com/users/mih/repos","events_url":"https://api.github.com/users/mih/events{/privacy}","received_events_url":"https://api.github.com/users/mih/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mih/datalad","description":"Keep scientific data under control by git  and git-annex","fork":true,"url":"https://api.github.com/repos/mih/datalad","forks_url":"https://api.github.com/repos/mih/datalad/forks","keys_url":"https://api.github.com/repos/mih/datalad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mih/datalad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mih/datalad/teams","hooks_url":"https://api.github.com/repos/mih/datalad/hooks","issue_events_url":"https://api.github.com/repos/mih/datalad/issues/events{/number}","events_url":"https://api.github.com/repos/mih/datalad/events","assignees_url":"https://api.github.com/repos/mih/datalad/assignees{/user}","branches_url":"https://api.github.com/repos/mih/datalad/branches{/branch}","tags_url":"https://api.github.com/repos/mih/datalad/tags","blobs_url":"https://api.github.com/repos/mih/datalad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mih/datalad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mih/datalad/git/refs{/sha}","trees_url":"https://api.github.com/repos/mih/datalad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mih/datalad/statuses/{sha}","languages_url":"https://api.github.com/repos/mih/datalad/languages","stargazers_url":"https://api.github.com/repos/mih/datalad/stargazers","contributors_url":"https://api.github.com/repos/mih/datalad/contributors","subscribers_url":"https://api.github.com/repos/mih/datalad/subscribers","subscription_url":"https://api.github.com/repos/mih/datalad/subscription","commits_url":"https://api.github.com/repos/mih/datalad/commits{/sha}","git_commits_url":"https://api.github.com/repos/mih/datalad/git/commits{/sha}","comments_url":"https://api.github.com/repos/mih/datalad/comments{/number}","issue_comment_url":"https://api.github.com/repos/mih/datalad/issues/comments{/number}","contents_url":"https://api.github.com/repos/mih/datalad/contents/{+path}","compare_url":"https://api.github.com/repos/mih/datalad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mih/datalad/merges","archive_url":"https://api.github.com/repos/mih/datalad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mih/datalad/downloads","issues_url":"https://api.github.com/repos/mih/datalad/issues{/number}","pulls_url":"https://api.github.com/repos/mih/datalad/pulls{/number}","milestones_url":"https://api.github.com/repos/mih/datalad/milestones{/number}","notifications_url":"https://api.github.com/repos/mih/datalad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mih/datalad/labels{/name}","releases_url":"https://api.github.com/repos/mih/datalad/releases{/id}","deployments_url":"https://api.github.com/repos/mih/datalad/deployments","created_at":"2015-04-24T07:11:39Z","updated_at":"2016-02-23T15:27:28Z","pushed_at":"2016-09-02T07:22:19Z","git_url":"git://github.com/mih/datalad.git","ssh_url":"git@github.com:mih/datalad.git","clone_url":"https://github.com/mih/datalad.git","svn_url":"https://github.com/mih/datalad","homepage":null,"size":4837,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"datalad:master","ref":"master","sha":"4755adb00e94b7d9c7070b0d71f6278c507ea731","user":{"login":"datalad","id":8927200,"avatar_url":"https://avatars.githubusercontent.com/u/8927200?v=3","gravatar_id":"","url":"https://api.github.com/users/datalad","html_url":"https://github.com/datalad","followers_url":"https://api.github.com/users/datalad/followers","following_url":"https://api.github.com/users/datalad/following{/other_user}","gists_url":"https://api.github.com/users/datalad/gists{/gist_id}","starred_url":"https://api.github.com/users/datalad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datalad/subscriptions","organizations_url":"https://api.github.com/users/datalad/orgs","repos_url":"https://api.github.com/users/datalad/repos","events_url":"https://api.github.com/users/datalad/events{/privacy}","received_events_url":"https://api.github.com/users/datalad/received_events","type":"Organization","site_admin":false},"repo":{"id":14052034,"name":"datalad","full_name":"datalad/datalad","owner":{"login":"datalad","id":8927200,"avatar_url":"https://avatars.githubusercontent.com/u/8927200?v=3","gravatar_id":"","url":"https://api.github.com/users/datalad","html_url":"https://github.com/datalad","followers_url":"https://api.github.com/users/datalad/followers","following_url":"https://api.github.com/users/datalad/following{/other_user}","gists_url":"https://api.github.com/users/datalad/gists{/gist_id}","starred_url":"https://api.github.com/users/datalad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datalad/subscriptions","organizations_url":"https://api.github.com/users/datalad/orgs","repos_url":"https://api.github.com/users/datalad/repos","events_url":"https://api.github.com/users/datalad/events{/privacy}","received_events_url":"https://api.github.com/users/datalad/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/datalad/datalad","description":"Keep scientific data under control with git  and git-annex","fork":false,"url":"https://api.github.com/repos/datalad/datalad","forks_url":"https://api.github.com/repos/datalad/datalad/forks","keys_url":"https://api.github.com/repos/datalad/datalad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datalad/datalad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datalad/datalad/teams","hooks_url":"https://api.github.com/repos/datalad/datalad/hooks","issue_events_url":"https://api.github.com/repos/datalad/datalad/issues/events{/number}","events_url":"https://api.github.com/repos/datalad/datalad/events","assignees_url":"https://api.github.com/repos/datalad/datalad/assignees{/user}","branches_url":"https://api.github.com/repos/datalad/datalad/branches{/branch}","tags_url":"https://api.github.com/repos/datalad/datalad/tags","blobs_url":"https://api.github.com/repos/datalad/datalad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datalad/datalad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datalad/datalad/git/refs{/sha}","trees_url":"https://api.github.com/repos/datalad/datalad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datalad/datalad/statuses/{sha}","languages_url":"https://api.github.com/repos/datalad/datalad/languages","stargazers_url":"https://api.github.com/repos/datalad/datalad/stargazers","contributors_url":"https://api.github.com/repos/datalad/datalad/contributors","subscribers_url":"https://api.github.com/repos/datalad/datalad/subscribers","subscription_url":"https://api.github.com/repos/datalad/datalad/subscription","commits_url":"https://api.github.com/repos/datalad/datalad/commits{/sha}","git_commits_url":"https://api.github.com/repos/datalad/datalad/git/commits{/sha}","comments_url":"https://api.github.com/repos/datalad/datalad/comments{/number}","issue_comment_url":"https://api.github.com/repos/datalad/datalad/issues/comments{/number}","contents_url":"https://api.github.com/repos/datalad/datalad/contents/{+path}","compare_url":"https://api.github.com/repos/datalad/datalad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datalad/datalad/merges","archive_url":"https://api.github.com/repos/datalad/datalad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datalad/datalad/downloads","issues_url":"https://api.github.com/repos/datalad/datalad/issues{/number}","pulls_url":"https://api.github.com/repos/datalad/datalad/pulls{/number}","milestones_url":"https://api.github.com/repos/datalad/datalad/milestones{/number}","notifications_url":"https://api.github.com/repos/datalad/datalad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datalad/datalad/labels{/name}","releases_url":"https://api.github.com/repos/datalad/datalad/releases{/id}","deployments_url":"https://api.github.com/repos/datalad/datalad/deployments","created_at":"2013-11-01T19:40:08Z","updated_at":"2016-08-15T01:13:11Z","pushed_at":"2016-09-02T08:43:20Z","git_url":"git://github.com/datalad/datalad.git","ssh_url":"git@github.com:datalad/datalad.git","clone_url":"https://github.com/datalad/datalad.git","svn_url":"https://github.com/datalad/datalad","homepage":"http://datalad.org","size":8915,"stargazers_count":37,"watchers_count":37,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":167,"forks":9,"open_issues":167,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/datalad/datalad/pulls/752"},"html":{"href":"https://github.com/datalad/datalad/pull/752"},"issue":{"href":"https://api.github.com/repos/datalad/datalad/issues/752"},"comments":{"href":"https://api.github.com/repos/datalad/datalad/issues/752/comments"},"review_comments":{"href":"https://api.github.com/repos/datalad/datalad/pulls/752/comments"},"review_comment":{"href":"https://api.github.com/repos/datalad/datalad/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/datalad/datalad/pulls/752/commits"},"statuses":{"href":"https://api.github.com/repos/datalad/datalad/statuses/1b8f375b15d65f6ab745ff547303f7013697da2e"}}}}
{"actor":{"display_login":"bpoldrack"}}