mirror of
https://github.com/frappe/bench.git
synced 2025-01-24 23:48:24 +00:00
fix: Don't fetch meta for rm app
This commit is contained in:
parent
1330e66d07
commit
17edb4797b
27
bench/app.py
27
bench/app.py
@ -35,7 +35,7 @@ if typing.TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
class AppMeta:
|
class AppMeta:
|
||||||
def __init__(self, name: str, branch: str = None):
|
def __init__(self, name: str, branch: str = None, to_clone: bool = True):
|
||||||
"""
|
"""
|
||||||
name (str): This could look something like
|
name (str): This could look something like
|
||||||
1. https://github.com/frappe/healthcare.git
|
1. https://github.com/frappe/healthcare.git
|
||||||
@ -53,14 +53,21 @@ class AppMeta:
|
|||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.remote_server = "github.com"
|
self.remote_server = "github.com"
|
||||||
|
self.to_clone = to_clone
|
||||||
self.on_disk = False
|
self.on_disk = False
|
||||||
self.use_ssh = False
|
self.use_ssh = False
|
||||||
|
self.from_apps = False
|
||||||
self.branch = branch
|
self.branch = branch
|
||||||
self.setup_details()
|
self.setup_details()
|
||||||
|
|
||||||
def setup_details(self):
|
def setup_details(self):
|
||||||
|
# fetch meta from installed apps
|
||||||
|
if not self.to_clone and hasattr(self, "bench") and os.path.exists(os.path.join(self.bench.name, "apps", self.name)):
|
||||||
|
self.from_apps = True
|
||||||
|
self._setup_details_from_installed_apps()
|
||||||
|
|
||||||
# fetch meta for repo on mounted disk
|
# fetch meta for repo on mounted disk
|
||||||
if os.path.exists(self.name):
|
elif os.path.exists(self.name):
|
||||||
self.on_disk = True
|
self.on_disk = True
|
||||||
self._setup_details_from_mounted_disk()
|
self._setup_details_from_mounted_disk()
|
||||||
|
|
||||||
@ -72,11 +79,16 @@ class AppMeta:
|
|||||||
else:
|
else:
|
||||||
self._setup_details_from_name_tag()
|
self._setup_details_from_name_tag()
|
||||||
|
|
||||||
|
def _setup_details_from_mounted_disk(self):
|
||||||
|
self.org, self.repo, self.tag = os.path.split(self.name)[-2:] + (self.branch,)
|
||||||
|
|
||||||
def _setup_details_from_name_tag(self):
|
def _setup_details_from_name_tag(self):
|
||||||
self.org, self.repo, self.tag = fetch_details_from_tag(self.name)
|
self.org, self.repo, self.tag = fetch_details_from_tag(self.name)
|
||||||
|
|
||||||
def _setup_details_from_mounted_disk(self):
|
def _setup_details_from_installed_apps(self):
|
||||||
self.org, self.repo, self.tag = os.path.split(self.name)[-2:] + (self.branch,)
|
self.org, self.repo, self.tag = os.path.split(
|
||||||
|
os.path.join(self.bench.name, "apps", self.name)
|
||||||
|
)[-2:] + (self.branch,)
|
||||||
|
|
||||||
def _setup_details_from_git_url(self):
|
def _setup_details_from_git_url(self):
|
||||||
return self.__setup_details_from_git()
|
return self.__setup_details_from_git()
|
||||||
@ -92,6 +104,9 @@ class AppMeta:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def url(self):
|
def url(self):
|
||||||
|
if self.from_apps:
|
||||||
|
return os.path.abspath(os.path.join("apps", self.name))
|
||||||
|
|
||||||
if self.on_disk:
|
if self.on_disk:
|
||||||
return os.path.abspath(self.name)
|
return os.path.abspath(self.name)
|
||||||
|
|
||||||
@ -108,9 +123,9 @@ class AppMeta:
|
|||||||
|
|
||||||
|
|
||||||
class App(AppMeta):
|
class App(AppMeta):
|
||||||
def __init__(self, name: str, branch: str = None, bench: "Bench" = None):
|
def __init__(self, name: str, branch: str = None, bench: "Bench" = None, *args, **kwargs):
|
||||||
super().__init__(name, branch)
|
|
||||||
self.bench = bench
|
self.bench = bench
|
||||||
|
super().__init__(name, branch, *args, **kwargs)
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
branch = f"--branch {self.tag}" if self.tag else ""
|
branch = f"--branch {self.tag}" if self.tag else ""
|
||||||
|
@ -114,9 +114,9 @@ class Bench(Base, Validator):
|
|||||||
from bench.app import App
|
from bench.app import App
|
||||||
|
|
||||||
self.validate_app_uninstall(app)
|
self.validate_app_uninstall(app)
|
||||||
self.apps.remove(App(app, bench=self))
|
self.apps.remove(App(app, bench=self, to_clone=False))
|
||||||
self.apps.sync()
|
self.apps.sync()
|
||||||
self.build()
|
# self.build() - removed because it seems unnecessary
|
||||||
self.reload()
|
self.reload()
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
|
@ -397,7 +397,7 @@ def fetch_details_from_tag(_tag):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
org, repo = org_repo
|
org, repo = org_repo
|
||||||
except ValueError:
|
except Exception:
|
||||||
org, repo = find_org(org_repo)
|
org, repo = find_org(org_repo)
|
||||||
|
|
||||||
return org, repo, tag
|
return org, repo, tag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user