Esempio n. 1
0
def test_check_none_result(tmpdir, Jagare):
    path = tmpdir.strpath
    JagareRepo.init(path, bare=True)

    try:
        sha = Jagare.resolve_commit(path, 'master')
    except Exception as e:
        assert type(e) in (NoneResult, NoneResultMock)
Esempio n. 2
0
File: mixes.py Progetto: CMGS/jagare
def init(name):
    repository_path = os.path.join(config.REPOS_PATH, name)
    repository_path = endwith_git(repository_path)

    repository_exist = is_repository(repository_path)

    if repository_exist:
        raise JagareError("repository already exists.", 409)

    Jagare.init(repository_path)

    return make_message_response("initialize success")
Esempio n. 3
0
def test_merge(tmpdir, no_ff, Jagare):
    path = tmpdir.strpath
    git_dir = os.path.join(path, '.git')

    # `git merge` must be run in a work tree
    t_repo = JagareRepo.init(git_dir,
                             work_path=path, bare=False)
    temp_repo.commit_something(git_dir, file_name='git_init')

    BR = 'br_test_merge'

    ret = t_repo.create_branch(BR, 'master')
    assert ret is True
    sha1 = t_repo.sha('master')

    temp_repo.commit_something(path, branch=BR)

    ret = Jagare.merge(path, ref=BR, msg=None, commit_msg=None,
                       no_ff=no_ff, env=None)
    sha2 = t_repo.sha('master')

    assert sha1 != sha2
    assert t_repo.sha(sha1) == sha1

    assert ret.stdout
    assert ret.stderr == ''
    assert ret.fullcmd
    assert ret.returncode == 0
Esempio n. 4
0
def test_merge_head(tmpdir, Jagare):
    path = tmpdir.strpath
    git_dir = os.path.join(path, '.git')

    # `git merge` must be run in a work tree
    t_repo = JagareRepo.init(git_dir,
                             work_path=path, bare=False)
    temp_repo.commit_something(git_dir, file_name='git_init')

    BR = 'br_test_merge'

    ret = t_repo.create_branch(BR, 'master')
    assert ret is True
    sha1 = t_repo.sha('master')

    temp_repo.commit_something(path, branch=BR)

    ret = Jagare.merge_head(path, BR)
    # sha2 = t_repo.sha('master')

    # assert sha1 != sha2
    assert t_repo.sha(sha1) == sha1

    assert ret.is_fastforward is True
    assert ret.fastforward_oid
    assert ret.is_uptodate is False
Esempio n. 5
0
def test_merge_head(tmpdir, Jagare):
    path = tmpdir.strpath
    git_dir = os.path.join(path, '.git')

    # `git merge` must be run in a work tree
    t_repo = JagareRepo.init(git_dir, work_path=path, bare=False)
    temp_repo.commit_something(git_dir, file_name='git_init')

    BR = 'br_test_merge'

    ret = t_repo.create_branch(BR, 'master')
    assert ret is True
    sha1 = t_repo.sha('master')

    temp_repo.commit_something(path, branch=BR)

    ret = Jagare.merge_head(path, BR)
    # sha2 = t_repo.sha('master')

    # assert sha1 != sha2
    assert t_repo.sha(sha1) == sha1

    assert ret.is_fastforward is True
    assert ret.fastforward_oid
    assert ret.is_uptodate is False
Esempio n. 6
0
def test_merge(tmpdir, no_ff, Jagare):
    path = tmpdir.strpath
    git_dir = os.path.join(path, '.git')

    # `git merge` must be run in a work tree
    t_repo = JagareRepo.init(git_dir, work_path=path, bare=False)
    temp_repo.commit_something(git_dir, file_name='git_init')

    BR = 'br_test_merge'

    ret = t_repo.create_branch(BR, 'master')
    assert ret is True
    sha1 = t_repo.sha('master')

    temp_repo.commit_something(path, branch=BR)

    ret = Jagare.merge(path,
                       ref=BR,
                       msg=None,
                       commit_msg=None,
                       no_ff=no_ff,
                       env=None)
    sha2 = t_repo.sha('master')

    assert sha1 != sha2
    assert t_repo.sha(sha1) == sha1

    assert ret.stdout
    assert ret.stderr == ''
    assert ret.fullcmd
    assert ret.returncode == 0
Esempio n. 7
0
 def test_bare(self):
     self.clean()
     repo = Jagare.init(self.path, bare=True)
     pygit2_repo = Repository(self.path)
     assert is_repository(self.path) is True
     assert repo.empty is True
     assert repo.bare is True
     assert pygit2_repo.is_empty is True
     assert pygit2_repo.is_bare is True
Esempio n. 8
0
 def test_empty(self):
     self.clean()
     repo = Jagare.init(self.path, work_path=self.path)
     pygit2_repo = Repository(self.path)
     assert is_repository(self.path) is True
     assert repo.empty is True
     assert repo.bare is False
     assert pygit2_repo.is_empty is True
     assert pygit2_repo.is_bare is False
