def test_GitRepo_gitignore(path): gr = GitRepo(path, create=True) sub = GitRepo(op.join(path, 'ignore-sub.me')) from ..exceptions import GitIgnoreError with open(op.join(path, '.gitignore'), "w") as f: f.write("*.me") with assert_raises(GitIgnoreError) as cme: gr.add('ignore.me') eq_(cme.exception.paths, ['ignore.me']) with assert_raises(GitIgnoreError) as cme: gr.add_submodule(path='ignore-sub.me') eq_(cme.exception.paths, ['ignore-sub.me']) with assert_raises(GitIgnoreError) as cme: gr.add([ 'ignore.me', 'dontigno.re', op.join('ignore-sub.me', 'a_file.txt') ]) eq_(set(cme.exception.paths), {'ignore.me', 'ignore-sub.me'}) eq_(gr.get_gitattributes('.')['.'], {}) # nothing is recorded within .gitattributes
def test_GitRepo_gitignore(path): gr = GitRepo(path, create=True) sub = GitRepo(op.join(path, 'ignore-sub.me')) # we need to commit something, otherwise add_submodule # will already refuse the submodule for having no commit sub.add('a_file.txt') sub.commit() from ..exceptions import GitIgnoreError with open(op.join(path, '.gitignore'), "w") as f: f.write("*.me") with assert_raises(GitIgnoreError) as cme: gr.add('ignore.me') eq_(cme.exception.paths, ['ignore.me']) with assert_raises(GitIgnoreError) as cme: gr.add_submodule(path='ignore-sub.me') eq_(cme.exception.paths, ['ignore-sub.me']) with assert_raises(GitIgnoreError) as cme: gr.add(['ignore.me', 'dontigno.re', op.join('ignore-sub.me', 'a_file.txt')]) eq_(set(cme.exception.paths), {'ignore.me', 'ignore-sub.me'}) eq_(gr.get_gitattributes('.')['.'], {}) # nothing is recorded within .gitattributes
def test_GitRepo_add_submodule(source, path): top_repo = GitRepo(path, create=True) top_repo.add_submodule('sub', name='sub', url=source) top_repo.commit('submodule added') eq_([s.name for s in top_repo.get_submodules()], ['sub']) ok_clean_git(path) ok_clean_git(op.join(path, 'sub'))