Skip to content

Commit

Permalink
F 修复常规发布更改Git仓库配置不生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
vapao committed Mar 8, 2020
1 parent 9d9541c commit 8d3e274
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions spug_api/apps/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.conf import settings
from apps.app.models import Deploy
from libs.gitlib import Git
import shutil
import os


Expand All @@ -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)
5 changes: 4 additions & 1 deletion spug_api/apps/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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


Expand Down Expand Up @@ -109,6 +109,9 @@ def post(self, request):
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:
Expand Down

0 comments on commit 8d3e274

Please sign in to comment.