问题
Bitbucket doesn't expose this information in the web interface, so I'll likely need to find it using the API.
回答1:
Some examples:
https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/?state=OPEN
https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests/?state=MERGED
and search for the size
entry in the response (eg: "size": 7)
回答2:
The following python code uses the requests library to interact with the bitbucket API. It should print the number of merged pull requests authored by the bitbucket account my_bb_username
. Note that you will need to edit url0
to point to the appropriate repository.
import requests
numprs = 0
url0 = "https://bitbucket.org/api/2.0/repositories/{username}/{reposlug}/pullrequests/?state=merged"
url = url0
while True:
r = requests.get(url)
if r.status_code != 200:
raise RuntimeError
data = r.json()
values = data['values']
for value in values:
if value['author']['username'] == 'my_bb_username':
print value['title']
numprs += 1
if 'next' in data.keys():
url = data['next']
else:
break
print numprs
If you want a list of all PRs, append ?state=merged,open,declined
to your API call. By default, the API will only include open PRs.
来源:https://stackoverflow.com/questions/27117153/how-do-i-count-the-number-of-pull-requests-ive-submitted-to-a-repository-on-bit