You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by gc...@apache.org on 2022/09/13 19:10:01 UTC

[allura] branch gc/8463 created (now 383f6e17d)

This is an automated email from the ASF dual-hosted git repository.

gcruz pushed a change to branch gc/8463
in repository https://gitbox.apache.org/repos/asf/allura.git


      at 383f6e17d [#8463] added basic resp endpoint to store commit statuses

This branch includes the following new commits:

     new 383f6e17d [#8463] added basic resp endpoint to store commit statuses

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[allura] 01/01: [#8463] added basic resp endpoint to store commit statuses

Posted by gc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gcruz pushed a commit to branch gc/8463
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 383f6e17d7fbf79173892eae1da413800485458b
Author: Guillermo Cruz <gu...@slashdotmedia.com>
AuthorDate: Tue Sep 13 13:09:54 2022 -0600

    [#8463] added basic resp endpoint to store commit statuses
---
 Allura/allura/controllers/repository.py |  7 +++++++
 Allura/allura/model/__init__.py         |  4 ++--
 Allura/allura/model/repository.py       | 18 +++++++++++++++++-
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index ab98ec1ef..96d0232fe 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -361,6 +361,13 @@ class RepoRestController(RepoRootController, AppRestControllerMixin):
                 }
                 for commit in revisions
             ]}
+    @expose('json:')
+    def commit_status(self, rev=None, **kwargs):
+        params = {x : kwargs.get(x, '').strip() for x in
+                                                   ['state', 'target_url', 'description', 'context']}
+        M.CommitStatus(params)
+        return {"status": "success"}
+
 
 
 class MergeRequestsController:
diff --git a/Allura/allura/model/__init__.py b/Allura/allura/model/__init__.py
index b7b1fdbfd..ef5adad30 100644
--- a/Allura/allura/model/__init__.py
+++ b/Allura/allura/model/__init__.py
@@ -28,7 +28,7 @@ from .auth import AuthGlobals, User, ProjectRole, EmailAddress
 from .auth import AuditLog, AlluraUserProperty, UserLoginDetails
 from .filesystem import File
 from .notification import Notification, Mailbox, SiteNotification
-from .repository import Repository, RepositoryImplementation
+from .repository import Repository, RepositoryImplementation, CommitStatus
 from .repository import MergeRequest, GitLikeTree
 from .stats import Stats
 from .oauth import OAuthToken, OAuthConsumerToken, OAuthRequestToken, OAuthAccessToken
@@ -55,7 +55,7 @@ __all__ = [
     'AwardFile', 'Award', 'AwardGrant', 'VotableArtifact', 'Discussion', 'Thread', 'PostHistory', 'Post',
     'DiscussionAttachment', 'BaseAttachment', 'AuthGlobals', 'User', 'ProjectRole', 'EmailAddress',
     'AuditLog', 'AlluraUserProperty', 'File', 'Notification', 'Mailbox', 'Repository',
-    'RepositoryImplementation', 'MergeRequest', 'GitLikeTree', 'Stats', 'OAuthToken', 'OAuthConsumerToken',
+    'RepositoryImplementation', 'CommitStatus', 'MergeRequest', 'GitLikeTree', 'Stats', 'OAuthToken', 'OAuthConsumerToken',
     'OAuthRequestToken', 'OAuthAccessToken', 'MonQTask', 'Webhook', 'ACE', 'ACL', 'EVERYONE', 'ALL_PERMISSIONS',
     'DENY_ALL', 'MarkdownCache', 'main_doc_session', 'main_orm_session', 'project_doc_session', 'project_orm_session',
     'artifact_orm_session', 'repository_orm_session', 'task_orm_session', 'ArtifactSessionExtension', 'repository',
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 7ebbffdb7..99a5be417 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -47,7 +47,7 @@ import six
 from ming import schema as S
 from ming import Field, collection, Index
 from ming.utils import LazyProperty
-from ming.odm import FieldProperty, session, Mapper, mapper, MappedClass
+from ming.odm import FieldProperty, session, Mapper, mapper, MappedClass, RelationProperty
 from ming.base import Object
 
 from allura.lib import helpers as h
@@ -1042,6 +1042,21 @@ CommitDoc = collection(
     Field('child_ids', [str], index=True),
     Field('repo_ids', [S.ObjectId()], index=True))
 
+class CommitStatus(MappedClass):
+    class __mongometa__:
+        session = repository_orm_session
+        name = 'commit_status'
+        indexes = ['commit_id']
+
+    query: 'Query[CommitStatus]'
+
+    state = FieldProperty(str)
+    target_url = FieldProperty(str)
+    description = FieldProperty(str)
+    context = FieldProperty(str)
+    commit_id = FieldProperty(str)
+    commit = RelationProperty('Commit')
+
 
 class Commit(MappedClass, RepoObject, ActivityObject):
     # Basic commit information
@@ -1066,6 +1081,7 @@ class Commit(MappedClass, RepoObject, ActivityObject):
     parent_ids = FieldProperty([str])
     child_ids = FieldProperty([str])
     repo_ids = FieldProperty([S.ObjectId()])
+    statuses = RelationProperty('CommitStatus', via="commit_id")
 
     type_s = 'Commit'
     # Ephemeral attrs