當前位置: 首頁>>代碼示例>>Python>>正文


Python GitRepo.git_add方法代碼示例

本文整理匯總了Python中datalad.support.gitrepo.GitRepo.git_add方法的典型用法代碼示例。如果您正苦於以下問題:Python GitRepo.git_add方法的具體用法?Python GitRepo.git_add怎麽用?Python GitRepo.git_add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在datalad.support.gitrepo.GitRepo的用法示例。


在下文中一共展示了GitRepo.git_add方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_GitRepo_add

# 需要導入模塊: from datalad.support.gitrepo import GitRepo [as 別名]
# 或者: from datalad.support.gitrepo.GitRepo import git_add [as 別名]
def test_GitRepo_add(src, path):

    gr = GitRepo(path, src)
    filename = "test_git_add.dat"
    with open(os.path.join(path, filename), 'w') as f:
        f.write("File to add to git")
    gr.git_add(filename)

    assert_in(filename, gr.get_indexed_files(), "%s not successfully added to %s" % (filename, path))
開發者ID:jgors,項目名稱:datalad,代碼行數:11,代碼來源:test_gitrepo.py

示例2: test_GitRepo_commit

# 需要導入模塊: from datalad.support.gitrepo import GitRepo [as 別名]
# 或者: from datalad.support.gitrepo.GitRepo import git_add [as 別名]
def test_GitRepo_commit(path):

    gr = GitRepo(path)
    filename = "test_git_add.dat"
    with open(os.path.join(path, filename), 'w') as f:
        f.write("File to add to git")

    gr.git_add(filename)
    gr.git_commit("Testing GitRepo.git_commit().")
    ok_clean_git(path, annex=False, untracked=[])
開發者ID:jgors,項目名稱:datalad,代碼行數:12,代碼來源:test_gitrepo.py

示例3: test_install_plain_git

# 需要導入模塊: from datalad.support.gitrepo import GitRepo [as 別名]
# 或者: from datalad.support.gitrepo.GitRepo import git_add [as 別名]
def test_install_plain_git(src, path):
    # make plain git repo
    gr = GitRepo(src, create=True)
    gr.git_add('test.txt')
    gr.git_commit('demo')
    # now install it somewhere else
    ds = install(path=path, source=src)
    # stays plain Git repo
    ok_(isinstance(ds.repo, GitRepo))
    # now go back to original
    ds = Dataset(src)
    ok_(isinstance(ds.repo, GitRepo))
    # installing a file must fail, as we decided not to perform magical upgrades
    # GitRepo -> AnnexRepo
    assert_raises(RuntimeError, ds.install, path='test2.txt', source=opj(src, 'test2.txt'))
    # but works when forced
    ifiles = ds.install(path='test2.txt', source=opj(src, 'test2.txt'), add_data_to_git=True)
    ok_startswith(ifiles, ds.path)
    ok_(ifiles.endswith('test2.txt'))
    ok_('test2.txt' in ds.repo.get_indexed_files())
開發者ID:glalteva,項目名稱:datalad,代碼行數:22,代碼來源:test_install.py


注:本文中的datalad.support.gitrepo.GitRepo.git_add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。