Esempio n. 9
0
 def test_bare(self):
     self.clean()
     repo = Jagare.init(self.path, bare=True)
     pygit2_repo = Repository(self.path)
     assert is_repository(self.path) is True
     assert repo.empty is True
     assert repo.bare is True
     assert pygit2_repo.is_empty is True
     assert pygit2_repo.is_bare is True
Esempio n. 10
0
 def test_empty(self):
     self.clean()
     repo = Jagare.init(self.path, work_path=self.path)  # git_dir == work_tree ??
     pygit2_repo = Repository(self.path)
     assert is_repository(self.path) is True
     assert repo.empty is True
     assert repo.bare is False
     assert pygit2_repo.is_empty is True
     assert pygit2_repo.is_bare is False
Esempio n. 11
0
    def test_push(self):
        repo = Jagare(self.path)

        path2 = self.get_temp_path()
        repo2 = Jagare.init(path2, bare=True)
        assert repo2.empty

        repo.add_remote('origin', repo2.path)
        repo.push('origin', 'master')
        assert not repo2.empty
Esempio n. 12
0
    def test_push(self):
        repo = Jagare(self.path)

        path2 = self.get_temp_path()
        repo2 = Jagare.init(path2, bare=True)
        assert repo2.empty

        repo.add_remote('origin', repo2.path)
        repo.push('origin', 'master')
        assert not repo2.empty
Esempio n. 13
0
 def init(self, to_path, work_path, is_bare):
     try:
         to_repo = Jagare.init(path=to_path, work_path=work_path,
                               bare=is_bare)
         return Repository(path=to_repo.path,
                           is_empty=to_repo.empty,
                           is_bare=to_repo.bare,
                           workdir=to_repo.repository.workdir,
                           head=to_repo.head and to_repo.head.name)
     except Exception as e:
         raise ServiceUnavailable(repr(e))
Esempio n. 14
0
 def init(self, to_path, work_path, is_bare):
     try:
         to_repo = Jagare.init(path=to_path,
                               work_path=work_path,
                               bare=is_bare)
         return Repository(path=to_repo.path,
                           is_empty=to_repo.empty,
                           is_bare=to_repo.bare,
                           workdir=to_repo.repository.workdir,
                           head=to_repo.head and to_repo.head.name)
     except Exception as e:
         raise ServiceUnavailable(repr(e))
Esempio n. 15
0
def test_push(tmpdir, Jagare):
    path = tmpdir.mkdir('source').strpath
    path2 = tmpdir.mkdir('target').strpath
    repo = temp_repo.create_temp_repo(path, is_bare=True)

    repo2 = JagareRepo.init(path2, bare=True)
    assert repo2.empty is True

    repo.add_remote('origin', repo2.path)
    ret = Jagare.push(path, 'origin', 'master', env={})
    assert not repo2.empty

    assert ret.stdout is not None  # why stdout == ''
    assert ret.stderr is not None  # why stderr != ''
    assert ret.fullcmd
    assert ret.returncode == 0
Esempio n. 16
0
def create_temp_repo(path, is_bare=True):
    repo = Jagare.init(path, bare=is_bare)

    data = [('test_file',
             """test_content
             test_content
             test_content
             """,
             'insert')]

    repo.commit_file(branch='master',
                     parent='master',
                     author_name='testuser',
                     author_email='*****@*****.**',
                     message='first commit',
                     reflog='commit one file',
                     data=data)

    return repo
Esempio n. 17
0
File: repo.py Progetto: banjin/code
 def init(self):
     path = os.path.join(self.temp_dir, '.git')
     work_path = self.temp_dir
     return Jagare.init(path, work_path=work_path, bare=False)
Esempio n. 18
0
File: repo.py Progetto: banjin/code
 def init(cls, gist):
     Jagare.init(gist.repo_path, bare=True)
Esempio n. 19
0
File: repo.py Progetto: banjin/code
 def init(cls, path, work_path=None, bare=True):
     return Jagare.init(path, work_path=work_path, bare=bare)
Esempio n. 20
0
 def init(self):
     path = os.path.join(self.temp_dir, '.git')
     work_path = self.temp_dir
     return Jagare.init(path, work_path=work_path, bare=False)
Esempio n. 21
0
 def init(cls, gist):
     Jagare.init(gist.repo_path, bare=True)
Esempio n. 22
0
 def init(cls, path, work_path=None, bare=True):
     return Jagare.init(path, work_path=work_path, bare=bare)
Esempio n. 23
0
    def init(self):
        import os

        path = os.path.join(self.temp_dir, ".git")
        work_path = self.temp_dir
        return Jagare.init(path, work_path=work_path, bare=False)