Как оформить заказ на новую ветку с помощью Pygithub?
Это то, что я узнал,
g = Github("user", "pass")
repoName = "apiTest"
print "Get all repos:"
for repo in g.get_user().get_repos():
print "\t%s" % repo.name
print "<--------------------------------------------------->"
print "Get all branches in repo %s:" % repoName
for branch in g.get_user().get_repo(repoName).get_branches():
print "\t%s" % branch.name
print "<--------------------------------------------------->"
print "Get last commit message in repo %s:" % repoName
branch = g.get_user().get_repo(repoName).get_branch("dev")
lastCommit = branch._commit.value.commit
print "\t%s" % lastCommit._message.value
print "\t%s"
print "<--------------------------------------------------->"
fc = repo.update_file("/README.md", "testing PyGithub", "test commit", fc.sha)
print fc
но я хотел бы знать, как оформить заказ на новую ветку. Я не нашел ни одного примера в Интернете. Большое спасибо.
1 ответ
Вы можете использовать функцию PyGithub create_git_ref для создания новой ветви. Используя ваш пример выше:
g = Github("user", "pass")
repoName = "apiTest"
source_branch = 'master'
target_branch = 'newfeature'
repo = g.get_user().get_repo(repoName)
sb = repo.get_branch(source_branch)
repo.create_git_ref(ref='refs/heads/' + target_branch, sha=sb.commit.sha)