要设置Bitbucket存储库,可以使用Bitbucket API进行操作。以下是使用Python编写的一些示例代码:
import requests
url = 'https://api.bitbucket.org/2.0/repositories//'
headers = {
'Authorization': 'Bearer ',
'Content-Type': 'application/json'
}
data = {
"scm": "git",
"is_private": True,
"fork_policy": "no_public_forks"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
import requests
url = 'https://api.bitbucket.org/2.0/repositories//'
headers = {
'Authorization': 'Bearer '
}
response = requests.get(url, headers=headers)
print(response.json())
import requests
url = 'https://api.bitbucket.org/2.0/repositories//'
headers = {
'Authorization': 'Bearer ',
'Content-Type': 'application/json'
}
data = {
"is_private": False
}
response = requests.put(url, headers=headers, json=data)
print(response.json())
请确保替换
为工作区名称,
为存储库名称,以及
为有效的Bitbucket访问令牌。