mirror of
https://github.com/frappe/bench.git
synced 2024-11-17 02:25:16 +00:00
feat: add commit hash and branch in states.json
This commit is contained in:
parent
d178b08abb
commit
9004e1dd6a
@ -428,7 +428,7 @@ def install_resolved_deps(
|
|||||||
for repo_name, app in reversed(resolution.items()):
|
for repo_name, app in reversed(resolution.items()):
|
||||||
existing_dir, _ = check_existing_dir(bench_path, repo_name)
|
existing_dir, _ = check_existing_dir(bench_path, repo_name)
|
||||||
if existing_dir:
|
if existing_dir:
|
||||||
if bench.apps.states[repo_name]["resolution"] != app.tag:
|
if bench.apps.states[repo_name]["resolution"]["branch"] != app.tag:
|
||||||
click.secho(
|
click.secho(
|
||||||
f"Incompatible version of {repo_name} is already installed",
|
f"Incompatible version of {repo_name} is already installed",
|
||||||
fg="yellow",
|
fg="yellow",
|
||||||
@ -500,7 +500,7 @@ def install_app(
|
|||||||
bench.run("yarn install", cwd=app_path)
|
bench.run("yarn install", cwd=app_path)
|
||||||
|
|
||||||
bench.apps.sync()
|
bench.apps.sync()
|
||||||
bench.apps.update_apps_states(app, tag)
|
bench.apps.update_apps_states(app, branch=tag)
|
||||||
|
|
||||||
if not skip_assets:
|
if not skip_assets:
|
||||||
build_assets(bench_path=bench_path, app=app)
|
build_assets(bench_path=bench_path, app=app)
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
# imports - standard imports
|
# imports - standard imports
|
||||||
|
import subprocess
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
from typing import List, MutableSequence, TYPE_CHECKING
|
from typing import List, MutableSequence, TYPE_CHECKING, Union
|
||||||
|
|
||||||
# imports - module imports
|
# imports - module imports
|
||||||
import bench
|
import bench
|
||||||
@ -159,6 +160,7 @@ class BenchApps(MutableSequence):
|
|||||||
def __init__(self, bench: Bench):
|
def __init__(self, bench: Bench):
|
||||||
self.bench = bench
|
self.bench = bench
|
||||||
self.states_path = os.path.join(self.bench.name, "sites", "apps_states.json")
|
self.states_path = os.path.join(self.bench.name, "sites", "apps_states.json")
|
||||||
|
self.apps_path = os.path.join(self.bench.name, "apps")
|
||||||
self.initialize_apps()
|
self.initialize_apps()
|
||||||
self.set_states()
|
self.set_states()
|
||||||
|
|
||||||
@ -169,7 +171,7 @@ class BenchApps(MutableSequence):
|
|||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self.states = {}
|
self.states = {}
|
||||||
|
|
||||||
def update_apps_states(self, app_name: str = None, resolution: str = None):
|
def update_apps_states(self, app_name: Union[str, None] = None, branch: Union[str, None] = None):
|
||||||
apps_to_remove = []
|
apps_to_remove = []
|
||||||
for app in self.states:
|
for app in self.states:
|
||||||
if app not in self.apps:
|
if app not in self.apps:
|
||||||
@ -180,8 +182,23 @@ class BenchApps(MutableSequence):
|
|||||||
|
|
||||||
if app_name:
|
if app_name:
|
||||||
version = get_current_version(app_name, self.bench.name)
|
version = get_current_version(app_name, self.bench.name)
|
||||||
|
|
||||||
|
app_dir = os.path.join(self.apps_path, app_name)
|
||||||
|
if not branch:
|
||||||
|
branch = (
|
||||||
|
subprocess
|
||||||
|
.check_output("git rev-parse --abbrev-ref HEAD", shell=True, cwd=app_dir)
|
||||||
|
.decode("utf-8")
|
||||||
|
.rstrip()
|
||||||
|
)
|
||||||
|
|
||||||
|
commit_hash = subprocess.check_output(f"git rev-parse {branch}", shell=True, cwd=app_dir).decode("utf-8").rstrip()
|
||||||
|
|
||||||
self.states[app_name] = {
|
self.states[app_name] = {
|
||||||
"resolution": resolution,
|
"resolution": {
|
||||||
|
"commit_hash":commit_hash,
|
||||||
|
"branch": branch
|
||||||
|
},
|
||||||
"version": version,
|
"version": version,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user