|
16 | 16 | from raven.contrib.django.raven_compat.models import client |
17 | 17 | from log import logger, op_logger |
18 | 18 | from oplog.models import add_oplog |
| 19 | +from git.client import fetch_project_commits |
19 | 20 |
|
20 | 21 |
|
21 | 22 | def render_op_result(op_result): |
@@ -735,16 +736,30 @@ def handle(app): |
735 | 736 | app.check_latest_giturl() |
736 | 737 | except InvalidLainYaml, e: |
737 | 738 | return (400, None, '%s' % e, reverse('api_image_push', kwargs={'appname': appname})) |
| 739 | + |
| 740 | + uniq_authors = authors |
| 741 | + total_commits = commits |
| 742 | + if authors is None: |
| 743 | + timestamp_len = 10 |
| 744 | + commits_info = fetch_project_commits( |
| 745 | + app.giturl, int(app.meta_version[:timestamp_len])) |
| 746 | + if commits_info is not None: |
| 747 | + uniq_authors, total_commits = commits_info |
| 748 | + else: |
| 749 | + return (400, None, 'Fetch commmits information failed', reverse('api_docs')) |
| 750 | + if len(total_commits) == 0 or len(uniq_authors) == 0: |
| 751 | + return (400, None, 'Nothing Changed', reverse('api_docs')) |
738 | 752 | commitid_len = 40 |
739 | 753 | datas = { |
740 | 754 | "appname": appname, |
741 | | - "commits": commits, |
| 755 | + "commits": total_commits, |
742 | 756 | "operator": AuthApi.operater, |
743 | 757 | "lastid": app.meta_version[-commitid_len:], |
744 | 758 | "nextid": app.latest_meta_version[-commitid_len:], |
745 | 759 | "giturl": app.giturl, |
746 | | - "authors": authors, |
| 760 | + "authors": uniq_authors, |
747 | 761 | } |
| 762 | + logger.info('notify datas:%s', str(datas)) |
748 | 763 | image_push_notify(datas) |
749 | 764 | return (200, None, 'ok', reverse('api_image_push', kwargs={'appname': appname})) |
750 | 765 | return cls.deal_with_appname(appname, handle) |
|
0 commit comments