Skip to content

Commit

Permalink
server: fix extracting name from repo url
Browse files Browse the repository at this point in the history
Also add more explicit errors about not matching repo or branch.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
  • Loading branch information
jakubgs committed Sep 27, 2023
1 parent 9ca408c commit a8cecc0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions files/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _checkout(self):
@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'):
Expand Down Expand Up @@ -100,8 +100,11 @@ def on_push(data):
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']
Expand Down

0 comments on commit a8cecc0

Please sign in to comment.