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:
parent
9ca408c40e
commit
a8cecc026b
|
@ -55,7 +55,7 @@ class ManagedRepo:
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
if self.url.startswith('https://'):
|
if self.url.startswith('https://'):
|
||||||
name = urlparse(self.url).path
|
name = urlparse(self.url).path.strip('/')
|
||||||
else:
|
else:
|
||||||
name = self.url.split(':').pop()
|
name = self.url.split(':').pop()
|
||||||
if name.endswith('.git'):
|
if name.endswith('.git'):
|
||||||
|
@ -100,8 +100,11 @@ def define_push_hook(repo, post_action):
|
||||||
branch = remove_prefix(data['ref'], 'refs/heads/')
|
branch = remove_prefix(data['ref'], 'refs/heads/')
|
||||||
name = data['repository']['full_name']
|
name = data['repository']['full_name']
|
||||||
|
|
||||||
if name != repo.name or branch != repo.branch:
|
if name != repo.name:
|
||||||
log.warning('Repo event does not match configred repo')
|
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
|
return
|
||||||
|
|
||||||
new_commit = data['head_commit']['id']
|
new_commit = data['head_commit']['id']
|
||||||
|
|
Loading…
Reference in New Issue