initial commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
---
|
||||
name: commit
|
||||
description: Stage and commit changes on the active feature branch using atomic conventional commits.
|
||||
---
|
||||
|
||||
# Commit
|
||||
|
||||
Create atomic conventional commits on the active feature branch.
|
||||
|
||||
## Commit format
|
||||
|
||||
- Format: `type(scope): description`
|
||||
- Types: `feat`, `fix`, `chore`, `docs`, `style`, `refactor`, `perf`, `test`
|
||||
- First line: imperative mood, lowercase, concise (e.g., "add login" not "added login").
|
||||
- Body: only for complex changes; explain why, not what.
|
||||
- Footer: `BREAKING CHANGE:` if applicable.
|
||||
|
||||
## Rules
|
||||
|
||||
- Scope is optional but encouraged when a module or file is the clear focus.
|
||||
- If changes span multiple logical tasks, create separate commits.
|
||||
- Each commit must be independently reviewable.
|
||||
- Never combine unrelated changes in a single commit.
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
# Stage specified files and create a commit.
|
||||
# Usage: bash scripts/commit.sh --message "type(scope): description" [--] file1 file2 ...
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
echo "Usage: bash scripts/commit.sh --message MESSAGE [--] FILE [FILE...]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --message MESSAGE Commit message (required)"
|
||||
echo " --help Show this help"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " bash scripts/commit.sh --message \"feat(auth): add login endpoint\" src/auth.py tests/test_auth.py"
|
||||
echo " bash scripts/commit.sh --message \"chore: update deps\" -- requirements.txt"
|
||||
}
|
||||
|
||||
MESSAGE=""
|
||||
FILES=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--help) usage; exit 0 ;;
|
||||
--message)
|
||||
[[ -z "${2:-}" ]] && { echo "Error: --message requires a value."; exit 1; }
|
||||
MESSAGE="$2"; shift 2 ;;
|
||||
--) shift; FILES+=("$@"); break ;;
|
||||
-*) echo "Error: unknown option '$1'. Run with --help for usage."; exit 1 ;;
|
||||
*) FILES+=("$1"); shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
CURRENT_BRANCH="$(git branch --show-current)"
|
||||
|
||||
if [[ -z "$CURRENT_BRANCH" ]]; then
|
||||
echo "Error: not on a branch."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$CURRENT_BRANCH" == "main" || "$CURRENT_BRANCH" == "master" ]]; then
|
||||
echo "Error: refusing to commit directly on '$CURRENT_BRANCH'. Create or switch to a feature branch first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$MESSAGE" ]]; then
|
||||
echo "Error: --message is required."
|
||||
echo ""
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${#FILES[@]} -eq 0 ]]; then
|
||||
echo "Error: at least one file must be specified."
|
||||
echo ""
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git add -- "${FILES[@]}"
|
||||
git commit --message "$MESSAGE"
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# Show branch status and full diff for commit planning.
|
||||
# Usage: bash scripts/status.sh [BASE_BRANCH]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ "${1:-}" == "--help" ]]; then
|
||||
echo "Usage: bash scripts/status.sh [BASE_BRANCH]"
|
||||
echo ""
|
||||
echo "Prints the current branch, git status, and the full diff (staged and unstaged) for commit planning."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
BASE_BRANCH="${1:-main}"
|
||||
CURRENT_BRANCH="$(git branch --show-current)"
|
||||
|
||||
echo "=== current branch ==="
|
||||
echo "${CURRENT_BRANCH:-detached HEAD}"
|
||||
|
||||
if git rev-parse --verify "$BASE_BRANCH" >/dev/null 2>&1 && [[ -n "$CURRENT_BRANCH" && "$CURRENT_BRANCH" != "$BASE_BRANCH" ]]; then
|
||||
echo ""
|
||||
echo "=== commits ahead of $BASE_BRANCH ==="
|
||||
git --no-pager log --oneline "$BASE_BRANCH..$CURRENT_BRANCH"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== git status ==="
|
||||
git status --short --branch
|
||||
|
||||
echo ""
|
||||
echo "=== staged diff ==="
|
||||
git diff --staged
|
||||
|
||||
echo ""
|
||||
echo "=== unstaged diff ==="
|
||||
git diff
|
||||
Reference in New Issue
Block a user