"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "buildbot/reporters/bitbucket.py" between
buildbot-3.0.2.tar.gz and buildbot-3.1.0.tar.gz

About: Buildbot is a continuous integration testing framework (Python-based). It supports also automation of complex build systems, application deployment, and management of sophisticated software-release processes.

bitbucket.py  (buildbot-3.0.2):bitbucket.py  (buildbot-3.1.0)
skipping to change at line 56 skipping to change at line 56
if generators is None: if generators is None:
generators = self._create_default_generators() generators = self._create_default_generators()
super().checkConfig(generators=generators, **kwargs) super().checkConfig(generators=generators, **kwargs)
httpclientservice.HTTPClientService.checkAvailable(self.__class__.__name __) httpclientservice.HTTPClientService.checkAvailable(self.__class__.__name __)
@defer.inlineCallbacks @defer.inlineCallbacks
def reconfigService(self, oauth_key, oauth_secret, base_url=_BASE_URL, oauth _url=_OAUTH_URL, def reconfigService(self, oauth_key, oauth_secret, base_url=_BASE_URL, oauth _url=_OAUTH_URL,
debug=None, verify=None, generators=None, **kwargs): debug=None, verify=None, generators=None, **kwargs):
oauth_key, oauth_secret = yield self.renderSecrets(oauth_key, oauth_secr et) oauth_key, oauth_secret = yield self.renderSecrets(oauth_key, oauth_secr et)
self.base_url = base_url
self.debug = debug self.debug = debug
self.verify = verify self.verify = verify
if generators is None: if generators is None:
generators = self._create_default_generators() generators = self._create_default_generators()
yield super().reconfigService(generators=generators, **kwargs) yield super().reconfigService(generators=generators, **kwargs)
if base_url.endswith('/'): base_url = base_url.rstrip('/')
base_url = base_url[:-1]
self._http = yield httpclientservice.HTTPClientService.getService( self._http = yield httpclientservice.HTTPClientService.getService(
self.master, base_url, self.master, base_url,
debug=self.debug, verify=self.verify) debug=self.debug, verify=self.verify)
self.oauthhttp = yield httpclientservice.HTTPClientService.getService( self.oauthhttp = yield httpclientservice.HTTPClientService.getService(
self.master, oauth_url, auth=(oauth_key, oauth_secret), self.master, oauth_url, auth=(oauth_key, oauth_secret),
debug=self.debug, verify=self.verify) debug=self.debug, verify=self.verify)
def _create_default_generators(self): def _create_default_generators(self):
return [BuildStartEndStatusGenerator()] return [BuildStartEndStatusGenerator()]
@defer.inlineCallbacks @defer.inlineCallbacks
def sendMessage(self, reports): def sendMessage(self, reports):
build = reports[0]['builds'][0] build = reports[0]['builds'][0]
results = build['results'] results = build['results']
oauth_request = yield self.oauthhttp.post("", oauth_request = yield self.oauthhttp.post("", data=_GET_TOKEN_DATA)
data=_GET_TOKEN_DATA)
if oauth_request.code == 200: if oauth_request.code == 200:
content_json = yield oauth_request.json() content_json = yield oauth_request.json()
token = content_json['access_token'] token = content_json['access_token']
else: else:
content = yield oauth_request.content() content = yield oauth_request.content()
log.error("{code}: unable to authenticate to Bitbucket {content}", log.error("{code}: unable to authenticate to Bitbucket {content}",
code=oauth_request.code, content=content) code=oauth_request.code, content=content)
return return
if build['complete']: if build['complete']:
skipping to change at line 120 skipping to change at line 119
bitbucket_uri = '/' + \ bitbucket_uri = '/' + \
'/'.join([owner, repo, 'commit', sha, 'statuses', 'build']) '/'.join([owner, repo, 'commit', sha, 'statuses', 'build'])
response = yield self._http.post(bitbucket_uri, json=body) response = yield self._http.post(bitbucket_uri, json=body)
if response.code != 200 and response.code != 201: if response.code != 200 and response.code != 201:
content = yield response.content() content = yield response.content()
log.error("{code}: unable to upload Bitbucket status {content}", log.error("{code}: unable to upload Bitbucket status {content}",
code=response.code, content=content) code=response.code, content=content)
@staticmethod def get_owner_and_repo(self, repourl):
def get_owner_and_repo(repourl):
""" """
Takes a git repository URL from Bitbucket and tries to determine the own er and repository Takes a git repository URL from Bitbucket and tries to determine the own er and repository
name name
:param repourl: Bitbucket git repo in the form of :param repourl: Bitbucket git repo in the form of
git@bitbucket.com:OWNER/REPONAME.git git@bitbucket.org:OWNER/REPONAME.git
https://bitbucket.com/OWNER/REPONAME.git https://bitbucket.org/OWNER/REPONAME.git
ssh://git@bitbucket.com/OWNER/REPONAME.git ssh://git@bitbucket.org/OWNER/REPONAME.git
https://api.bitbucket.org/2.0/repositories/OWNER/REPONAME
:return: owner, repo: The owner of the repository and the repository nam e :return: owner, repo: The owner of the repository and the repository nam e
""" """
parsed = urlparse(repourl) parsed = urlparse(repourl)
if parsed.scheme: base_parsed = urlparse(self.base_url)
path = parsed.path[1:] if parsed.path.startswith(base_parsed.path):
path = parsed.path.replace(base_parsed.path, "")
elif parsed.scheme:
path = parsed.path
else: else:
# we assume git@host:owner/repo.git here # we assume git@host:owner/repo.git here
path = parsed.path.split(':', 1)[-1] path = parsed.path.split(':', 1)[-1]
path = path.lstrip('/')
if path.endswith('.git'): if path.endswith('.git'):
path = path[:-4] path = path[:-4]
while path.endswith('/'): path = path.rstrip('/')
path = path[:-1]
parts = path.split('/') parts = path.split('/')
assert len(parts) == 2, 'OWNER/REPONAME is expected' assert len(parts) == 2, 'OWNER/REPONAME is expected'
return parts return parts
 End of changes. 8 change blocks. 
13 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)