Skip to content

Commit 9e2e3de

Browse files
committed
feat(Makefile): I've just implemented two new targets into the makefile, publish and rm_branch that flush all the branch and merge with develop when we're sre we're done
1 parent 8625f85 commit 9e2e3de

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# By: dlesieur <dlesieur@student.42.fr> +#+ +:+ +#+ #
77
# +#+#+#+#+#+ +#+ #
88
# Created: 2025/10/23 19:03:21 by dlesieur #+# #+# #
9-
# Updated: 2025/11/06 21:12:58 by dlesieur ### ########.fr #
9+
# Updated: 2025/11/06 21:19:06 by dlesieur ### ########.fr #
1010
# #
1111
# **************************************************************************** #
1212

@@ -215,6 +215,7 @@ rm_branch:
215215

216216
publish:
217217
@set -e; \
218+
export GIT_PUBLISH=1; \
218219
BR=$$(git branch --show-current); \
219220
if [ -z "$$BR" ]; then echo "fatal: branch name required"; exit 128; fi; \
220221
if [ -z "$(MSG)" ]; then echo "fatal: provide commit message via MSG=\"...\""; exit 2; fi; \
@@ -226,6 +227,7 @@ publish:
226227
git checkout develop; \
227228
git pull --ff-only; \
228229
echo "[publish] merging $$BR -> develop"; \
230+
# Merge commit will be allowed in publish mode without 250-word requirement
229231
git merge --no-ff $$BR; \
230232
git push origin develop; \
231233
echo "[publish] deleting branch $$BR locally and on origin"; \

scripts/hooks/commit-msg

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@ if [ -z "$MSG_FILE" ]; then
1111
exit 0
1212
fi
1313

14+
# PUBLISH MODE: only enforce length >= 250 words, nothing else.
15+
if [ "${GIT_PUBLISH:-}" = "1" ]; then
16+
# Skip checks for merge commits to avoid blocking automated merge messages
17+
if git rev-parse -q --verify MERGE_HEAD >/dev/null 2>&1; then
18+
log_info "publish mode: merge commit detected — skipping length check."
19+
exit 0
20+
fi
21+
# Count words excluding commented/empty lines
22+
word_count=$(awk '!/^[[:space:]]*($|#)/{print}' "$MSG_FILE" | wc -w | tr -d '[:space:]')
23+
if [ "$word_count" -lt 25 ]; then
24+
log_error "publish mode: commit message must contain at least 250 words (got $word_count)."
25+
log_info "Tip: provide a detailed description via: MSG=\"your long message ...\""
26+
exit 1
27+
fi
28+
log_success "publish mode: commit message length OK ($word_count words)."
29+
exit 0
30+
fi
31+
1432
log_broadcast "COMMIT_SYSTEM"
1533

1634
header=$(awk '!/^[[:space:]]*($|#)/{print;exit}' "$MSG_FILE")

scripts/hooks/pre-commit

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/sh
22
. "$(dirname "$0")/log_hook.sh"
33

4+
# Skip validation entirely during publish; commit-msg will enforce word count.
5+
if [ "${GIT_PUBLISH:-}" = "1" ]; then
6+
log_info "publish mode: skipping pre-commit checks."
7+
exit 0
8+
fi
9+
410
TYPES="feat|fix|docs|refactor|test"
511
ALLOWED_TYPES="feat, fix, docs, refactor, test"
612
FORBIDDEN="WIP|update|squash!|debug|temporary"
@@ -25,7 +31,7 @@ fi
2531

2632
description=$(printf "%s" "$header" | sed -E "s/^($TYPES)\([^)]+\):[[:space:]]*(.*)$/\2/I")
2733
len=$(printf '%s' "$description" | wc -c | tr -d '[:space:]')
28-
if [ "$len" -lt 25 ] || [ "$len" -gt 170 ]; then
34+
if [ "$len" -lt 50 ] || [ "$len" -gt 170 ]; then
2935
log_error "Description length must be between 50 and 170 characters (got $len)."
3036
log_info "Your description: \"$description\""
3137
exit 1

0 commit comments

Comments
 (0)