本文整理汇总了Python中utils.GerritGitUtils.get_branches方法的典型用法代码示例。如果您正苦于以下问题:Python GerritGitUtils.get_branches方法的具体用法?Python GerritGitUtils.get_branches怎么用?Python GerritGitUtils.get_branches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.GerritGitUtils
的用法示例。
在下文中一共展示了GerritGitUtils.get_branches方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_upstream
# 需要导入模块: from utils import GerritGitUtils [as 别名]
# 或者: from utils.GerritGitUtils import get_branches [as 别名]
def test_upstream(self):
""" Validate upstream feature of managesf
"""
# Create a test upstream project
pname_us = 'p_upstream'
self.create_project(pname_us, config.ADMIN_USER)
ggu_us = GerritGitUtils(config.ADMIN_USER,
config.ADMIN_PRIV_KEY_PATH,
config.USERS[config.ADMIN_USER]['email'])
url = "ssh://%[email protected]%s:29418/%s" % (config.ADMIN_USER,
config.GATEWAY_HOST, pname_us)
# clone
us_clone_dir = ggu_us.clone(url, pname_us)
self.dirs_to_delete.append(os.path.dirname(us_clone_dir))
# Test that the clone is a success
self.assertTrue(os.path.isdir(us_clone_dir))
# push some test files to the upstream project
us_files = [str(x) for x in range(1, 10)]
for f in us_files:
file(os.path.join(us_clone_dir, f), 'w').write(f)
os.chmod(os.path.join(us_clone_dir, f), 0755)
ggu_us.add_commit_in_branch(us_clone_dir, "master",
commit="Adding files 1-10",
files=us_files)
ggu_us.direct_push_branch(us_clone_dir, "master")
ggu_us.add_commit_in_branch(us_clone_dir, "branch1")
ggu_us.direct_push_branch(us_clone_dir, "branch1")
# No create a test project with upstream pointing to the above
upstream_url = "ssh://%[email protected]%s:29418/%s" % (
config.ADMIN_USER, config.GATEWAY_HOST, pname_us)
pname = 'p_%s' % create_random_str()
# create the project as admin
options = {"upstream": upstream_url,
"upstream-ssh-key": config.ADMIN_PRIV_KEY_PATH}
self.create_project(pname, config.ADMIN_USER, options=options)
ggu = GerritGitUtils(config.ADMIN_USER,
config.ADMIN_PRIV_KEY_PATH,
config.USERS[config.ADMIN_USER]['email'])
url = "ssh://%[email protected]%s:29418/%s" % (config.ADMIN_USER,
config.GATEWAY_HOST, pname)
# clone
clone_dir = ggu.clone(url, pname)
# Check if the files pushed in upstream project is present
files = [f for f in os.listdir(clone_dir) if not f.startswith('.')]
self.assertEqual(set(files), set(us_files))
branches = ggu.get_branches(clone_dir, True)
self.assertNotIn('gerrit/branch1', branches)
# Test upstream with additional branches
pname2 = 'p_%s' % create_random_str()
options['add-branches'] = ''
self.create_project(pname2, config.ADMIN_USER, options=options)
url = "ssh://%[email protected]%s:29418/%s" % (config.ADMIN_USER,
config.GATEWAY_HOST, pname2)
clone_dir = ggu.clone(url, pname2)
branches = ggu.get_branches(clone_dir, True)
self.assertIn('gerrit/branch1', branches)
self.dirs_to_delete.append(os.path.dirname(clone_dir))