Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in
M
mfang2.0
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 92
    • Issues 92
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 1
    • Merge Requests 1
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • 魔方Web开发组
  • mfang2.0
  • Issues
  • #376

Closed
Open
Opened Jul 02, 2022 by 宋永裕@songyongyu💬
  • Report abuse
  • New issue
Report abuse New issue

[Feat] python端工程下载模块的Git操作的改进

原来的方法,执行git操作前会更改Django的工作目录;在有并发任务时,可能会因工作目录错乱而发生异常。

      # os.chdir(self.git_folder)
      gitCmd = 'git clone -b %s git@%s:%s.git' % (template_code_obj.git_branch, 
          self.downloadObj.git_host.replace("http://",""), template_code_obj.git_path)
      # 将git仓库目录拉下来
      os.system(gitCmd)
      # git clone之后,会创建一个以项目名称命名的目录,进入这个目录,执行git pull   
      os.chdir(project_path)
      # 将仓库文件拉下来
      os.system("git pull")
      # 拉取完成后立即回到主目录,避免影响其他操作
      # 通过测试脚本下载项目会频繁出现下载失败,可能跟这个目录问题有关系
      os.chdir(settings.BASE_DIR)

现在的设计,无需切换工作目录

      gitCmd = 'git -C %s clone -b %s git@%s:%s.git' % (self.git_folder, template_code_obj.git_branch, 
                self.downloadObj.git_host.replace("http://",""), template_code_obj.git_path)
      os.system(gitCmd)
      gitCmd = 'git -C %s pull' % self.project_path
      os.system(gitCmd)
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
2
Labels
已跟进 测试中
Assign labels
  • View project labels
Reference: fmsh-web-develop/mfang2.0#376