@thedecipherist/mdd 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/mdd-branch-guard.sh +20 -15
- package/package.json +1 -1
|
@@ -13,26 +13,31 @@ BRANCH=$(git branch --show-current 2>/dev/null)
|
|
|
13
13
|
# Only block on main/master
|
|
14
14
|
[[ "$BRANCH" == "main" || "$BRANCH" == "master" ]] || exit 0
|
|
15
15
|
|
|
16
|
-
#
|
|
16
|
+
# Check for uncommitted changes
|
|
17
17
|
CHANGES=$(git status --porcelain 2>/dev/null | wc -l | tr -d ' ')
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
echo " MDD never writes files directly on main or master."
|
|
24
|
-
echo ""
|
|
25
|
-
if [ "$CHANGES" -gt 0 ]; then
|
|
26
|
-
echo " You have ${CHANGES} uncommitted change(s). Commit or stash first:"
|
|
19
|
+
# Clean working tree — auto-create a branch and allow the write
|
|
20
|
+
if [ "$CHANGES" -eq 0 ]; then
|
|
21
|
+
AUTO_BRANCH="mdd/session-$(date +%Y%m%d-%H%M%S)"
|
|
22
|
+
git checkout -b "$AUTO_BRANCH" 2>/dev/null
|
|
27
23
|
echo ""
|
|
28
|
-
echo "
|
|
29
|
-
echo " — or —"
|
|
30
|
-
echo " git stash && git checkout -b feat/<name>"
|
|
31
|
-
else
|
|
32
|
-
echo " Create a feature branch, then re-run your /mdd command:"
|
|
24
|
+
echo " MDD Branch Guard: auto-created branch '${AUTO_BRANCH}' (was on ${BRANCH})"
|
|
33
25
|
echo ""
|
|
34
|
-
|
|
26
|
+
exit 0
|
|
35
27
|
fi
|
|
28
|
+
|
|
29
|
+
# Dirty working tree — block and ask the user what to do
|
|
30
|
+
echo ""
|
|
31
|
+
echo "⛔ MDD BRANCH GUARD"
|
|
32
|
+
echo ""
|
|
33
|
+
echo " Branch '${BRANCH}' has ${CHANGES} uncommitted change(s)."
|
|
34
|
+
echo " Use AskUserQuestion to ask the user:"
|
|
35
|
+
echo " Question: 'You have uncommitted changes on ${BRANCH}. How would you like to proceed?'"
|
|
36
|
+
echo " Options:"
|
|
37
|
+
echo " 1. Commit changes — run: git add -A && git commit -m 'wip: save before branch' && git checkout -b feat/<name>"
|
|
38
|
+
echo " 2. Stash changes — run: git stash && git checkout -b feat/<name>"
|
|
39
|
+
echo " 3. Cancel — do nothing"
|
|
40
|
+
echo " For options 1 and 2, replace feat/<name> with a branch name derived from the task at hand."
|
|
36
41
|
echo ""
|
|
37
42
|
|
|
38
43
|
exit 2
|