Beispiel #1
0
 def insert_change_attributes(obj, change):
     obj.update({
         "repository_prefix":
         change["repository_prefix"],
         "repository_fullname":
         change["repository_fullname"],
         "repository_shortname":
         change["repository_shortname"],
         "branch":
         change["branch"],
         "target_branch":
         change["target_branch"],
         "number":
         change["number"],
         "change_id":
         change["change_id"],
         "url":
         change["url"],
         "on_author":
         change["author"],
         "on_created_at":
         change["created_at"],
         "changed_files":
         list(
             map(lambda x: SimpleFile(path=x.path),
                 change["changed_files"])),
     })
Beispiel #2
0
 def insert_change_attributes(obj, change):
     obj.update({
         "repository_prefix":
         change["repository_prefix"],
         "repository_fullname":
         change["repository_fullname"],
         "repository_shortname":
         change["repository_shortname"],
         "branch":
         change["branch"],
         "target_branch":
         change["target_branch"],
         "number":
         change["number"],
         "change_id":
         change["change_id"],
         "on_author":
         change["author"],
         "on_created_at":
         change["created_at"],
         "changed_files":
         [SimpleFile(path=cf.path) for cf in change["changed_files"]],
     })
Beispiel #3
0
 def extract_objects(
     self,
     changes: List[RawChange],
     dumper: Callable,
 ) -> List[Union[Change, Event]]:
     #
     # Here convert raw changes to the Change or Event dataclasses.
     #
     # These objects will be indexed into the DB by the caller.
     # It is mandatory that an object keep the same id during its live;
     # for instance each time the Pull Request X is extracted by this function
     # (because it has been updated) its computed id must remane the same.
     # Then the objects will updated in the DB and will not concidered as a
     # new object.
     #
     # Change and Event's attributes type must be follow (see: db.py)
     #
     objects: List[Union[Change, Event]] = []
     dummy_change = Change(
         _id="123",
         _type="Change",
         number=1,
         change_id="org/dummyrepo/1",
         title="A dummy change",
         text="Body text",
         url=None,
         commit_count=1,
         additions=10,
         deletions=0,
         changed_files_count=1,
         changed_files=[File(additions=10, deletions=0, path="README.md")],
         commits=[
             Commit(
                 sha="12345",
                 author="John",
                 committer="John",
                 authored_at="2020-04-11T07:01:15Z",
                 committed_at="2020-04-11T07:00:15Z",
                 additions=10,
                 deletions=0,
                 title="A dummy commit",
             )
         ],
         repository_prefix="org",
         repository_fullname="org/dummyrepo",
         repository_shortname="dummyrepo",
         author="John",
         committer="John",
         merged_by="Zuul",
         branch="dummy-feature",
         target_branch="main",
         created_at="2020-04-11T07:00:15Z",
         merged_at="2020-04-12T07:00:15Z",
         updated_at="2020-04-12T07:00:15Z",
         closed_at="2020-04-12T07:00:15Z",
         state="MERGED",
         duration=3600,
         mergeable=None,
         labels=None,
         assignees=None,
         approval=None,
         draft=None,
         self_merged=False,
     )
     dummy_event = Event(
         _id="cce_1",
         _type="ChangeCreatedEvent",
         created_at="2020-04-11T07:00:15Z",
         author="John",
         repository_prefix="org",
         repository_fullname="org/dummyrepo",
         repository_shortname="dummyrepo",
         url=None,
         branch="dummy-feature",
         target_branch="main",
         number=1,
         change_id="org/dummyrepo/1",
         on_author="John",
         on_created_at="2020-04-11T07:00:15Z",
         changed_files=[SimpleFile(path="README.md")],
         approval=None,
     )
     objects.extend([dummy_change, dummy_event])
     return objects