server: fix extracting name from repo url

Also add more explicit errors about not matching repo or branch.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-09-27 20:34:24 +02:00
parent 9ca408c40e
commit a8cecc026b
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
1 changed files with 6 additions and 3 deletions

View File

@ -55,7 +55,7 @@ class ManagedRepo:
@property
def name(self):
if self.url.startswith('https://'):
name = urlparse(self.url).path
name = urlparse(self.url).path.strip('/')
else:
name = self.url.split(':').pop()
if name.endswith('.git'):
@ -100,8 +100,11 @@ def define_push_hook(repo, post_action):
branch = remove_prefix(data['ref'], 'refs/heads/')
name = data['repository']['full_name']
if name != repo.name or branch != repo.branch:
log.warning('Repo event does not match configred repo')
if name != repo.name:
log.error('Wrong repo: Event(%s) != Local(%s)', name, repo.name)
return
if branch != repo.branch:
log.error('Wrong branch: Event(%s) != Local(%s)', branch, repo.branch)
return
new_commit = data['head_commit']['id']