mirror of
https://github.com/frappe/bench.git
synced 2024-11-13 16:56:33 +00:00
Merge pull request #1306 from revant/fix-init-for-tag
fix: allow bench init with git tags
This commit is contained in:
commit
338df66e48
@ -35,6 +35,7 @@ class TestUtils(unittest.TestCase):
|
|||||||
is_valid_frappe_branch("https://github.com/random/random.git", frappe_branch="random-branch")
|
is_valid_frappe_branch("https://github.com/random/random.git", frappe_branch="random-branch")
|
||||||
|
|
||||||
is_valid_frappe_branch("https://github.com/frappe/frappe.git", frappe_branch="develop")
|
is_valid_frappe_branch("https://github.com/frappe/frappe.git", frappe_branch="develop")
|
||||||
|
is_valid_frappe_branch("https://github.com/frappe/frappe.git", frappe_branch="v13.29.0")
|
||||||
|
|
||||||
def test_app_states(self):
|
def test_app_states(self):
|
||||||
bench_dir = "./sandbox"
|
bench_dir = "./sandbox"
|
||||||
|
@ -50,6 +50,7 @@ def is_frappe_app(directory: str) -> bool:
|
|||||||
return bool(is_frappe_app)
|
return bool(is_frappe_app)
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=None)
|
||||||
def is_valid_frappe_branch(frappe_path:str, frappe_branch:str):
|
def is_valid_frappe_branch(frappe_path:str, frappe_branch:str):
|
||||||
"""Check if a branch exists in a repo. Throws InvalidRemoteException if branch is not found
|
"""Check if a branch exists in a repo. Throws InvalidRemoteException if branch is not found
|
||||||
|
|
||||||
@ -61,26 +62,19 @@ def is_valid_frappe_branch(frappe_path:str, frappe_branch:str):
|
|||||||
:type frappe_branch: str
|
:type frappe_branch: str
|
||||||
:raises InvalidRemoteException: branch for this repo doesn't exist
|
:raises InvalidRemoteException: branch for this repo doesn't exist
|
||||||
"""
|
"""
|
||||||
import subprocess
|
import git
|
||||||
|
|
||||||
|
g = git.cmd.Git()
|
||||||
|
|
||||||
if frappe_branch:
|
if frappe_branch:
|
||||||
try:
|
try:
|
||||||
ret = subprocess.check_output(
|
res = g.ls_remote("--heads", "--tags", frappe_path, frappe_branch)
|
||||||
(
|
if not res:
|
||||||
"git",
|
|
||||||
"ls-remote",
|
|
||||||
"--heads",
|
|
||||||
frappe_path,
|
|
||||||
frappe_branch,
|
|
||||||
),
|
|
||||||
encoding="UTF-8",
|
|
||||||
)
|
|
||||||
if not ret:
|
|
||||||
raise InvalidRemoteException(
|
raise InvalidRemoteException(
|
||||||
f"Invalid {frappe_branch} for the remote {frappe_path}"
|
f"Invalid branch or tag: {frappe_branch} for the remote {frappe_path}"
|
||||||
)
|
)
|
||||||
except subprocess.CalledProcessError:
|
except git.exc.GitCommandError:
|
||||||
raise InvalidRemoteException(f"Invalid frappe path {frappe_path}")
|
raise InvalidRemoteException(f"Invalid frappe path: {frappe_path}")
|
||||||
|
|
||||||
|
|
||||||
def log(message, level=0, no_log=False):
|
def log(message, level=0, no_log=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user