Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ def get_app(
resolve_deps=False,
cache_key=None,
compress_artifacts=False,
app_name=None,
):
"""bench get-app clones a Frappe App from remote (GitHub or any other git server),
and installs it on the current bench. This also resolves dependencies based on the
Expand Down Expand Up @@ -778,6 +779,14 @@ def get_app(

if to_clone:
app.get()
# rename folder if app_name override provided
if app_name and app_name != app.repo:
os.rename(
os.path.join(bench_path, "apps", app.repo),
os.path.join(bench_path, "apps", app_name),
)
app.app_name = app_name
app.repo = app_name

if (
to_clone
Expand Down Expand Up @@ -1033,6 +1042,13 @@ def pull_apps(apps=None, bench_path=".", reset=False):
bench.run(f"git fetch {remote} --unshallow", cwd=app_dir)

branch = get_current_branch(app, bench_path=bench_path)

# --- FIX: Skip update if detached HEAD ---
if not branch:
print(f"App {app} is pinned to a specific version. Skipping update.")
continue
# -----------------------------------------

logger.log(f"pulling {app}")
if reset:
reset_cmd = f"git reset --hard {remote}/{branch}"
Expand Down
5 changes: 3 additions & 2 deletions bench/commands/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def drop(path):
default=False,
help="Whether to gzip get-app artifacts that are to be cached",
)
@click.option("--app-name", default=None, help="Override folder name on disk")
def get_app(
git_url,
branch,
Expand All @@ -174,6 +175,7 @@ def get_app(
resolve_deps=False,
cache_key=None,
compress_artifacts=False,
app_name=None,
):
"clone an app from the internet and set it up in your bench"
from bench.app import get_app
Expand All @@ -188,9 +190,8 @@ def get_app(
resolve_deps=resolve_deps,
cache_key=cache_key,
compress_artifacts=compress_artifacts,
app_name=app_name,
)


@click.command("new-app", help="Create a new Frappe application under apps folder")
@click.option(
"--no-git",
Expand Down
10 changes: 7 additions & 3 deletions bench/utils/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ def get_current_branch(app, bench_path="."):
from bench.utils import get_cmd_output

repo_dir = get_repo_dir(app, bench_path=bench_path)
return get_cmd_output("git symbolic-ref -q --short HEAD", cwd=repo_dir)
try:
return get_cmd_output("git symbolic-ref -q --short HEAD", cwd=repo_dir)
except Exception:
# If we are in Detached HEAD state (e.g. pinned tag), this returns None
return None


@lru_cache(maxsize=5)
Expand Down Expand Up @@ -273,8 +277,8 @@ def get_app_name(bench_path: str, folder_name: str) -> str:

if not app_name:
raise AppInstallationError(
"Could not determine the package name. Checked pyproject.toml, setup.cfg, and setup.py."
)
"Could not determine the package name. Checked pyproject.toml, setup.cfg, and setup.py."
)


if app_name and folder_name != app_name:
Expand Down