def test_newthings_coming_down(originpath, destpath): origin = GitRepo(originpath, create=True) create_tree(originpath, {'load.dat': 'heavy'}) Dataset(originpath).save('load.dat') ds = install(source=originpath, path=destpath, result_xfm='datasets', return_type='item-or-list') assert_is_instance(ds.repo, GitRepo) assert_in('origin', ds.repo.get_remotes()) # turn origin into an annex origin = AnnexRepo(originpath, create=True) # clone doesn't know yet assert_false(knows_annex(ds.path)) # but after an update it should # no merge, only one sibling, no parameters should be specific enough assert_result_count(ds.update(), 1, status='ok', type='dataset') assert (knows_annex(ds.path)) # no branches appeared eq_(ds.repo.get_branches(), [DEFAULT_BRANCH]) # now merge, and get an annex assert_result_count(ds.update(merge=True), 1, action='update', status='ok', type='dataset') assert_in('git-annex', ds.repo.get_branches()) assert_is_instance(ds.repo, AnnexRepo) # should be fully functional testfname = opj(ds.path, 'load.dat') assert_false(ds.repo.file_has_content(testfname)) ds.get('.') ok_file_has_content(opj(ds.path, 'load.dat'), 'heavy') # check that a new tag comes down origin.tag('first!') assert_result_count(ds.update(), 1, status='ok', type='dataset') eq_(ds.repo.get_tags(output='name')[0], 'first!') # and now we destroy the remote annex origin.call_git(['config', '--remove-section', 'annex']) rmtree(opj(origin.path, '.git', 'annex'), chmod_files=True) origin.call_git(['branch', '-D', 'git-annex']) origin = GitRepo(originpath) assert_false(knows_annex(originpath)) # and update the local clone # for now this should simply not fail (see gh-793), later might be enhanced to a # graceful downgrade before_branches = ds.repo.get_branches() assert_result_count(ds.update(), 1, status='ok', type='dataset') eq_(before_branches, ds.repo.get_branches()) # annex branch got pruned eq_(['origin/HEAD', 'origin/' + DEFAULT_BRANCH], ds.repo.get_remote_branches()) # check that a new tag comes down even if repo types mismatch origin.tag('second!') assert_result_count(ds.update(), 1, status='ok', type='dataset') eq_(ds.repo.get_tags(output='name')[-1], 'second!')
def test_newthings_coming_down(originpath, destpath): origin = GitRepo(originpath, create=True) create_tree(originpath, {'load.dat': 'heavy'}) Dataset(originpath).save('load.dat') ds = install( source=originpath, path=destpath, result_xfm='datasets', return_type='item-or-list') assert_is_instance(ds.repo, GitRepo) assert_in('origin', ds.repo.get_remotes()) # turn origin into an annex origin = AnnexRepo(originpath, create=True) # clone doesn't know yet assert_false(knows_annex(ds.path)) # but after an update it should # no merge, only one sibling, no parameters should be specific enough assert_result_count(ds.update(), 1, status='ok', type='dataset') assert(knows_annex(ds.path)) # no branches appeared eq_(ds.repo.get_branches(), ['master']) # now merge, and get an annex assert_result_count(ds.update(merge=True), 1, status='ok', type='dataset') assert_in('git-annex', ds.repo.get_branches()) assert_is_instance(ds.repo, AnnexRepo) # should be fully functional testfname = opj(ds.path, 'load.dat') assert_false(ds.repo.file_has_content(testfname)) ds.get('.') ok_file_has_content(opj(ds.path, 'load.dat'), 'heavy') # check that a new tag comes down origin.tag('first!') assert_result_count(ds.update(), 1, status='ok', type='dataset') eq_(ds.repo.get_tags(output='name')[0], 'first!') # and now we destroy the remote annex origin._git_custom_command([], ['git', 'config', '--remove-section', 'annex']) rmtree(opj(origin.path, '.git', 'annex'), chmod_files=True) origin._git_custom_command([], ['git', 'branch', '-D', 'git-annex']) origin = GitRepo(originpath) assert_false(knows_annex(originpath)) # and update the local clone # for now this should simply not fail (see gh-793), later might be enhanced to a # graceful downgrade before_branches = ds.repo.get_branches() assert_result_count(ds.update(), 1, status='ok', type='dataset') eq_(before_branches, ds.repo.get_branches()) # annex branch got pruned eq_(['origin/HEAD', 'origin/master'], ds.repo.get_remote_branches()) # check that a new tag comes down even if repo types mismatch origin.tag('second!') assert_result_count(ds.update(), 1, status='ok', type='dataset') eq_(ds.repo.get_tags(output='name')[-1], 'second!')
def test_get_tags(path): from mock import patch gr = GitRepo(path, create=True) eq_(gr.get_tags(), []) eq_(gr.describe(), None) # Explicitly override the committer date because tests may set it to a # fixed value, but we want to check that the returned tags are sorted by # the committer date. with patch.dict("os.environ", {"GIT_COMMITTER_DATE": "Thu, 07 Apr 2005 22:13:13 +0200"}): create_tree(gr.path, {'file': ""}) gr.add('file') gr.commit(msg="msg") eq_(gr.get_tags(), []) eq_(gr.describe(), None) gr.tag("nonannotated") tags1 = [{'name': 'nonannotated', 'hexsha': gr.get_hexsha()}] eq_(gr.get_tags(), tags1) eq_(gr.describe(), None) eq_(gr.describe(tags=True), tags1[0]['name']) first_commit = gr.get_hexsha() with patch.dict("os.environ", {"GIT_COMMITTER_DATE": "Fri, 08 Apr 2005 22:13:13 +0200"}): create_tree(gr.path, {'file': "123"}) gr.add('file') gr.commit(msg="changed") gr.tag("annotated", message="annotation") tags2 = tags1 + [{'name': 'annotated', 'hexsha': gr.get_hexsha()}] eq_(gr.get_tags(), tags2) eq_(gr.describe(), tags2[1]['name']) # compare prev commit eq_(gr.describe(commitish=first_commit), None) eq_(gr.describe(commitish=first_commit, tags=True), tags1[0]['name'])
def test_get_tags(path): from mock import patch gr = GitRepo(path, create=True) eq_(gr.get_tags(), []) eq_(gr.describe(), None) # Explicitly override the committer date because tests may set it to a # fixed value, but we want to check that the returned tags are sorted by # the committer date. with patch.dict("os.environ", {"GIT_COMMITTER_DATE": "Thu, 07 Apr 2005 22:13:13 +0200"}): create_tree(gr.path, {'file': ""}) gr.add('file') gr.commit(msg="msg") eq_(gr.get_tags(), []) eq_(gr.describe(), None) gr.tag("nonannotated") tags1 = [{'name': 'nonannotated', 'hexsha': gr.get_hexsha()}] eq_(gr.get_tags(), tags1) eq_(gr.describe(), None) eq_(gr.describe(tags=True), tags1[0]['name']) first_commit = gr.get_hexsha() with patch.dict("os.environ", {"GIT_COMMITTER_DATE": "Fri, 08 Apr 2005 22:13:13 +0200"}): create_tree(gr.path, {'file': "123"}) gr.add('file') gr.commit(msg="changed") gr.tag("annotated", message="annotation") tags2 = tags1 + [{'name': 'annotated', 'hexsha': gr.get_hexsha()}] eq_(gr.get_tags(), tags2) eq_(gr.describe(), tags2[1]['name']) # compare prev commit eq_(gr.describe(commitish=first_commit), None) eq_(gr.describe(commitish=first_commit, tags=True), tags1[0]['name'])
def test_get_hexsha_tag(path): gr = GitRepo(path, create=True) gr.commit(msg="msg", options=["--allow-empty"]) gr.tag("atag", message="atag msg") # get_hexsha() dereferences a tag to a commit. eq_(gr.get_hexsha("atag"), gr.get_hexsha())
def test_get_hexsha_tag(path): gr = GitRepo(path, create=True) gr.commit(msg="msg", options=["--allow-empty"]) gr.tag("atag", message="atag msg") # get_hexsha() dereferences a tag to a commit. eq_(gr.get_hexsha("atag"), gr.get_hexsha())