archive: move all generation-1 scripts to archive
- create_issue.sh: 800+ lines monster (functional but unmaintainable) - update_script_labels.sh: 15KB auto-update system (too complex) - get_issues.sh: 7KB grown over time (needs simplification) - update_issue.sh: 5KB functional (part of old system) Preparing clean slate for low-tech generation-2 system
This commit is contained in:
parent
b5eb30caa0
commit
78b70cf06b
4 changed files with 0 additions and 0 deletions
779
scripts/archive/create_issue_monster.sh
Executable file
779
scripts/archive/create_issue_monster.sh
Executable file
|
|
@ -0,0 +1,779 @@
|
|||
#!/bin/bash
|
||||
# scripts/create_issue.sh - Furt API Gateway Issue Creator
|
||||
# DEBUG VERSION with path fixes and diagnostic output
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Standard environment setup
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
if [ -f "$PROJECT_ROOT/.env" ]; then
|
||||
export $(cat "$PROJECT_ROOT/.env" | grep -v '^#' | xargs)
|
||||
fi
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
|
||||
log_debug() {
|
||||
if [[ "${DEBUG:-}" == "1" ]]; then
|
||||
echo -e "${CYAN}[DEBUG]${NC} $1" >&2;
|
||||
fi
|
||||
}
|
||||
|
||||
# Track new labels for auto-update (FIXED: Safe initialization)
|
||||
declare -A NEW_LABELS_CREATED=()
|
||||
|
||||
# === LABEL DEFINITIONS START ===
|
||||
# This section is auto-maintained by update_script_labels.sh
|
||||
# DO NOT EDIT MANUALLY - Changes will be overwritten
|
||||
declare -A LABEL_DEFINITIONS=(
|
||||
["hugo-integration"]="color:ff7518;context:frontend;usage:hugo_templates,integration"
|
||||
["service-newsletter"]="color:ff6b6b;context:newsletter;usage:newsletter_integration"
|
||||
["service-analytics"]="color:1d76db;context:service_integration;usage:service_specific"
|
||||
["ready-for-deployment"]="color:28a745;context:deploy_ready;usage:status_updates"
|
||||
["service-clean-test4"]="color:1d76db;context:service_integration;usage:service_specific"
|
||||
["service-completely-absolut-new7"]="color:1d76db;context:service_integration;usage:service_specific"
|
||||
["service-completely-absolut-new9"]="color:1d76db;context:service_integration;usage:service_specific"
|
||||
["service-completely-absolut-new8"]="color:1d76db;context:service_integration;usage:service_specific"
|
||||
["performance"]="color:fbca04;context:optimization;usage:performance_template,architecture_template"
|
||||
["bug"]="color:d73a4a;context:error;usage:bug_template,status_updates"
|
||||
["question"]="color:d876e3;context:discussion;usage:question_template"
|
||||
["service-formular2mail"]="color:1d76db;context:formular2mail;usage:formular2mail_integration"
|
||||
["good-first-issue"]="color:7057ff;context:beginner_friendly;usage:manual_assignment"
|
||||
["service-completely-absolut-new10"]="color:1d76db;context:service_integration;usage:service_specific"
|
||||
["service-completely-absolut-new11"]="color:1d76db;context:service_integration;usage:service_specific"
|
||||
["breaking-change"]="color:d73a4a;context:breaking;usage:api_templates,architecture_template"
|
||||
["service-request"]="color:7057ff;context:new_service;usage:service_templates,status_updates"
|
||||
["service-debug-test"]="color:1d76db;context:service_integration;usage:service_specific"
|
||||
["low-priority"]="color:0e8a16;context:nice_to_have;usage:all_templates"
|
||||
["blocked"]="color:d73a4a;context:blocked;usage:status_updates"
|
||||
["low-tech"]="color:6f42c1;context:low_tech_principle;usage:architecture_template,performance_template,security_template"
|
||||
["deployment"]="color:ff7518;context:deployment;usage:deployment_template"
|
||||
["gateway"]="color:0052cc;context:gateway_core;usage:architecture_template,performance_template,service_templates"
|
||||
["service-sagjan"]="color:1d76db;context:sagjan;usage:sagjan_integration"
|
||||
["work-in-progress"]="color:fbca04;context:active;usage:status_updates"
|
||||
["service-debug-check-final2"]="color:1d76db;context:service_integration;usage:service_specific"
|
||||
["digital-sovereignty"]="color:6f42c1;context:digital_sovereignty;usage:architecture_template,performance_template,security_template"
|
||||
["security"]="color:28a745;context:security_review;usage:security_template,architecture_template"
|
||||
["architecture"]="color:d4c5f9;context:design;usage:architecture_template,gateway"
|
||||
["configuration"]="color:f9d71c;context:config_management;usage:deployment_template,architecture_template"
|
||||
["needs-review"]="color:0e8a16;context:review;usage:status_updates"
|
||||
["help-wanted"]="color:159818;context:community_help;usage:manual_assignment"
|
||||
["service-whatever-you-want"]="color:1d76db;context:service_integration;usage:service_specific"
|
||||
["api-contract"]="color:5319e7;context:api_design;usage:api_templates,service_templates"
|
||||
["enhancement"]="color:84b6eb;context:improvement;usage:all_templates"
|
||||
["high-priority"]="color:d73a4a;context:urgent;usage:all_templates"
|
||||
["testing"]="color:f9d71c;context:testing;usage:testing_template,integration"
|
||||
["test-all-templates"]="color:ff0000;context:test;usage:all_templates"
|
||||
)
|
||||
|
||||
# Extract label info
|
||||
get_label_color() { echo "${LABEL_DEFINITIONS[$1]}" | cut -d';' -f1 | cut -d':' -f2; }
|
||||
get_label_context() { echo "${LABEL_DEFINITIONS[$1]}" | cut -d';' -f2 | cut -d':' -f2; }
|
||||
get_label_usage() { echo "${LABEL_DEFINITIONS[$1]}" | cut -d';' -f3 | cut -d':' -f2; }
|
||||
|
||||
# Check if label is valid for context
|
||||
is_label_valid_for_context() {
|
||||
local label="$1"
|
||||
local context="$2"
|
||||
local usage=$(get_label_usage "$label")
|
||||
[[ "$usage" == *"$context"* ]] || [[ "$usage" == "all_templates" ]]
|
||||
}
|
||||
# === LABEL DEFINITIONS END ===
|
||||
|
||||
# === TEMPLATE LABEL MAPPINGS START ===
|
||||
# Auto-generated template to label mappings
|
||||
declare -A TEMPLATE_LABELS=(
|
||||
["performance"]="performance,low-priority,low-tech,gateway,digital-sovereignty,enhancement,high-priority,test-all-templates"
|
||||
["bug"]="bug,low-priority,enhancement,high-priority,test-all-templates"
|
||||
["api"]="breaking-change,low-priority,api-contract,enhancement,high-priority,test-all-templates"
|
||||
["service"]="low-priority,gateway,api-contract,enhancement,high-priority,test-all-templates"
|
||||
["deployment"]="low-priority,deployment,configuration,enhancement,high-priority,test-all-templates"
|
||||
["security"]="low-priority,low-tech,digital-sovereignty,security,enhancement,high-priority,test-all-templates"
|
||||
["architecture"]="performance,breaking-change,low-priority,low-tech,gateway,digital-sovereignty,security,architecture,configuration,enhancement,high-priority,test-all-templates"
|
||||
["hugo"]="hugo-integration,low-priority,enhancement,high-priority,test-all-templates"
|
||||
)
|
||||
# === TEMPLATE LABEL MAPPINGS END ===
|
||||
|
||||
# Load existing labels from repository
|
||||
declare -A LABEL_IDS
|
||||
|
||||
load_existing_labels() {
|
||||
if [[ -z "${GITEA_URL:-}" ]] || [[ -z "${GITEA_TOKEN:-}" ]]; then
|
||||
log_error "GITEA_URL and GITEA_TOKEN must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Loading existing labels from repository..."
|
||||
|
||||
local response=$(curl -s "$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/labels" \
|
||||
-H "Authorization: token $GITEA_TOKEN")
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
log_error "Failed to fetch labels from repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while IFS= read -r line; do
|
||||
local name=$(echo "$line" | jq -r '.name')
|
||||
local id=$(echo "$line" | jq -r '.id')
|
||||
LABEL_IDS["$name"]="$id"
|
||||
done < <(echo "$response" | jq -c '.[]')
|
||||
|
||||
log_info "Loaded ${#LABEL_IDS[@]} existing labels"
|
||||
}
|
||||
|
||||
# FIXED: Silent version of ensure_label_exists (no stdout pollution!)
|
||||
ensure_label_exists_silent() {
|
||||
local name="$1"
|
||||
local color="${2:-ff6b6b}"
|
||||
local description="${3:-Auto-generated label}"
|
||||
local usage="${4:-manual_assignment}" # ADDED: usage parameter
|
||||
|
||||
log_debug "Checking label: $name"
|
||||
|
||||
if [[ -n "${LABEL_IDS[$name]:-}" ]]; then
|
||||
log_debug "Label $name already exists (ID: ${LABEL_IDS[$name]})"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_debug "Creating new label: $name with color $color"
|
||||
|
||||
# Create label (redirect output to prevent stdout mixing)
|
||||
local response=$(curl -s -w "\n%{http_code}" -X POST \
|
||||
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/labels" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"name\": \"$name\",
|
||||
\"color\": \"$color\",
|
||||
\"description\": \"$description\"
|
||||
}" 2>/dev/null)
|
||||
|
||||
local http_code=$(echo "$response" | tail -n1)
|
||||
local response_body=$(echo "$response" | head -n -1)
|
||||
|
||||
if [[ "$http_code" == "201" ]]; then
|
||||
local new_id=$(echo "$response_body" | jq -r '.id')
|
||||
LABEL_IDS["$name"]="$new_id"
|
||||
|
||||
# FIXED: Track for auto-update with correct usage
|
||||
NEW_LABELS_CREATED["$name"]="$color:auto_generated:$usage"
|
||||
log_debug "Successfully created label $name (ID: $new_id)"
|
||||
log_debug "Added to NEW_LABELS_CREATED: $name -> ${NEW_LABELS_CREATED[$name]}"
|
||||
return 0
|
||||
else
|
||||
log_debug "Failed to create label $name (HTTP: $http_code)"
|
||||
log_debug "Response: $response_body"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Process labels for template (updates global arrays, no output)
|
||||
process_labels_for_template() {
|
||||
local template="$1"
|
||||
shift
|
||||
local additional_labels=("$@")
|
||||
|
||||
log_debug "Processing labels for template: $template"
|
||||
log_debug "Additional labels: ${additional_labels[*]}"
|
||||
|
||||
# Get template labels
|
||||
local template_labels_string="${TEMPLATE_LABELS[$template]:-}"
|
||||
local all_labels=()
|
||||
|
||||
# Add template labels
|
||||
if [[ -n "$template_labels_string" ]]; then
|
||||
IFS=',' read -ra template_labels <<< "$template_labels_string"
|
||||
all_labels+=("${template_labels[@]}")
|
||||
log_debug "Template labels: ${template_labels[*]}"
|
||||
fi
|
||||
|
||||
# Add additional labels
|
||||
all_labels+=("${additional_labels[@]}")
|
||||
log_debug "All labels to process: ${all_labels[*]}"
|
||||
|
||||
# Process all labels and ensure they exist
|
||||
for label in "${all_labels[@]}"; do
|
||||
log_debug "Processing label: $label"
|
||||
|
||||
# Process both known and unknown labels
|
||||
if [[ -n "${LABEL_DEFINITIONS[$label]:-}" ]]; then
|
||||
log_debug "Known label: $label"
|
||||
# Known label - use defined color and context
|
||||
local color=$(get_label_color "$label")
|
||||
local context=$(get_label_context "$label")
|
||||
|
||||
ensure_label_exists_silent "$label" "$color" "Furt: $context"
|
||||
else
|
||||
log_debug "Unknown label: $label - creating with smart defaults"
|
||||
# Unknown label - auto-create with smart defaults
|
||||
local default_color="ff6b6b"
|
||||
local default_context="auto_generated"
|
||||
|
||||
# Smart defaults based on label pattern
|
||||
if [[ "$label" == service-* ]]; then
|
||||
default_color="1d76db"
|
||||
default_context="service_integration"
|
||||
default_usage="service_specific" # FIXED: Not all_templates!
|
||||
log_debug "Service label detected - using blue color and service_specific usage"
|
||||
elif [[ "$label" == *-priority ]]; then
|
||||
default_color="d73a4a"
|
||||
default_context="priority_level"
|
||||
default_usage="priority_management"
|
||||
log_debug "Priority label detected - using red color"
|
||||
elif [[ "$label" == hugo-* ]]; then
|
||||
default_color="ff7518"
|
||||
default_context="frontend_integration"
|
||||
default_usage="hugo_integration"
|
||||
log_debug "Hugo label detected - using orange color"
|
||||
else
|
||||
default_usage="manual_assignment"
|
||||
fi
|
||||
|
||||
ensure_label_exists_silent "$label" "$default_color" "Furt: $default_context"
|
||||
|
||||
# FIXED: Track with correct usage
|
||||
if [[ -n "${LABEL_IDS[$label]:-}" ]] && [[ -n "${NEW_LABELS_CREATED[$label]:-}" ]]; then
|
||||
NEW_LABELS_CREATED["$label"]="$default_color:$default_context:$default_usage"
|
||||
log_debug "Updated NEW_LABELS_CREATED with correct usage: $label -> $default_color:$default_context:$default_usage"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Debug: Check if this label was newly created
|
||||
if [[ -n "${LABEL_IDS[$label]:-}" ]]; then
|
||||
if [[ -n "${NEW_LABELS_CREATED[$label]:-}" ]]; then
|
||||
log_debug " → Label $label was newly created and tracked"
|
||||
else
|
||||
log_debug " → Label $label already existed"
|
||||
fi
|
||||
else
|
||||
log_warning "Failed to process label: $label"
|
||||
fi
|
||||
done
|
||||
|
||||
# Debug: Check NEW_LABELS_CREATED at end of processing
|
||||
log_debug "NEW_LABELS_CREATED after processing: ${#NEW_LABELS_CREATED[@]} entries"
|
||||
if [[ "${#NEW_LABELS_CREATED[@]}" -gt 0 ]] 2>/dev/null; then
|
||||
for label_name in "${!NEW_LABELS_CREATED[@]}"; do
|
||||
log_debug " - $label_name: ${NEW_LABELS_CREATED[$label_name]}"
|
||||
done
|
||||
else
|
||||
log_debug " (no entries in NEW_LABELS_CREATED array)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Build JSON from already processed labels (pure function, no side effects)
|
||||
build_labels_json_from_processed() {
|
||||
local template="$1"
|
||||
shift
|
||||
local additional_labels=("$@")
|
||||
|
||||
log_debug "Building JSON from processed labels"
|
||||
|
||||
# Get template labels
|
||||
local template_labels_string="${TEMPLATE_LABELS[$template]:-}"
|
||||
local all_labels=()
|
||||
|
||||
# Add template labels
|
||||
if [[ -n "$template_labels_string" ]]; then
|
||||
IFS=',' read -ra template_labels <<< "$template_labels_string"
|
||||
all_labels+=("${template_labels[@]}")
|
||||
fi
|
||||
|
||||
# Add additional labels
|
||||
all_labels+=("${additional_labels[@]}")
|
||||
|
||||
# Collect IDs from already processed labels
|
||||
local label_ids=()
|
||||
for label in "${all_labels[@]}"; do
|
||||
if [[ -n "${LABEL_IDS[$label]:-}" ]]; then
|
||||
label_ids+=("${LABEL_IDS[$label]}")
|
||||
log_debug "Added ID ${LABEL_IDS[$label]} for $label to JSON"
|
||||
else
|
||||
log_warning "No ID found for label: $label"
|
||||
fi
|
||||
done
|
||||
|
||||
log_debug "Final label IDs for JSON: ${label_ids[*]}"
|
||||
|
||||
# Build JSON array (clean output only!)
|
||||
if [[ ${#label_ids[@]} -gt 0 ]]; then
|
||||
printf '[%s]' "$(IFS=','; echo "${label_ids[*]}")"
|
||||
else
|
||||
echo "[]"
|
||||
fi
|
||||
}
|
||||
|
||||
# DEPRECATED: Old build_labels_json function (kept for compatibility)
|
||||
build_labels_json() {
|
||||
local template="$1"
|
||||
shift
|
||||
local additional_labels=("$@")
|
||||
|
||||
log_debug "Building labels for template: $template"
|
||||
log_debug "Additional labels: ${additional_labels[*]}"
|
||||
|
||||
# Get template labels
|
||||
local template_labels_string="${TEMPLATE_LABELS[$template]:-}"
|
||||
local all_labels=()
|
||||
|
||||
# Add template labels
|
||||
if [[ -n "$template_labels_string" ]]; then
|
||||
IFS=',' read -ra template_labels <<< "$template_labels_string"
|
||||
all_labels+=("${template_labels[@]}")
|
||||
log_debug "Template labels: ${template_labels[*]}"
|
||||
fi
|
||||
|
||||
# Add additional labels
|
||||
all_labels+=("${additional_labels[@]}")
|
||||
log_debug "All labels to process: ${all_labels[*]}"
|
||||
|
||||
# FIXED: Ensure all labels exist and collect IDs (handles unknown labels!)
|
||||
local label_ids=()
|
||||
for label in "${all_labels[@]}"; do
|
||||
log_debug "Processing label: $label"
|
||||
|
||||
# Process both known and unknown labels
|
||||
if [[ -n "${LABEL_DEFINITIONS[$label]:-}" ]]; then
|
||||
log_debug "Known label: $label"
|
||||
# Known label - use defined color and context
|
||||
local color=$(get_label_color "$label")
|
||||
local context=$(get_label_context "$label")
|
||||
|
||||
ensure_label_exists_silent "$label" "$color" "Furt: $context"
|
||||
else
|
||||
log_debug "Unknown label: $label - creating with smart defaults"
|
||||
# FIXED: Unknown label - auto-create with smart defaults
|
||||
local default_color="ff6b6b"
|
||||
local default_context="auto_generated"
|
||||
|
||||
# Smart defaults based on label pattern
|
||||
if [[ "$label" == service-* ]]; then
|
||||
default_color="1d76db"
|
||||
default_context="service_integration"
|
||||
log_debug "Service label detected - using blue color"
|
||||
elif [[ "$label" == *-priority ]]; then
|
||||
default_color="d73a4a"
|
||||
default_context="priority_level"
|
||||
log_debug "Priority label detected - using red color"
|
||||
elif [[ "$label" == hugo-* ]]; then
|
||||
default_color="ff7518"
|
||||
default_context="frontend_integration"
|
||||
log_debug "Hugo label detected - using orange color"
|
||||
fi
|
||||
|
||||
ensure_label_exists_silent "$label" "$default_color" "Furt: $default_context"
|
||||
fi
|
||||
|
||||
# Collect ID if label was created/exists
|
||||
if [[ -n "${LABEL_IDS[$label]:-}" ]]; then
|
||||
label_ids+=("${LABEL_IDS[$label]}")
|
||||
log_debug "Added label ID: ${LABEL_IDS[$label]} for $label"
|
||||
|
||||
# Debug: Check if this label was newly created
|
||||
if [[ -n "${NEW_LABELS_CREATED[$label]:-}" ]]; then
|
||||
log_debug " → This label was newly created and tracked"
|
||||
else
|
||||
log_debug " → This label already existed"
|
||||
fi
|
||||
else
|
||||
log_warning "Failed to get ID for label: $label"
|
||||
fi
|
||||
done
|
||||
|
||||
log_debug "Final label IDs: ${label_ids[*]}"
|
||||
|
||||
# Debug: Check NEW_LABELS_CREATED at end of function
|
||||
log_debug "NEW_LABELS_CREATED at end of build_labels_json: ${#NEW_LABELS_CREATED[@]} entries"
|
||||
if [[ "${#NEW_LABELS_CREATED[@]}" -gt 0 ]] 2>/dev/null; then
|
||||
for label_name in "${!NEW_LABELS_CREATED[@]}"; do
|
||||
log_debug " - $label_name: ${NEW_LABELS_CREATED[$label_name]}"
|
||||
done
|
||||
else
|
||||
log_debug " (no entries in NEW_LABELS_CREATED array)"
|
||||
fi
|
||||
|
||||
# Build JSON array (clean output only!)
|
||||
if [[ ${#label_ids[@]} -gt 0 ]]; then
|
||||
printf '[%s]' "$(IFS=','; echo "${label_ids[*]}")"
|
||||
else
|
||||
echo "[]"
|
||||
fi
|
||||
}
|
||||
|
||||
# Show which labels are being used (AFTER JSON building to avoid stdout pollution)
|
||||
show_labels_used() {
|
||||
local template="$1"
|
||||
shift
|
||||
local additional_labels=("$@")
|
||||
|
||||
log_info "Labels used for this issue:"
|
||||
|
||||
# Show template labels
|
||||
local template_labels_string="${TEMPLATE_LABELS[$template]:-}"
|
||||
if [[ -n "$template_labels_string" ]]; then
|
||||
IFS=',' read -ra template_labels <<< "$template_labels_string"
|
||||
for label in "${template_labels[@]}"; do
|
||||
if [[ -n "${LABEL_IDS[$label]:-}" ]]; then
|
||||
log_info " ✅ $label (ID: ${LABEL_IDS[$label]})"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Show additional labels (these may have been newly created)
|
||||
for label in "${additional_labels[@]}"; do
|
||||
if [[ -n "${LABEL_IDS[$label]:-}" ]]; then
|
||||
if [[ -n "${NEW_LABELS_CREATED[$label]:-}" ]]; then
|
||||
log_info " ✅ $label (ID: ${LABEL_IDS[$label]}) [NEW!]"
|
||||
else
|
||||
log_info " ✅ $label (ID: ${LABEL_IDS[$label]})"
|
||||
fi
|
||||
else
|
||||
log_warning " ❌ $label (failed to create)"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# FIXED: AUTO-UPDATE with safe array handling and correct path
|
||||
auto_update_scripts_if_needed() {
|
||||
# FIXED: Safe check for empty associative array
|
||||
local new_labels_count=0
|
||||
if [[ "${#NEW_LABELS_CREATED[@]}" -gt 0 ]] 2>/dev/null; then
|
||||
new_labels_count=${#NEW_LABELS_CREATED[@]}
|
||||
fi
|
||||
|
||||
log_debug "Auto-update check: $new_labels_count new labels created"
|
||||
|
||||
# Debug: Show what's in NEW_LABELS_CREATED
|
||||
if [[ $new_labels_count -gt 0 ]]; then
|
||||
log_debug "NEW_LABELS_CREATED contents:"
|
||||
for label_name in "${!NEW_LABELS_CREATED[@]}"; do
|
||||
log_debug " - $label_name: ${NEW_LABELS_CREATED[$label_name]}"
|
||||
done
|
||||
else
|
||||
log_debug "NEW_LABELS_CREATED is empty or unset"
|
||||
# Debug: Try to list what's in the array anyway
|
||||
if [[ "${#NEW_LABELS_CREATED[@]}" -gt 0 ]] 2>/dev/null; then
|
||||
for key in "${!NEW_LABELS_CREATED[@]}"; do
|
||||
log_debug " Found key: $key"
|
||||
done
|
||||
else
|
||||
log_debug " Array iteration failed - truly empty"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $new_labels_count -eq 0 ]]; then
|
||||
log_debug "No new labels created - skipping auto-update"
|
||||
return 0 # No new labels, no update needed
|
||||
fi
|
||||
|
||||
log_info "🔄 Auto-updating scripts with $new_labels_count new labels..."
|
||||
|
||||
# Check if update script exists
|
||||
local update_script="$SCRIPT_DIR/update_script_labels.sh"
|
||||
if [[ ! -f "$update_script" ]]; then
|
||||
log_warning "Update script not found: $update_script"
|
||||
log_warning "Skipping auto-update"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ ! -x "$update_script" ]]; then
|
||||
log_warning "Update script not executable: $update_script"
|
||||
log_warning "Making executable..."
|
||||
chmod +x "$update_script"
|
||||
fi
|
||||
|
||||
# Add new labels to registry
|
||||
for label_name in "${!NEW_LABELS_CREATED[@]}"; do
|
||||
local label_info="${NEW_LABELS_CREATED[$label_name]}"
|
||||
local color=$(echo "$label_info" | cut -d':' -f1)
|
||||
local context=$(echo "$label_info" | cut -d':' -f2)
|
||||
local usage=$(echo "$label_info" | cut -d':' -f3)
|
||||
|
||||
log_info "Adding '$label_name' to registry..."
|
||||
|
||||
# Add to registry (suppressing output to avoid noise)
|
||||
FURT_AUTO_UPDATE=true "$update_script" add "$label_name" "$color" "$context" "$usage" >/dev/null 2>&1 || {
|
||||
log_warning "Failed to add $label_name to registry"
|
||||
}
|
||||
done
|
||||
|
||||
# Update all scripts with new labels
|
||||
log_info "Synchronizing all scripts..."
|
||||
"$update_script" update >/dev/null 2>&1 || {
|
||||
log_warning "Failed to update scripts"
|
||||
return 0
|
||||
}
|
||||
|
||||
log_success "✅ All scripts automatically synchronized with new labels!"
|
||||
|
||||
# Show what was added
|
||||
echo ""
|
||||
echo "🆕 New labels created and synchronized:"
|
||||
for label_name in "${!NEW_LABELS_CREATED[@]}"; do
|
||||
echo " - $label_name (ID: ${LABEL_IDS[$label_name]})"
|
||||
done
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Create issue templates
|
||||
create_service_issue() {
|
||||
local service_name="${1:-newsletter}"
|
||||
|
||||
log_debug "Creating service issue for: $service_name"
|
||||
|
||||
local title="[SERVICE] $service_name für Furt Gateway"
|
||||
local body="# Service-Request: $service_name
|
||||
|
||||
## 🏷️ Service-Details
|
||||
**Name:** $service_name
|
||||
**Port:** TBD
|
||||
**Zweck:** [Service-Beschreibung]
|
||||
|
||||
## 📝 Funktionsanforderungen
|
||||
- [ ] [Anforderung 1]
|
||||
- [ ] [Anforderung 2]
|
||||
- [ ] [Anforderung 3]
|
||||
|
||||
## 🔗 Gateway-Integration
|
||||
- [ ] **Routing:** \`/v1/$service_name/*\`
|
||||
- [ ] **Auth:** API-Key required
|
||||
- [ ] **Rate-Limiting:** TBD req/min
|
||||
- [ ] **Health-Check:** \`/health\`
|
||||
|
||||
## 🎯 Hugo-Integration
|
||||
- [ ] **Shortcode:** \`{{< furt-$service_name >}}\`
|
||||
- [ ] **JavaScript-Client**
|
||||
- [ ] **CSS-Styling**
|
||||
|
||||
## ⚡ Priorität
|
||||
🔥 **Hoch** - benötigt für Website-Launch"
|
||||
|
||||
# Process labels first, then build JSON
|
||||
local service_label="service-$service_name"
|
||||
log_debug "Service label to add: $service_label"
|
||||
|
||||
# First: Process all labels (this updates global arrays)
|
||||
process_labels_for_template "service" "$service_label"
|
||||
|
||||
# Then: Build JSON from already-processed labels (pure function, no side effects)
|
||||
local labels_json=$(build_labels_json_from_processed "service" "$service_label")
|
||||
|
||||
# Show which labels are being used (AFTER processing when labels are actually created)
|
||||
show_labels_used "service" "$service_label"
|
||||
|
||||
create_issue "$title" "$body" "$labels_json"
|
||||
}
|
||||
|
||||
create_architecture_issue() {
|
||||
local topic="${1:-middleware-optimization}"
|
||||
|
||||
local title="[ARCH] Gateway $topic"
|
||||
local body="# Architektur-Diskussion: $topic
|
||||
|
||||
## 🎯 Architektur-Thema
|
||||
[Beschreibung des Architektur-Themas]
|
||||
|
||||
## 📊 Aktuelle Situation
|
||||
- [Status Quo 1]
|
||||
- [Status Quo 2]
|
||||
|
||||
## 💡 Vorgeschlagene Änderung
|
||||
- [Vorschlag 1]
|
||||
- [Vorschlag 2]
|
||||
|
||||
## 🔄 Alternativen
|
||||
1. **Option A:** [Beschreibung]
|
||||
2. **Option B:** [Beschreibung]
|
||||
|
||||
## 📈 Betroffene Bereiche
|
||||
- [ ] Gateway-Performance
|
||||
- [ ] Service-Integration
|
||||
- [ ] Security
|
||||
- [ ] Configuration-Management"
|
||||
|
||||
# Process labels first, then build JSON
|
||||
process_labels_for_template "architecture"
|
||||
local labels_json=$(build_labels_json_from_processed "architecture")
|
||||
|
||||
create_issue "$title" "$body" "$labels_json"
|
||||
}
|
||||
|
||||
# Generic template creator
|
||||
create_generic_issue() {
|
||||
local template="$1"
|
||||
local component="${2:-gateway}"
|
||||
local description="[Beschreibung hinzufügen]"
|
||||
|
||||
# Safe parameter handling for $3
|
||||
if [[ $# -ge 3 ]] && [[ -n "${3:-}" ]]; then
|
||||
description="$3"
|
||||
fi
|
||||
|
||||
log_debug "Creating $template issue for: $component"
|
||||
|
||||
local title_prefix
|
||||
case "$template" in
|
||||
api) title_prefix="[API]" ;;
|
||||
security) title_prefix="[SEC]" ;;
|
||||
hugo) title_prefix="[HUGO]" ;;
|
||||
deployment) title_prefix="[DEPLOY]" ;;
|
||||
bug) title_prefix="[BUG]" ;;
|
||||
*) title_prefix="[${template^^}]" ;;
|
||||
esac
|
||||
|
||||
local title="$title_prefix $component $(echo ${template^} | sed 's/api/API Contract/')"
|
||||
local body="# ${template^}: $component
|
||||
|
||||
## 📝 ${template^}-Details
|
||||
**Komponente:** $component
|
||||
**Beschreibung:** $description
|
||||
|
||||
## 🎯 Anforderungen
|
||||
- [ ] [Anforderung 1]
|
||||
- [ ] [Anforderung 2]
|
||||
- [ ] [Anforderung 3]
|
||||
|
||||
## ✅ Definition of Done
|
||||
- [ ] [DoD Kriterium 1]
|
||||
- [ ] [DoD Kriterium 2]
|
||||
- [ ] [DoD Kriterium 3]"
|
||||
|
||||
# Process labels first, then build JSON
|
||||
process_labels_for_template "$template"
|
||||
local labels_json=$(build_labels_json_from_processed "$template")
|
||||
|
||||
show_labels_used "$template"
|
||||
create_issue "$title" "$body" "$labels_json"
|
||||
}
|
||||
|
||||
# Show usage information
|
||||
show_usage() {
|
||||
echo "🎯 Furt API-Gateway Issue Creator (Debug Version)"
|
||||
echo ""
|
||||
echo "Usage: $0 [TEMPLATE] [OPTIONS]"
|
||||
echo ""
|
||||
echo "📋 Available Templates:"
|
||||
echo " service [name] New service for gateway (default: newsletter)"
|
||||
echo " architecture [topic] Gateway architecture discussion (default: middleware-optimization)"
|
||||
echo " performance [comp] Performance optimization (default: gateway)"
|
||||
echo " api [service] API contract update (default: formular2mail)"
|
||||
echo " security [comp] Security review/issue (default: gateway)"
|
||||
echo " bug [comp] [desc] Bug report (default: gateway)"
|
||||
echo " hugo [feature] Hugo integration (default: shortcode)"
|
||||
echo " deployment [comp] Deployment issue (default: gateway)"
|
||||
echo " custom Custom issue (interactive)"
|
||||
echo ""
|
||||
echo "🚀 Examples:"
|
||||
echo " $0 service newsletter # Create newsletter service request"
|
||||
echo " $0 architecture rate-limiting # Discuss rate limiting architecture"
|
||||
echo " $0 performance gateway # Gateway performance optimization"
|
||||
echo " $0 custom # Interactive custom issue"
|
||||
echo ""
|
||||
echo "🔧 Debug Mode:"
|
||||
echo " Set DEBUG=1 for verbose debug output"
|
||||
}
|
||||
|
||||
# Generic issue creation
|
||||
create_issue() {
|
||||
local title="$1"
|
||||
local body="$2"
|
||||
local labels_json="$3"
|
||||
|
||||
log_info "Creating issue: $title"
|
||||
log_debug "Labels JSON: $labels_json"
|
||||
|
||||
local response=$(curl -s -w "\n%{http_code}" -X POST \
|
||||
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/issues" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": $(echo "$title" | jq -R .),
|
||||
\"body\": $(echo "$body" | jq -R -s .),
|
||||
\"labels\": $labels_json
|
||||
}")
|
||||
|
||||
local http_code=$(echo "$response" | tail -n1)
|
||||
local response_body=$(echo "$response" | head -n -1)
|
||||
|
||||
if [[ "$http_code" == "201" ]]; then
|
||||
local issue_number=$(echo "$response_body" | jq -r '.number')
|
||||
local issue_url=$(echo "$response_body" | jq -r '.html_url')
|
||||
|
||||
log_success "Issue #$issue_number created!"
|
||||
echo "🔗 $issue_url"
|
||||
else
|
||||
log_error "Failed to create issue (HTTP: $http_code)"
|
||||
log_error "Response: $response_body"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
local template="${1:-help}"
|
||||
|
||||
# Enable debug if requested
|
||||
if [[ "${DEBUG:-}" == "1" ]]; then
|
||||
log_info "Debug mode enabled"
|
||||
fi
|
||||
|
||||
if [[ "$template" == "help" ]] || [[ "$template" == "--help" ]] || [[ "$template" == "-h" ]]; then
|
||||
show_usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Load existing labels
|
||||
load_existing_labels
|
||||
|
||||
case "$template" in
|
||||
service)
|
||||
create_service_issue "${2:-newsletter}"
|
||||
;;
|
||||
architecture)
|
||||
create_architecture_issue "${2:-middleware-optimization}"
|
||||
;;
|
||||
performance)
|
||||
local component="${2:-gateway}"
|
||||
local title="[PERF] $component Performance-Optimierung"
|
||||
local body="# Performance-Optimierung: $component"
|
||||
|
||||
process_labels_for_template "performance"
|
||||
local labels_json=$(build_labels_json_from_processed "performance")
|
||||
|
||||
create_issue "$title" "$body" "$labels_json"
|
||||
;;
|
||||
api|security|hugo|deployment|bug)
|
||||
if [[ $# -ge 3 ]]; then
|
||||
create_generic_issue "$template" "${2:-gateway}" "$3"
|
||||
else
|
||||
create_generic_issue "$template" "${2:-gateway}"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
log_error "Unknown template: $template"
|
||||
show_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# FIXED: AUTO-UPDATE: Automatically sync scripts if new labels were created
|
||||
auto_update_scripts_if_needed
|
||||
}
|
||||
|
||||
# Run if executed directly
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
main "$@"
|
||||
fi
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue