Browse Source

Merge branch 'bugfix/coding_id_notype' into develop

liuyuqi-dellpc 1 year ago
parent
commit
4c3f1e38bc
1 changed files with 22 additions and 16 deletions
  1. 22 16
      repo_sync/platform/coding/coding.py

+ 22 - 16
repo_sync/platform/coding/coding.py

@@ -88,22 +88,28 @@ class CodingIE(BasePlatform):
         r = self.sess.post(url, json=data)
         if r.status_code == 200:
             res_data = r.json()
-            if res_data['Response']["DepotData"]["Page"]["TotalRow"] > 0:
-                DepotList = res_data['Response']["DepotData"]["Depots"]
-                depot = Repo(
-                    Id=DepotList[0]['Id'],
-                    Name=DepotList[0]['Name'],
-                    HttpsUrl=DepotList[0]['HttpsUrl'],
-                    ProjectId=DepotList[0]['ProjectId'],
-                    SshUrl=DepotList[0]['SshUrl'],
-                    WebUrl=DepotList[0]['WebUrl'],
-                    ProjectName=DepotList[0]['ProjectName'],
-                    Description=DepotList[0]['Description'],
-                    CreatedAt=DepotList[0]['CreatedAt'],
-                    GroupId=DepotList[0]['GroupId'],
-                    GroupName=DepotList[0]['GroupName']
-                )
-                return depot
+            try:
+                if res_data['Response']["DepotData"]["Page"]["TotalRow"] > 0:
+                    DepotList = res_data['Response']["DepotData"]["Depots"]
+                    depot = Repo(
+                        Id=DepotList[0]['Id'],
+                        Name=DepotList[0]['Name'],
+                        HttpsUrl=DepotList[0]['HttpsUrl'],
+                        ProjectId=DepotList[0]['ProjectId'],
+                        SshUrl=DepotList[0]['SshUrl'],
+                        WebUrl=DepotList[0]['WebUrl'],
+                        ProjectName=DepotList[0]['ProjectName'],
+                        Description=DepotList[0]['Description'],
+                        CreatedAt=DepotList[0]['CreatedAt'],
+                        GroupId=DepotList[0]['GroupId'],
+                        GroupName=DepotList[0]['GroupName']
+                    )
+                    return depot
+                else:
+                    print(f'can not find repo {repo_name} in project {self.project_name}')
+                    exit(1)
+            except Exception as e:
+                raise Exception(f'can not find repo {repo_name} in project {self.project_name}')
 
     def get_project_info(self)->Project:
         url = f'{self._host}/open-api'