coding

代码重构优化-不要用过多的if嵌套

不要用过多的if嵌套 重构前: def project_version(request,group_name,branch_name,project_name): if branch_name and group_name and project_name: project_name_with_namespace = '%s/%s' %(group_name,project_name) project = gl.projects.get(project_name_with_namespace) if project: branches = [] branch = project.branches.list() if branch: branches = [] branch_name_find = '%s-' %(branch_name) for branch_name_in in branch: if (branch_name_in.