Exemplo n.º 1
0
    def test_is_up_to_date(self):
        """应该能探测是否是已经merge过的"""
        with setup2repos('prj_uptodate') as (path, repo, fork_path, fork_repo):

            with self.clone_clean(path) as work_path:
                with chdir(work_path):
                    gyt.call(['git', 'pull', fork_path])
                    gyt.call(['git', 'push', 'origin', 'master'])

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            ok_(pullreq.is_up_to_date())
Exemplo n.º 2
0
    def test_is_up_to_date(self):
        """应该能探测是否是已经merge过的"""
        with setup2repos('prj_uptodate') as (path, repo, fork_path, fork_repo):

            with self.clone_clean(path) as work_path:
                with chdir(work_path):
                    gyt.call(['git', 'pull', fork_path])
                    gyt.call(['git', 'push', 'origin', 'master'])

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            ok_(pullreq.is_up_to_date())
Exemplo n.º 3
0
    def test_git_check_version(self):
        _, _, ver = gyt.call(gyt.GIT_EXECUTABLE, 'version').split()

        def _ver_num(ver):
            return [int(n) for n in ver.split('.')]

        assert _ver_num(ver) >= _ver_num(gyt.GIT_MIN_VERSION)
Exemplo n.º 4
0
 def test_simple_commit_in_branch_in_subdir(self):
     repo = self._repo('test', bare=False)
     self._commit(repo, 'test/file1', 'content1', 'msg1')
     tmp_branch = repo.temp_branch_name()
     repo.commit_one_file('test/file1', 'content1 modified', 'change1',
                          self.u, orig_hash=hash('content1'),
                          branch=tmp_branch)
     with mkdtemp() as tmpdir:
         gyt.call(['git', 'clone', repo.path, tmpdir])
         repo_check = gyt.repo(tmpdir, bare=False)
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
         repo_check.call('checkout master')
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
         repo_check.call('checkout %s' % tmp_branch)
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1 modified'
         repo_check.call('checkout master')
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
 def test_simple_commit_in_branch_in_subdir(self):
     repo = self._repo("test", bare=False)
     self._commit(repo, "test/file1", "content1", "msg1")
     tmp_branch = repo.temp_branch_name()
     repo.commit_one_file(
         "test/file1", "content1 modified", "change1", self.u, orig_hash=hash("content1"), branch=tmp_branch
     )
     with mkdtemp() as tmpdir:
         gyt.call(["git", "clone", repo.path, tmpdir])
         repo_check = gyt.repo(tmpdir, bare=False)
         src = repo_check.call("show HEAD:test/file1")
         assert src == u"content1"
         repo_check.call("checkout master")
         src = repo_check.call("show HEAD:test/file1")
         assert src == u"content1"
         repo_check.call("checkout %s" % tmp_branch)
         src = repo_check.call("show HEAD:test/file1")
         assert src == u"content1 modified"
         repo_check.call("checkout master")
         src = repo_check.call("show HEAD:test/file1")
         assert src == u"content1"
Exemplo n.º 6
0
 def test_simple_commit_in_branch_in_subdir(self):
     repo = self._repo('test', bare=False)
     self._commit(repo, 'test/file1', 'content1', 'msg1')
     tmp_branch = repo.temp_branch_name()
     repo.commit_one_file('test/file1',
                          'content1 modified',
                          'change1',
                          self.u,
                          orig_hash=hash('content1'),
                          branch=tmp_branch)
     with mkdtemp() as tmpdir:
         gyt.call(['git', 'clone', repo.path, tmpdir])
         repo_check = gyt.repo(tmpdir, bare=False)
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
         repo_check.call('checkout master')
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
         repo_check.call('checkout %s' % tmp_branch)
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1 modified'
         repo_check.call('checkout master')
         src = repo_check.call('show HEAD:test/file1')
         assert src == u'content1'
Exemplo n.º 7
0
def new_git_bare_repo():
    with mkdtemp() as tmpdir:
        gyt.call(['git', 'init', '--bare', tmpdir])
        yield tmpdir
Exemplo n.º 8
0
def clone(git_dir):
    with mkdtemp() as work_path:
        gyt.call(['git', 'clone', git_dir, work_path])
        assert os.path.exists(work_path + '/.git')
        yield work_path

        with chdir(work_path):
            gyt.call(['git', 'config', 'user.name', 'test author'])
            gyt.call(['git', 'config', 'user.email', '*****@*****.**'])
            gyt.call(['git', 'add', "."])
            gyt.call(['git', 'commit', '-m', 'test'], _raise=True)
            gyt.call(['git', 'push', 'origin', 'master'], _raise=True)
