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())
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)
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"
def new_git_bare_repo(): with mkdtemp() as tmpdir: gyt.call(['git', 'init', '--bare', tmpdir]) yield tmpdir
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)
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)
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
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
def test_git_call_error_raise(self): gyt.call(gyt.GIT_EXECUTABLE, 'unexisting___command__')
def test_git_call_with_int_in_list(self): ok = gyt.call([gyt.GIT_EXECUTABLE, 'rev-parse', 123], _raise=False) assert ok == False
def test_git_call_error(self): out = gyt.call( gyt.GIT_EXECUTABLE, 'unexisting___command__', _raise=False) assert out is False
def test_gyt_call_command_as_string(self): out = gyt.call(gyt.GIT_EXECUTABLE, ['help', 'init']) assert 'git init' in out
def test_git_call_version(self): out = gyt.call(gyt.GIT_EXECUTABLE, 'version') assert 'git' in out
def test_git_call_error(self): out = gyt.call(gyt.GIT_EXECUTABLE, 'unexisting___command__', _raise=False) assert out is False