**Motivations:** - Align master with current codebase (token from projects/<id>/.secrets/<env>/ia_token) - Id resolution by mail To or by API token; no slug **Root causes:** - Token moved from conf.json to .secrets/<env>/ia_token; env from directory name **Correctifs:** - Server and scripts resolve project+env by scanning all projects and envs **Evolutions:** - tickets-fetch-inbox routes by To address; notary-ai agents and API doc updated **Pages affectées:** - ai_working_help/server.js, docs, project_config.py, lib/project_config.sh - projects/README.md, lecoffreio/docs/API.md, gitea-issues/tickets-fetch-inbox.py
46 lines
1.2 KiB
Bash
Executable File
46 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Create a local branch for an issue. Branch name: issue/<number> (safe, short).
|
|
# Base branch defaults to "test"; ensure it is up to date (fetch + reset to origin/base).
|
|
# Usage: ./create-branch-for-issue.sh <issue_number> [base_branch]
|
|
#
|
|
set -euo pipefail
|
|
|
|
GITEA_ISSUES_DIR="${GITEA_ISSUES_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
|
|
# shellcheck source=lib.sh
|
|
source "${GITEA_ISSUES_DIR}/lib.sh"
|
|
|
|
if [[ $# -lt 1 ]]; then
|
|
log_err "Usage: $0 <issue_number> [base_branch]"
|
|
exit 1
|
|
fi
|
|
|
|
ISSUE_NUM="$1"
|
|
BASE="${2:-test}"
|
|
|
|
require_git_root || exit 1
|
|
|
|
if git show-ref --quiet "refs/heads/issue/${ISSUE_NUM}"; then
|
|
log_info "Branch issue/${ISSUE_NUM} already exists. Checking it out."
|
|
git checkout "issue/${ISSUE_NUM}"
|
|
echo "issue/${ISSUE_NUM}"
|
|
exit 0
|
|
fi
|
|
|
|
if ! git show-ref --quiet "refs/heads/${BASE}"; then
|
|
log_err "Base branch ${BASE} does not exist locally."
|
|
exit 1
|
|
fi
|
|
|
|
git fetch origin
|
|
if git show-ref --quiet "refs/remotes/origin/${BASE}"; then
|
|
git checkout "${BASE}"
|
|
git reset --hard "origin/${BASE}"
|
|
else
|
|
git checkout "${BASE}"
|
|
fi
|
|
|
|
git checkout -b "issue/${ISSUE_NUM}"
|
|
log_info "Created and checked out branch issue/${ISSUE_NUM} from ${BASE}."
|
|
echo "issue/${ISSUE_NUM}"
|