Skip to content

Commit

Permalink
abort builds if a new patchset is pushed (SAP#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
ib-steffen authored Feb 25, 2019
1 parent 680c9c5 commit 716d983
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/db/migrations/00028.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "commit" ADD COLUMN gerrit_change_id varchar;
10 changes: 5 additions & 5 deletions src/gerrit/trigger/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ def handle_patchset_created_project(conn, event, project_id, project_name):
ON b.commit_id = c.id
AND b.project_id = c.project_id
WHERE
c.url = %s AND
c.gerrit_change_id = %s AND
j.state in ('scheduled', 'running')
''', [url])
''', [event['change']['id']])
c.close()
conn.commit()

Expand All @@ -120,18 +120,18 @@ def handle_patchset_created_project(conn, event, project_id, project_name):
INSERT INTO "commit" (
id, message, repository_id, timestamp,
author_name, author_email, author_username,
committer_name, committer_email, committer_username, url, branch, project_id, tag)
committer_name, committer_email, committer_username, url, branch, project_id, tag, gerrit_change_id)
VALUES (%s, %s, %s,
%s, %s, %s,
%s, %s, %s,
%s, %s, %s, %s, %s)
%s, %s, %s, %s, %s, %s)
RETURNING *
''', (sha, event['change']['commitMessage'],
repository_id, datetime.datetime.now(),
event['change']['owner'].get('name', 'unknown'),
'', event['change']['owner']['username'], '', '', '',
url,
event['change']['branch'], project_id, None))
event['change']['branch'], project_id, None, event['change']['id']))
result = c.fetchone()
c.close()
commit = result
Expand Down

0 comments on commit 716d983

Please sign in to comment.