Files
repo-foundry/src/lib/plan.sh
T
Tirsvad 4058ab4e3e Exclude .claude, .agents and AGENTS.md from git in the new project
After the templates are copied, create-project.sh adds /.claude, /.agents and
/AGENTS.md to .git/info/exclude of the new project as its own step, "Git
excludes". No .gitignore or tracked file changes and nothing is committed.
The step is skipped when the framework steps are skipped, and a path git
already tracks stays tracked and is named in the step.

The .git/info/exclude code of exclude_env_file moves into the shared helper
exclude_from_git (git.sh), which both now use; the .env behavior is unchanged.

Refs #66
Task: MIL-009#2
2026-10-08 14:06:37 +08:00

60 lines
2.8 KiB
Bash

# shellcheck shell=bash
# shellcheck disable=SC2004,SC2034,SC2154 # shared state and arrays are declared in constants.sh
# plan.sh - Printing what the script is about to do.
#
# Part of create-project.sh: sourced by it, never run on its own.
#
# Provides: local_plan_note, print_plan
# local_plan_note: what will happen to the project directory.
local_plan_note() {
local dir="${PROJECT[directory]}"
case "${STATE[local_dir]}" in
missing) printf 'create %s (new directory), git on %s, no commit' "$dir" "$DEFAULT_BRANCH" ;;
empty) printf 'use the existing empty directory %s (you will be asked)' "$dir" ;;
*) printf 'use the existing directory %s, which has files (you will be asked)' "$dir" ;;
esac
}
print_plan() {
local gitea_action github_action origin_note
say ""
say "Plan:"
if ((STATE[reuse_gitea])); then
gitea_action="reuse the existing repository (you will be asked to confirm)"
elif [[ -n ${PROJECT[license]} ]]; then
gitea_action="create (${PROJECT[visibility]}) with the ${PROJECT[license]} license$(license_note)"
else
gitea_action="create (${PROJECT[visibility]}), empty"
fi
say "$(printf ' %-18s: %s %s' "Gitea repository" "$gitea_action" "$(repo_url gitea)")"
if ((PROJECT[has_github])); then
if ((STATE[reuse_github])); then
github_action="reuse the existing empty repository (you will be asked to confirm)"
else
github_action="create (${PROJECT[visibility]}), empty"
fi
say "$(printf ' %-18s: %s %s' "GitHub repository" "$github_action" "$(repo_url github)")"
say "$(printf ' %-18s: %s' "Push mirror" "Gitea -> GitHub every ${CONFIG[MIRROR_INTERVAL]}")"
else
say "$(printf ' %-18s: %s' "GitHub repository" "not used")"
say "$(printf ' %-18s: %s' "Push mirror" "not used")"
fi
if ((STATE[is_ssh_ok])); then
origin_note="SSH (the SSH test passed)"
else
origin_note="HTTPS (SSH test: ${STATE[ssh_note]})"
fi
say "$(printf ' %-18s: %s' "Local project" "$(local_plan_note)")"
say "$(printf ' %-18s: %s' "Local origin" "will use $origin_note")"
if ((STATE[is_ssh_ok])); then
say "$(printf ' %-18s: %s' "Framework" "add $(framework_url) as a submodule")"
say "$(printf ' %-18s: %s' "Skills and hooks" "install once; plan gate $(yes_no "${PROJECT[is_plan_gate_enabled]}")")"
say "$(printf ' %-18s: %s' "Templates" "AGENTS.md and docs/artifact-registry.md (you are asked before a file is replaced)")"
say "$(printf ' %-18s: %s' "Git excludes" "${FRAMEWORK_EXCLUDES[*]} go into .git/info/exclude (no tracked file changes)")"
else
say "$(printf ' %-18s: %s' "Framework" "NOT possible without SSH to Gitea; you will be asked whether to go on without it")"
fi
say "$(printf ' %-18s: %s' "Project .env" "you are asked whether to create it ($(env_file_key_list))")"
}