Skip to content
Merged
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
53 changes: 15 additions & 38 deletions utils/mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
"""
version_branch = f"grass{major_version}"
if source_is_remote():
branch = gs.Popen(
branch = subprocess.Popen(
[

Check notice

Code scanning / Bandit

Starting a process with a partial executable path Note

Starting a process with a partial executable path
"git",
"ls-remote",
"--heads",
Expand All @@ -86,16 +86,14 @@
)
branch, stderr = branch.communicate()
if stderr:
gs.fatal(
_(
"Failed to get branch from the Git repository"
" <{repo_path}>.\n{error}"
).format(
repo_path=addons_git_repo_url,
error=gs.decode(stderr),
)
)
if version_branch not in gs.decode(branch):
message = (
"Failed to get branch from the Git repository <{repo_path}>.\n{error}"
).format(repo_path=addons_git_repo_url, error=stderr.decode())
if gs:
gs.fatal(_(message))
else:
sys.exit(message)
if version_branch not in branch.decode():
version_branch = "grass{}".format(int(major_version) - 1)
return version_branch

Expand Down Expand Up @@ -397,14 +395,6 @@
if not addons_base_dir or not major_version:
return None
grass_addons_dir = Path(addons_base_dir) / "grass-addons"
if gs:
call = gs.call
popen = gs.Popen
fatal = gs.fatal
else:
call = subprocess.call
popen = subprocess.Popen
fatal = sys.stderr.write
addons_branch = get_version_branch(
major_version=major_version,
addons_git_repo_url=urlparse.urljoin(base_url, "grass-addons/"),
Expand All @@ -419,8 +409,8 @@
try:
with tempfile.TemporaryDirectory(dir=addons_base_dir) as tmpdir:
tmp_clone_path = Path(tmpdir) / "grass-addons"
call(
subprocess.call(
[

Check notice

Code scanning / Bandit

Starting a process with a partial executable path Note

Starting a process with a partial executable path
"git",
"clone",
"-q",
Expand All @@ -435,8 +425,8 @@
except (shutil.Error, OSError):
if not grass_addons_dir.exists():
raise
addons_file_list = popen(
addons_file_list = subprocess.Popen(
["git", "ls-tree", "--name-only", "-r", addons_branch],

Check notice

Code scanning / Bandit

Starting a process with a partial executable path Note

Starting a process with a partial executable path
cwd=grass_addons_dir,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand All @@ -446,27 +436,14 @@
message = (
"Failed to get addons files list from the"
" Git repository <{repo_path}>.\n{error}"
)
).format(repo_path=grass_addons_dir, error=stderr.decode())
if gs:
fatal(
_(
message,
).format(
repo_path=grass_addons_dir,
error=gs.decode(stderr),
)
)
gs.fatal(_(message))
else:
message += "\n"
fatal(
message.format(
repo_path=grass_addons_dir,
error=stderr.decode(),
)
)
sys.exit(message)
addon_paths = re.findall(
rf".*{pgm}*.",
gs.decode(addons_file_list) if gs else addons_file_list.decode(),
addons_file_list.decode(),
)
for addon_path in addon_paths:
if pgm == Path(addon_path).name:
Expand Down
Loading