Commits

Jan Borsodi committed 2fba11a

hob.repo: Unpublished services must now first be marked as a draft. This should ensure that new service development get started as drafts.

Comments (0)

Files changed (2)

     "PROT009": "New command: %(cmd_name)s(%(message_path)s) returns (%(response_path)s) = %(cmd_id)d;",
     "PROT010": "New event: %(cmd_name)s returns (%(response_path)s) = %(cmd_id)d;",
     "PROT011": "Service %(name)s %(version)s has changed from draft to published.",
+    "PROT012": "Service %(name)s %(version)s is unpublished, it is recommended to mark the first release as a draft.",
     }
 
 # Codes related to message
         self.showWarning = True
         self.showInfo = False
         self.checkDraft = True
+        self.requireDraft = True
 
         self.service = {"object": None,
                         "draft": None,
         if not remote:
             for major in local:
                 for minor in local[major]:
-                    self.new.append(local[major][minor])
-                    self.info(local[major][minor], "PROT006", dict(major=major, minor=minor, name=name))
+                    service = local[major][minor]
+                    # Any new service should first be marked as a draft
+                    if not service.isDraft() and self.requireDraft:
+                        self.error(local, "PROT012",
+                                   {
+                                      "name": service.name,
+                                      "version": service.getVersion(),
+                                   })
+                    else:
+                        self.new.append(service)
+                        self.info(service, "PROT006", dict(major=major, minor=minor, name=name))
 
     def onServiceVersion(self, local, remote, name, major):
         if not remote:
             for minor in local:
-                self.new.append(local[minor])
-                self.info(local[minor], "PROT006", dict(major=major, minor=minor, name=name))
+                service = local[minor]
+                # Any new service should first be marked as a draft
+                if not service.isDraft() and self.requireDraft:
+                    self.error(local, "PROT012",
+                               {
+                                  "name": service.name,
+                                  "version": service.getVersion(),
+                               })
+                else:
+                    self.new.append(service)
+                    self.info(service, "PROT006", dict(major=major, minor=minor, name=name))
 
     def onServiceMinorVersion(self, local, remote, name, major, minor):
         if not remote:
-            self.new.append(local)
-            self.info(local, "PROT006", dict(major=major, minor=minor, name=name))
+            service = local
+            # Any new service should first be marked as a draft
+            if not service.isDraft() and self.requireDraft:
+                self.error(local, "PROT012",
+                           {
+                              "name": service.name,
+                              "version": service.getVersion(),
+                           })
+            else:
+                self.new.append(service)
+                self.info(service, "PROT006", dict(major=major, minor=minor, name=name))
 
     def onServiceDraftState(self, local, remote, version, local_is_draft, remote_is_draft):
         self.service["draft"] = (local_is_draft, remote_is_draft)
     result = CompareResult()
     result.checkDraft = not force
     result.showInfo = show_info
+    result.requireDraft = True
     manager.compare(result)
 
     if not result.isValid():