From 5ffe5bee07ff802ae5bec9b9667a91e941a3a464 Mon Sep 17 00:00:00 2001 From: giveen Date: Wed, 14 Jan 2026 15:59:15 -0700 Subject: [PATCH] scripts: add METASPLOIT_SUBTREE_REPO override and improve subtree messaging --- scripts/add_metasploit_subtree.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/add_metasploit_subtree.sh b/scripts/add_metasploit_subtree.sh index e3c7a64..92f9a4f 100644 --- a/scripts/add_metasploit_subtree.sh +++ b/scripts/add_metasploit_subtree.sh @@ -4,11 +4,12 @@ set -euo pipefail -REPO_URL="https://github.com/GH05TCREW/MetasploitMCP.git" +REPO_URL="${METASPLOIT_SUBTREE_REPO:-https://github.com/GH05TCREW/MetasploitMCP.git}" PREFIX="third_party/MetasploitMCP" BRANCH="main" echo "This will add MetasploitMCP as a git subtree under ${PREFIX}." +echo "You can override the upstream repo with: METASPLOIT_SUBTREE_REPO=...\n" echo "If the subtree already exists, the script will pull and rebase the subtree instead.\n" if [ -d "${PREFIX}" ]; then @@ -27,6 +28,14 @@ if [ -d "${PREFIX}" ]; then fi else echo "Adding subtree for the first time..." - git subtree add --prefix="${PREFIX}" "${REPO_URL}" "${BRANCH}" --squash - echo "MetasploitMCP subtree added under ${PREFIX}." + # Ensure parent dir exists for clearer errors + mkdir -p "$(dirname "${PREFIX}")" + + if git subtree add --prefix="${PREFIX}" "${REPO_URL}" "${BRANCH}" --squash; then + echo "MetasploitMCP subtree added under ${PREFIX}." + else + echo "Failed to add subtree from ${REPO_URL}." >&2 + echo "Check that the URL is correct or override with METASPLOIT_SUBTREE_REPO." >&2 + exit 1 + fi fi