Exemplo n.º 9
0
 def test_call_with_unicode(self):
     assert 'aaaaa' == gyt.call(u"echo aaaaa")
     test_str = u"aaaaa太牛了!"
     assert test_str == gyt.call("echo '%s'" % test_str)
Exemplo n.º 10
0
 def xxxxxx_git_call_with_int_in_list(self):
     # BROKEN, maybe no need to fix? TODO
     ok = gyt.call(gyt.GIT_EXECUTABLE, ['rev-parse', 123], _raise=False)
     assert ok == False
Exemplo n.º 11
0
 def clone_clean(self, git_dir):
     with mkdtemp() as work_path:
         gyt.call(['git', 'clone', git_dir, work_path])
         assert os.path.exists(join(work_path, '.git'))
         yield work_path
Exemplo n.º 12
0
    def test_git_check_version(self):
        _, _, ver = gyt.call(gyt.GIT_EXECUTABLE, 'version').split()

        def _ver_num(ver):
            return [int(n) for n in ver.split('.')]
        assert _ver_num(ver) >= _ver_num(gyt.GIT_MIN_VERSION)
Exemplo n.º 13
0
 def test_git_call_error_raise(self):
     gyt.call(gyt.GIT_EXECUTABLE, 'unexisting___command__')
Exemplo n.º 14
0
 def clone_clean(self, git_dir):
     with mkdtemp() as work_path:
         gyt.call(['git', 'clone', git_dir, work_path])
         assert os.path.exists(join(work_path, '.git'))
         yield work_path
Exemplo n.º 15
0
 def xxxxxx_git_call_with_int_in_list(self):
     # BROKEN, maybe no need to fix? TODO
     ok = gyt.call(gyt.GIT_EXECUTABLE, ['rev-parse', 123], _raise=False)
     assert ok == False
Exemplo n.º 16
0
 def test_call_with_unicode(self):
     assert 'aaaaa' == gyt.call(u"echo aaaaa")
     test_str = u"aaaaa太牛了!"
     assert test_str == gyt.call("echo '%s'" % test_str)
Exemplo n.º 17
0
 def test_git_call_with_int_in_list(self):
     ok = gyt.call([gyt.GIT_EXECUTABLE, 'rev-parse', 123], _raise=False)
     assert ok == False
Exemplo n.º 18
0
 def test_git_call_error_raise(self):
     gyt.call(gyt.GIT_EXECUTABLE, 'unexisting___command__')
Exemplo n.º 19
0
 def test_git_call_error(self):
     out = gyt.call(
         gyt.GIT_EXECUTABLE, 'unexisting___command__', _raise=False)
     assert out is False
Exemplo n.º 20
0
def new_git_bare_repo():
    with mkdtemp() as tmpdir:
        gyt.call(['git', 'init', '--bare', tmpdir])
        yield tmpdir
Exemplo n.º 21
0
 def test_gyt_call_command_as_string(self):
     out = gyt.call(gyt.GIT_EXECUTABLE, ['help', 'init'])
     assert 'git init' in out
Exemplo n.º 22
0
def clone(git_dir):
    with mkdtemp() as work_path:
        gyt.call(['git', 'clone', git_dir, work_path])
        assert os.path.exists(work_path + '/.git')
        yield work_path

        with chdir(work_path):
            gyt.call(['git', 'config', 'user.name', 'test author'])
            gyt.call(['git', 'config', 'user.email', '*****@*****.**'])
            gyt.call(['git', 'add', "."])
            gyt.call(['git', 'commit', '-m', 'test'], _raise=True)
            gyt.call(['git', 'push', 'origin', 'master'], _raise=True)
Exemplo n.º 23
0
 def test_git_call_version(self):
     out = gyt.call(gyt.GIT_EXECUTABLE, 'version')
     assert 'git' in out
Exemplo n.º 24
0
 def test_git_call_with_int_in_list(self):
     ok = gyt.call([gyt.GIT_EXECUTABLE, 'rev-parse', 123], _raise=False)
     assert ok == False
Exemplo n.º 25
0
 def test_git_call_error(self):
     out = gyt.call(gyt.GIT_EXECUTABLE,
                    'unexisting___command__',
                    _raise=False)
     assert out is False
Exemplo n.º 26
0
 def test_git_call_version(self):
     out = gyt.call(gyt.GIT_EXECUTABLE, 'version')
     assert 'git' in out
Exemplo n.º 27
0
 def test_gyt_call_command_as_string(self):
     out = gyt.call(gyt.GIT_EXECUTABLE, ['help', 'init'])
     assert 'git init' in out