F 修复常规发布更改Git仓库配置不生效的问题

pull/31/head v2.1.1
vapao 2020-03-08 13:11:42 +08:00
parent 9d9541c1b9
commit 8d3e274bc4
2 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,7 @@
from django.conf import settings
from apps.app.models import Deploy
from libs.gitlib import Git
import shutil
import os
@ -22,3 +23,7 @@ def fetch_versions(deploy: Deploy):
git_repo = deploy.extend_obj.git_repo
repo_dir = os.path.join(settings.REPOS_DIR, str(deploy.id))
return Git(git_repo, repo_dir).fetch_branches_tags()
def remove_repo(deploy_id):
shutil.rmtree(os.path.join(settings.REPOS_DIR, str(deploy_id)), True)

View File

@ -6,7 +6,7 @@ from django.db.models import F
from libs import JsonParser, Argument, json_response
from apps.app.models import App, Deploy, DeployExtend1, DeployExtend2
from apps.config.models import Config
from apps.app.utils import parse_envs, fetch_versions
from apps.app.utils import parse_envs, fetch_versions, remove_repo
import json
@ -109,6 +109,9 @@ class DeployView(View):
extend_form.filter_rule = json.dumps(extend_form.filter_rule)
extend_form.custom_envs = json.dumps(parse_envs(extend_form.custom_envs))
if form.id:
extend = DeployExtend1.objects.filter(deploy_id=form.id).first()
if extend.git_repo != extend_form.git_repo:
remove_repo(form.id)
Deploy.objects.filter(pk=form.id).update(**form)
DeployExtend1.objects.filter(deploy_id=form.id).update(**extend_form)
else: