feat: functional monster script (anti-pattern warning)
This commit is contained in:
parent
56ed910884
commit
b5eb30caa0
3 changed files with 498 additions and 119 deletions
|
|
@ -1,5 +1,3 @@
|
||||||
#!/bin/bash
|
|
||||||
# config/labels.registry
|
|
||||||
# Central Label Registry for Furt API Gateway Project
|
# Central Label Registry for Furt API Gateway Project
|
||||||
# Format: name:color:context:usage_contexts
|
# Format: name:color:context:usage_contexts
|
||||||
# This file is the single source of truth for all labels
|
# This file is the single source of truth for all labels
|
||||||
|
|
@ -11,16 +9,26 @@ bug:d73a4a:error:bug_template,status_updates
|
||||||
question:d876e3:discussion:question_template
|
question:d876e3:discussion:question_template
|
||||||
|
|
||||||
# === COMPONENT CATEGORIES ===
|
# === COMPONENT CATEGORIES ===
|
||||||
gateway:0052cc:gateway_core:architecture,performance,service_templates
|
gateway:0052cc:gateway_core:architecture_template,performance_template,service_templates
|
||||||
performance:fbca04:optimization:performance_template,architecture
|
performance:fbca04:optimization:performance_template,architecture_template
|
||||||
architecture:d4c5f9:design:architecture_template,gateway
|
architecture:d4c5f9:design:architecture_template,gateway
|
||||||
security:28a745:security_review:security_template,gateway
|
security:28a745:security_review:security_template,architecture_template
|
||||||
configuration:f9d71c:config_management:deployment,architecture
|
configuration:f9d71c:config_management:deployment_template,architecture_template
|
||||||
|
|
||||||
# === SERVICE-SPECIFIC LABELS ===
|
# === SERVICE-SPECIFIC LABELS ===
|
||||||
service-formular2mail:1d76db:formular2mail:service_templates,integration
|
service-debug-check-final2:1d76db:service_integration:service_specific
|
||||||
service-sagjan:1d76db:sagjan:service_templates,integration
|
service-clean-test4:1d76db:service_integration:service_specific
|
||||||
service-newsletter:ff6b6b:newsletter:service_templates,integration
|
service-debug-test:1d76db:service_integration:service_specific
|
||||||
|
service-formular2mail:1d76db:formular2mail:formular2mail_integration
|
||||||
|
service-sagjan:1d76db:sagjan:sagjan_integration
|
||||||
|
service-newsletter:ff6b6b:newsletter:newsletter_integration
|
||||||
|
service-analytics:1d76db:service_integration:service_specific
|
||||||
|
service-whatever-you-want:1d76db:service_integration:service_specific
|
||||||
|
service-completely-absolut-new7:1d76db:service_integration:service_specific
|
||||||
|
service-completely-absolut-new8:1d76db:service_integration:service_specific
|
||||||
|
service-completely-absolut-new9:1d76db:service_integration:service_specific
|
||||||
|
service-completely-absolut-new10:1d76db:service_integration:service_specific
|
||||||
|
service-completely-absolut-new11:1d76db:service_integration:service_specific
|
||||||
|
|
||||||
# === WORKFLOW STATE LABELS ===
|
# === WORKFLOW STATE LABELS ===
|
||||||
work-in-progress:fbca04:active:status_updates
|
work-in-progress:fbca04:active:status_updates
|
||||||
|
|
@ -31,19 +39,20 @@ ready-for-deployment:28a745:deploy_ready:status_updates
|
||||||
# === INTEGRATION LABELS ===
|
# === INTEGRATION LABELS ===
|
||||||
hugo-integration:ff7518:frontend:hugo_templates,integration
|
hugo-integration:ff7518:frontend:hugo_templates,integration
|
||||||
api-contract:5319e7:api_design:api_templates,service_templates
|
api-contract:5319e7:api_design:api_templates,service_templates
|
||||||
breaking-change:d73a4a:breaking:api_templates,architecture
|
breaking-change:d73a4a:breaking:api_templates,architecture_template
|
||||||
|
|
||||||
# === PRIORITY LABELS ===
|
# === PRIORITY LABELS ===
|
||||||
high-priority:d73a4a:urgent:all_templates
|
high-priority:d73a4a:urgent:all_templates
|
||||||
low-priority:0e8a16:nice_to_have:all_templates
|
low-priority:0e8a16:nice_to_have:all_templates
|
||||||
|
|
||||||
# === META LABELS ===
|
# === META LABELS ===
|
||||||
low-tech:6f42c1:low_tech_principle:all_templates
|
low-tech:6f42c1:low_tech_principle:architecture_template,performance_template,security_template
|
||||||
digital-sovereignty:6f42c1:digital_sovereignty:all_templates
|
digital-sovereignty:6f42c1:digital_sovereignty:architecture_template,performance_template,security_template
|
||||||
good-first-issue:7057ff:beginner_friendly:all_templates
|
good-first-issue:7057ff:beginner_friendly:manual_assignment
|
||||||
help-wanted:159818:community_help:all_templates
|
help-wanted:159818:community_help:manual_assignment
|
||||||
|
|
||||||
# === DEPLOYMENT LABELS ===
|
# === DEPLOYMENT LABELS ===
|
||||||
deployment:ff7518:deployment:deployment_template
|
deployment:ff7518:deployment:deployment_template
|
||||||
testing:f9d71c:testing:testing_template,integration
|
testing:f9d71c:testing:testing_template,integration
|
||||||
documentation:0366d6:docs:documentation_template
|
|
||||||
|
test-all-templates:ff0000:test:all_templates
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# scripts/create_issue.sh - Furt API Gateway Issue Creator
|
# scripts/create_issue.sh - Furt API Gateway Issue Creator
|
||||||
# FINAL VERSION with all fixes: HTTP 422, stdout-mixing, array handling, unknown labels
|
# DEBUG VERSION with path fixes and diagnostic output
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
@ -17,12 +17,18 @@ GREEN='\033[0;32m'
|
||||||
BLUE='\033[0;34m'
|
BLUE='\033[0;34m'
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
YELLOW='\033[1;33m'
|
YELLOW='\033[1;33m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||||
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
||||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||||
log_warning() { echo -e "${YELLOW}[WARNING]${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)
|
# Track new labels for auto-update (FIXED: Safe initialization)
|
||||||
declare -A NEW_LABELS_CREATED=()
|
declare -A NEW_LABELS_CREATED=()
|
||||||
|
|
@ -31,24 +37,44 @@ declare -A NEW_LABELS_CREATED=()
|
||||||
# This section is auto-maintained by update_script_labels.sh
|
# This section is auto-maintained by update_script_labels.sh
|
||||||
# DO NOT EDIT MANUALLY - Changes will be overwritten
|
# DO NOT EDIT MANUALLY - Changes will be overwritten
|
||||||
declare -A LABEL_DEFINITIONS=(
|
declare -A LABEL_DEFINITIONS=(
|
||||||
["service-request"]="color:7057ff;context:new_service;usage:service_templates,status_updates"
|
|
||||||
["enhancement"]="color:84b6eb;context:improvement;usage:all_templates"
|
|
||||||
["bug"]="color:d73a4a;context:error;usage:bug_template,status_updates"
|
|
||||||
["gateway"]="color:0052cc;context:gateway_core;usage:architecture,performance,service_templates"
|
|
||||||
["performance"]="color:fbca04;context:optimization;usage:performance_template,architecture"
|
|
||||||
["architecture"]="color:d4c5f9;context:design;usage:architecture_template,gateway"
|
|
||||||
["security"]="color:28a745;context:security_review;usage:security_template,gateway"
|
|
||||||
["service-formular2mail"]="color:1d76db;context:formular2mail;usage:service_templates,integration"
|
|
||||||
["service-sagjan"]="color:1d76db;context:sagjan;usage:service_templates,integration"
|
|
||||||
["service-newsletter"]="color:ff6b6b;context:newsletter;usage:service_templates,integration"
|
|
||||||
["work-in-progress"]="color:fbca04;context:active;usage:status_updates"
|
|
||||||
["needs-review"]="color:0e8a16;context:review;usage:status_updates"
|
|
||||||
["hugo-integration"]="color:ff7518;context:frontend;usage:hugo_templates,integration"
|
["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"
|
["api-contract"]="color:5319e7;context:api_design;usage:api_templates,service_templates"
|
||||||
["breaking-change"]="color:d73a4a;context:breaking;usage:api_templates,architecture"
|
["enhancement"]="color:84b6eb;context:improvement;usage:all_templates"
|
||||||
["high-priority"]="color:d73a4a;context:urgent;usage:all_templates"
|
["high-priority"]="color:d73a4a;context:urgent;usage:all_templates"
|
||||||
["low-tech"]="color:6f42c1;context:low_tech_principle;usage:all_templates"
|
["testing"]="color:f9d71c;context:testing;usage:testing_template,integration"
|
||||||
["digital-sovereignty"]="color:6f42c1;context:digital_sovereignty;usage:all_templates"
|
["test-all-templates"]="color:ff0000;context:test;usage:all_templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Extract label info
|
# Extract label info
|
||||||
|
|
@ -68,14 +94,14 @@ is_label_valid_for_context() {
|
||||||
# === TEMPLATE LABEL MAPPINGS START ===
|
# === TEMPLATE LABEL MAPPINGS START ===
|
||||||
# Auto-generated template to label mappings
|
# Auto-generated template to label mappings
|
||||||
declare -A TEMPLATE_LABELS=(
|
declare -A TEMPLATE_LABELS=(
|
||||||
["service"]="service-request,enhancement,gateway,service-formular2mail,service-sagjan,service-newsletter,api-contract,high-priority,low-tech,digital-sovereignty"
|
["performance"]="performance,low-priority,low-tech,gateway,digital-sovereignty,enhancement,high-priority,test-all-templates"
|
||||||
["architecture"]="enhancement,gateway,performance,architecture,security,breaking-change,high-priority,low-tech,digital-sovereignty"
|
["bug"]="bug,low-priority,enhancement,high-priority,test-all-templates"
|
||||||
["performance"]="enhancement,gateway,performance,architecture,high-priority,low-tech,digital-sovereignty"
|
["api"]="breaking-change,low-priority,api-contract,enhancement,high-priority,test-all-templates"
|
||||||
["bug"]="bug,enhancement,gateway,service-formular2mail,service-sagjan,service-newsletter,work-in-progress,needs-review,high-priority,low-tech,digital-sovereignty"
|
["service"]="low-priority,gateway,api-contract,enhancement,high-priority,test-all-templates"
|
||||||
["security"]="security,gateway,enhancement,high-priority,low-tech,digital-sovereignty"
|
["deployment"]="low-priority,deployment,configuration,enhancement,high-priority,test-all-templates"
|
||||||
["hugo"]="hugo-integration,enhancement,gateway,service-formular2mail,service-sagjan,service-newsletter,api-contract,high-priority,low-tech,digital-sovereignty"
|
["security"]="low-priority,low-tech,digital-sovereignty,security,enhancement,high-priority,test-all-templates"
|
||||||
["api"]="api-contract,service-request,enhancement,gateway,service-formular2mail,service-sagjan,service-newsletter,breaking-change,high-priority,low-tech,digital-sovereignty"
|
["architecture"]="performance,breaking-change,low-priority,low-tech,gateway,digital-sovereignty,security,architecture,configuration,enhancement,high-priority,test-all-templates"
|
||||||
["deployment"]="enhancement,gateway,service-formular2mail,service-sagjan,service-newsletter,high-priority,low-tech,digital-sovereignty"
|
["hugo"]="hugo-integration,low-priority,enhancement,high-priority,test-all-templates"
|
||||||
)
|
)
|
||||||
# === TEMPLATE LABEL MAPPINGS END ===
|
# === TEMPLATE LABEL MAPPINGS END ===
|
||||||
|
|
||||||
|
|
@ -112,11 +138,17 @@ ensure_label_exists_silent() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
local color="${2:-ff6b6b}"
|
local color="${2:-ff6b6b}"
|
||||||
local description="${3:-Auto-generated label}"
|
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
|
if [[ -n "${LABEL_IDS[$name]:-}" ]]; then
|
||||||
|
log_debug "Label $name already exists (ID: ${LABEL_IDS[$name]})"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
log_debug "Creating new label: $name with color $color"
|
||||||
|
|
||||||
# Create label (redirect output to prevent stdout mixing)
|
# Create label (redirect output to prevent stdout mixing)
|
||||||
local response=$(curl -s -w "\n%{http_code}" -X POST \
|
local response=$(curl -s -w "\n%{http_code}" -X POST \
|
||||||
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/labels" \
|
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/labels" \
|
||||||
|
|
@ -135,20 +167,120 @@ ensure_label_exists_silent() {
|
||||||
local new_id=$(echo "$response_body" | jq -r '.id')
|
local new_id=$(echo "$response_body" | jq -r '.id')
|
||||||
LABEL_IDS["$name"]="$new_id"
|
LABEL_IDS["$name"]="$new_id"
|
||||||
|
|
||||||
# FIXED: Track for auto-update (but don't log here!)
|
# FIXED: Track for auto-update with correct usage
|
||||||
NEW_LABELS_CREATED["$name"]="$color:auto_generated:all_templates"
|
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
|
return 0
|
||||||
else
|
else
|
||||||
|
log_debug "Failed to create label $name (HTTP: $http_code)"
|
||||||
|
log_debug "Response: $response_body"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# FIXED: Build labels JSON for API calls (handles unknown labels!)
|
# Process labels for template (updates global arrays, no output)
|
||||||
build_labels_json() {
|
process_labels_for_template() {
|
||||||
local template="$1"
|
local template="$1"
|
||||||
shift
|
shift
|
||||||
local additional_labels=("$@")
|
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
|
# Get template labels
|
||||||
local template_labels_string="${TEMPLATE_LABELS[$template]:-}"
|
local template_labels_string="${TEMPLATE_LABELS[$template]:-}"
|
||||||
local all_labels=()
|
local all_labels=()
|
||||||
|
|
@ -162,17 +294,66 @@ build_labels_json() {
|
||||||
# Add additional labels
|
# Add additional labels
|
||||||
all_labels+=("${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!)
|
# FIXED: Ensure all labels exist and collect IDs (handles unknown labels!)
|
||||||
local label_ids=()
|
local label_ids=()
|
||||||
for label in "${all_labels[@]}"; do
|
for label in "${all_labels[@]}"; do
|
||||||
|
log_debug "Processing label: $label"
|
||||||
|
|
||||||
# Process both known and unknown labels
|
# Process both known and unknown labels
|
||||||
if [[ -n "${LABEL_DEFINITIONS[$label]:-}" ]]; then
|
if [[ -n "${LABEL_DEFINITIONS[$label]:-}" ]]; then
|
||||||
|
log_debug "Known label: $label"
|
||||||
# Known label - use defined color and context
|
# Known label - use defined color and context
|
||||||
local color=$(get_label_color "$label")
|
local color=$(get_label_color "$label")
|
||||||
local context=$(get_label_context "$label")
|
local context=$(get_label_context "$label")
|
||||||
|
|
||||||
ensure_label_exists_silent "$label" "$color" "Furt: $context"
|
ensure_label_exists_silent "$label" "$color" "Furt: $context"
|
||||||
else
|
else
|
||||||
|
log_debug "Unknown label: $label - creating with smart defaults"
|
||||||
# FIXED: Unknown label - auto-create with smart defaults
|
# FIXED: Unknown label - auto-create with smart defaults
|
||||||
local default_color="ff6b6b"
|
local default_color="ff6b6b"
|
||||||
local default_context="auto_generated"
|
local default_context="auto_generated"
|
||||||
|
|
@ -181,12 +362,15 @@ build_labels_json() {
|
||||||
if [[ "$label" == service-* ]]; then
|
if [[ "$label" == service-* ]]; then
|
||||||
default_color="1d76db"
|
default_color="1d76db"
|
||||||
default_context="service_integration"
|
default_context="service_integration"
|
||||||
|
log_debug "Service label detected - using blue color"
|
||||||
elif [[ "$label" == *-priority ]]; then
|
elif [[ "$label" == *-priority ]]; then
|
||||||
default_color="d73a4a"
|
default_color="d73a4a"
|
||||||
default_context="priority_level"
|
default_context="priority_level"
|
||||||
|
log_debug "Priority label detected - using red color"
|
||||||
elif [[ "$label" == hugo-* ]]; then
|
elif [[ "$label" == hugo-* ]]; then
|
||||||
default_color="ff7518"
|
default_color="ff7518"
|
||||||
default_context="frontend_integration"
|
default_context="frontend_integration"
|
||||||
|
log_debug "Hugo label detected - using orange color"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ensure_label_exists_silent "$label" "$default_color" "Furt: $default_context"
|
ensure_label_exists_silent "$label" "$default_color" "Furt: $default_context"
|
||||||
|
|
@ -195,9 +379,31 @@ build_labels_json() {
|
||||||
# Collect ID if label was created/exists
|
# Collect ID if label was created/exists
|
||||||
if [[ -n "${LABEL_IDS[$label]:-}" ]]; then
|
if [[ -n "${LABEL_IDS[$label]:-}" ]]; then
|
||||||
label_ids+=("${LABEL_IDS[$label]}")
|
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
|
fi
|
||||||
done
|
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!)
|
# Build JSON array (clean output only!)
|
||||||
if [[ ${#label_ids[@]} -gt 0 ]]; then
|
if [[ ${#label_ids[@]} -gt 0 ]]; then
|
||||||
printf '[%s]' "$(IFS=','; echo "${label_ids[*]}")"
|
printf '[%s]' "$(IFS=','; echo "${label_ids[*]}")"
|
||||||
|
|
@ -225,15 +431,21 @@ show_labels_used() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Show additional labels
|
# Show additional labels (these may have been newly created)
|
||||||
for label in "${additional_labels[@]}"; do
|
for label in "${additional_labels[@]}"; do
|
||||||
if [[ -n "${LABEL_IDS[$label]:-}" ]]; then
|
if [[ -n "${LABEL_IDS[$label]:-}" ]]; then
|
||||||
log_info " ✅ $label (ID: ${LABEL_IDS[$label]}) [NEW!]"
|
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
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# FIXED: AUTO-UPDATE with safe array handling
|
# FIXED: AUTO-UPDATE with safe array handling and correct path
|
||||||
auto_update_scripts_if_needed() {
|
auto_update_scripts_if_needed() {
|
||||||
# FIXED: Safe check for empty associative array
|
# FIXED: Safe check for empty associative array
|
||||||
local new_labels_count=0
|
local new_labels_count=0
|
||||||
|
|
@ -241,12 +453,47 @@ auto_update_scripts_if_needed() {
|
||||||
new_labels_count=${#NEW_LABELS_CREATED[@]}
|
new_labels_count=${#NEW_LABELS_CREATED[@]}
|
||||||
fi
|
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
|
if [[ $new_labels_count -eq 0 ]]; then
|
||||||
|
log_debug "No new labels created - skipping auto-update"
|
||||||
return 0 # No new labels, no update needed
|
return 0 # No new labels, no update needed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_info "🔄 Auto-updating scripts with $new_labels_count new labels..."
|
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
|
# Add new labels to registry
|
||||||
for label_name in "${!NEW_LABELS_CREATED[@]}"; do
|
for label_name in "${!NEW_LABELS_CREATED[@]}"; do
|
||||||
local label_info="${NEW_LABELS_CREATED[$label_name]}"
|
local label_info="${NEW_LABELS_CREATED[$label_name]}"
|
||||||
|
|
@ -257,12 +504,17 @@ auto_update_scripts_if_needed() {
|
||||||
log_info "Adding '$label_name' to registry..."
|
log_info "Adding '$label_name' to registry..."
|
||||||
|
|
||||||
# Add to registry (suppressing output to avoid noise)
|
# Add to registry (suppressing output to avoid noise)
|
||||||
FURT_AUTO_UPDATE=true "$SCRIPT_DIR/update_script_labels.sh" add "$label_name" "$color" "$context" "$usage" >/dev/null 2>&1 || true
|
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
|
done
|
||||||
|
|
||||||
# Update all scripts with new labels
|
# Update all scripts with new labels
|
||||||
log_info "Synchronizing all scripts..."
|
log_info "Synchronizing all scripts..."
|
||||||
"$SCRIPT_DIR/update_script_labels.sh" update >/dev/null 2>&1 || true
|
"$update_script" update >/dev/null 2>&1 || {
|
||||||
|
log_warning "Failed to update scripts"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
log_success "✅ All scripts automatically synchronized with new labels!"
|
log_success "✅ All scripts automatically synchronized with new labels!"
|
||||||
|
|
||||||
|
|
@ -279,6 +531,8 @@ auto_update_scripts_if_needed() {
|
||||||
create_service_issue() {
|
create_service_issue() {
|
||||||
local service_name="${1:-newsletter}"
|
local service_name="${1:-newsletter}"
|
||||||
|
|
||||||
|
log_debug "Creating service issue for: $service_name"
|
||||||
|
|
||||||
local title="[SERVICE] $service_name für Furt Gateway"
|
local title="[SERVICE] $service_name für Furt Gateway"
|
||||||
local body="# Service-Request: $service_name
|
local body="# Service-Request: $service_name
|
||||||
|
|
||||||
|
|
@ -306,11 +560,18 @@ create_service_issue() {
|
||||||
## ⚡ Priorität
|
## ⚡ Priorität
|
||||||
🔥 **Hoch** - benötigt für Website-Launch"
|
🔥 **Hoch** - benötigt für Website-Launch"
|
||||||
|
|
||||||
# FIXED: Build labels JSON (clean, no stdout pollution) with additional service label
|
# Process labels first, then build JSON
|
||||||
local labels_json=$(build_labels_json "service" "service-$service_name")
|
local service_label="service-$service_name"
|
||||||
|
log_debug "Service label to add: $service_label"
|
||||||
|
|
||||||
# Show which labels are being used (AFTER JSON building)
|
# First: Process all labels (this updates global arrays)
|
||||||
show_labels_used "service" "service-$service_name"
|
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_issue "$title" "$body" "$labels_json"
|
||||||
}
|
}
|
||||||
|
|
@ -342,11 +603,88 @@ create_architecture_issue() {
|
||||||
- [ ] Security
|
- [ ] Security
|
||||||
- [ ] Configuration-Management"
|
- [ ] Configuration-Management"
|
||||||
|
|
||||||
local labels_json=$(build_labels_json "architecture")
|
# 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"
|
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
|
# Generic issue creation
|
||||||
create_issue() {
|
create_issue() {
|
||||||
local title="$1"
|
local title="$1"
|
||||||
|
|
@ -354,6 +692,7 @@ create_issue() {
|
||||||
local labels_json="$3"
|
local labels_json="$3"
|
||||||
|
|
||||||
log_info "Creating issue: $title"
|
log_info "Creating issue: $title"
|
||||||
|
log_debug "Labels JSON: $labels_json"
|
||||||
|
|
||||||
local response=$(curl -s -w "\n%{http_code}" -X POST \
|
local response=$(curl -s -w "\n%{http_code}" -X POST \
|
||||||
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/issues" \
|
"$GITEA_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/issues" \
|
||||||
|
|
@ -381,34 +720,15 @@ create_issue() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Show usage information
|
|
||||||
show_usage() {
|
|
||||||
echo "🎯 Furt API-Gateway Issue Creator"
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Main function
|
# Main function
|
||||||
main() {
|
main() {
|
||||||
local template="${1:-help}"
|
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
|
if [[ "$template" == "help" ]] || [[ "$template" == "--help" ]] || [[ "$template" == "-h" ]]; then
|
||||||
show_usage
|
show_usage
|
||||||
exit 0
|
exit 0
|
||||||
|
|
@ -428,9 +748,19 @@ main() {
|
||||||
local component="${2:-gateway}"
|
local component="${2:-gateway}"
|
||||||
local title="[PERF] $component Performance-Optimierung"
|
local title="[PERF] $component Performance-Optimierung"
|
||||||
local body="# Performance-Optimierung: $component"
|
local body="# Performance-Optimierung: $component"
|
||||||
local labels_json=$(build_labels_json "performance")
|
|
||||||
|
process_labels_for_template "performance"
|
||||||
|
local labels_json=$(build_labels_json_from_processed "performance")
|
||||||
|
|
||||||
create_issue "$title" "$body" "$labels_json"
|
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"
|
log_error "Unknown template: $template"
|
||||||
show_usage
|
show_usage
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# scripts/update_script_labels.sh
|
# scripts/update_script_labels.sh
|
||||||
# Auto-updates all scripts with current label definitions from registry
|
# Auto-updates all scripts with current label definitions from registry
|
||||||
# COMPLETE VERSION with all integration fixes
|
# FINAL FIXED VERSION with corrected all_templates logic
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||||
REGISTRY_FILE="$PROJECT_ROOT/config/labels.registry"
|
REGISTRY_FILE="$PROJECT_ROOT/configs/labels.registry"
|
||||||
|
|
||||||
# Colors for logging
|
# Colors for logging
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
|
|
@ -45,16 +45,16 @@ bug:d73a4a:error:bug_template,status_updates
|
||||||
question:d876e3:discussion:question_template
|
question:d876e3:discussion:question_template
|
||||||
|
|
||||||
# === COMPONENT CATEGORIES ===
|
# === COMPONENT CATEGORIES ===
|
||||||
gateway:0052cc:gateway_core:architecture,performance,service_templates
|
gateway:0052cc:gateway_core:architecture_template,performance_template,service_templates
|
||||||
performance:fbca04:optimization:performance_template,architecture
|
performance:fbca04:optimization:performance_template,architecture_template
|
||||||
architecture:d4c5f9:design:architecture_template,gateway
|
architecture:d4c5f9:design:architecture_template,gateway
|
||||||
security:28a745:security_review:security_template,gateway
|
security:28a745:security_review:security_template,architecture_template
|
||||||
configuration:f9d71c:config_management:deployment,architecture
|
configuration:f9d71c:config_management:deployment_template,architecture_template
|
||||||
|
|
||||||
# === SERVICE-SPECIFIC LABELS ===
|
# === SERVICE-SPECIFIC LABELS ===
|
||||||
service-formular2mail:1d76db:formular2mail:service_templates,integration
|
service-formular2mail:1d76db:formular2mail:formular2mail_integration
|
||||||
service-sagjan:1d76db:sagjan:service_templates,integration
|
service-sagjan:1d76db:sagjan:sagjan_integration
|
||||||
service-newsletter:ff6b6b:newsletter:service_templates,integration
|
service-newsletter:ff6b6b:newsletter:newsletter_integration
|
||||||
|
|
||||||
# === WORKFLOW STATE LABELS ===
|
# === WORKFLOW STATE LABELS ===
|
||||||
work-in-progress:fbca04:active:status_updates
|
work-in-progress:fbca04:active:status_updates
|
||||||
|
|
@ -65,22 +65,21 @@ ready-for-deployment:28a745:deploy_ready:status_updates
|
||||||
# === INTEGRATION LABELS ===
|
# === INTEGRATION LABELS ===
|
||||||
hugo-integration:ff7518:frontend:hugo_templates,integration
|
hugo-integration:ff7518:frontend:hugo_templates,integration
|
||||||
api-contract:5319e7:api_design:api_templates,service_templates
|
api-contract:5319e7:api_design:api_templates,service_templates
|
||||||
breaking-change:d73a4a:breaking:api_templates,architecture
|
breaking-change:d73a4a:breaking:api_templates,architecture_template
|
||||||
|
|
||||||
# === PRIORITY LABELS ===
|
# === PRIORITY LABELS ===
|
||||||
high-priority:d73a4a:urgent:all_templates
|
high-priority:d73a4a:urgent:all_templates
|
||||||
low-priority:0e8a16:nice_to_have:all_templates
|
low-priority:0e8a16:nice_to_have:all_templates
|
||||||
|
|
||||||
# === META LABELS ===
|
# === META LABELS ===
|
||||||
low-tech:6f42c1:low_tech_principle:all_templates
|
low-tech:6f42c1:low_tech_principle:architecture_template,performance_template,security_template
|
||||||
digital-sovereignty:6f42c1:digital_sovereignty:all_templates
|
digital-sovereignty:6f42c1:digital_sovereignty:architecture_template,performance_template,security_template
|
||||||
good-first-issue:7057ff:beginner_friendly:all_templates
|
good-first-issue:7057ff:beginner_friendly:manual_assignment
|
||||||
help-wanted:159818:community_help:all_templates
|
help-wanted:159818:community_help:manual_assignment
|
||||||
|
|
||||||
# === DEPLOYMENT LABELS ===
|
# === DEPLOYMENT LABELS ===
|
||||||
deployment:ff7518:deployment:deployment_template
|
deployment:ff7518:deployment:deployment_template
|
||||||
testing:f9d71c:testing:testing_template,integration
|
testing:f9d71c:testing:testing_template,integration
|
||||||
documentation:0366d6:docs:documentation_template
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
log_success "Created label registry: $REGISTRY_FILE"
|
log_success "Created label registry: $REGISTRY_FILE"
|
||||||
|
|
@ -151,7 +150,7 @@ is_label_valid_for_context() {
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate template-to-labels mapping
|
# Generate template-to-labels mapping - FIXED VERSION
|
||||||
generate_template_mappings() {
|
generate_template_mappings() {
|
||||||
cat << 'EOF'
|
cat << 'EOF'
|
||||||
|
|
||||||
|
|
@ -160,19 +159,51 @@ generate_template_mappings() {
|
||||||
declare -A TEMPLATE_LABELS=(
|
declare -A TEMPLATE_LABELS=(
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Generate mappings based on usage contexts
|
# FIXED: Consistent template names with corrected all_templates logic
|
||||||
for template in "service_templates" "architecture" "performance_template" "bug_template" "security_template" "hugo_templates" "api_templates" "deployment_template"; do
|
declare -A template_mappings=(
|
||||||
|
["service"]="service_templates"
|
||||||
|
["architecture"]="architecture_template"
|
||||||
|
["performance"]="performance_template"
|
||||||
|
["bug"]="bug_template"
|
||||||
|
["security"]="security_template"
|
||||||
|
["hugo"]="hugo_templates"
|
||||||
|
["api"]="api_templates"
|
||||||
|
["deployment"]="deployment_template"
|
||||||
|
)
|
||||||
|
|
||||||
|
for template_name in "${!template_mappings[@]}"; do
|
||||||
|
local template_usage="${template_mappings[$template_name]}"
|
||||||
local labels=()
|
local labels=()
|
||||||
|
|
||||||
|
# FIXED: First add all_templates labels to every template
|
||||||
for label in "${!LABEL_USAGES[@]}"; do
|
for label in "${!LABEL_USAGES[@]}"; do
|
||||||
local usage="${LABEL_USAGES[$label]}"
|
local usage="${LABEL_USAGES[$label]}"
|
||||||
if [[ "$usage" == *"$template"* ]] || [[ "$usage" == "all_templates" ]]; then
|
|
||||||
|
# EXCLUDE service-specific labels from all templates
|
||||||
|
if [[ "$label" == service-* ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Skip manual assignment labels
|
||||||
|
if [[ "$usage" == "manual_assignment" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# FIXED: Add all_templates labels to every template first
|
||||||
|
if [[ "$usage" == "all_templates" ]]; then
|
||||||
|
labels+=("$label")
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add template-specific labels
|
||||||
|
if [[ "$usage" == *"$template_usage"* ]]; then
|
||||||
labels+=("$label")
|
labels+=("$label")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ ${#labels[@]} -gt 0 ]]; then
|
if [[ ${#labels[@]} -gt 0 ]]; then
|
||||||
local label_list=$(IFS=','; echo "${labels[*]}")
|
local label_list=$(IFS=','; echo "${labels[*]}")
|
||||||
echo " [\"${template%_*}\"]=\"$label_list\""
|
echo " [\"$template_name\"]=\"$label_list\""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
@ -309,15 +340,15 @@ add_label_to_registry() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
local color="${2:-ff6b6b}"
|
local color="${2:-ff6b6b}"
|
||||||
local context="${3:-auto_generated}"
|
local context="${3:-auto_generated}"
|
||||||
local usage="${4:-all_templates}"
|
local usage="${4:-manual_assignment}"
|
||||||
|
|
||||||
# Skip if called during auto-update to prevent loops
|
# Skip if called during auto-update to prevent loops
|
||||||
if [[ "${FURT_AUTO_UPDATE:-}" == "true" ]]; then
|
if [[ "${FURT_AUTO_UPDATE:-}" == "true" ]]; then
|
||||||
return 0
|
log_info "Auto-update mode: Adding $name to registry (skipping rebuild)"
|
||||||
|
else
|
||||||
|
log_info "Adding new label to registry: $name"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_info "Adding new label to registry: $name"
|
|
||||||
|
|
||||||
# Ensure registry exists
|
# Ensure registry exists
|
||||||
create_registry_if_missing
|
create_registry_if_missing
|
||||||
|
|
||||||
|
|
@ -329,7 +360,7 @@ add_label_to_registry() {
|
||||||
|
|
||||||
# Add to appropriate section (determine by context)
|
# Add to appropriate section (determine by context)
|
||||||
local section_marker="# === CORE WORKFLOW LABELS ==="
|
local section_marker="# === CORE WORKFLOW LABELS ==="
|
||||||
if [[ "$context" == *"service"* ]]; then
|
if [[ "$context" == *"service"* ]] || [[ "$name" == service-* ]]; then
|
||||||
section_marker="# === SERVICE-SPECIFIC LABELS ==="
|
section_marker="# === SERVICE-SPECIFIC LABELS ==="
|
||||||
elif [[ "$context" == *"workflow"* ]]; then
|
elif [[ "$context" == *"workflow"* ]]; then
|
||||||
section_marker="# === WORKFLOW STATE LABELS ==="
|
section_marker="# === WORKFLOW STATE LABELS ==="
|
||||||
|
|
@ -362,20 +393,25 @@ show_registry_status() {
|
||||||
echo "📊 Label Registry Status"
|
echo "📊 Label Registry Status"
|
||||||
echo "========================"
|
echo "========================"
|
||||||
echo "Registry file: $REGISTRY_FILE"
|
echo "Registry file: $REGISTRY_FILE"
|
||||||
echo "Total labels: $(grep -c "^[^#]" "$REGISTRY_FILE" 2>/dev/null || echo 0)"
|
|
||||||
echo ""
|
|
||||||
echo "Labels by category:"
|
|
||||||
|
|
||||||
local current_section=""
|
if [[ -f "$REGISTRY_FILE" ]]; then
|
||||||
while IFS= read -r line; do
|
echo "Total labels: $(grep -c "^[^#]" "$REGISTRY_FILE" 2>/dev/null || echo 0)"
|
||||||
if [[ "$line" =~ ^#\ ===.*===\ $ ]]; then
|
echo ""
|
||||||
current_section=$(echo "$line" | sed 's/# === \(.*\) ===/\1/')
|
echo "Labels by category:"
|
||||||
echo " $current_section:"
|
|
||||||
elif [[ "$line" =~ ^[^#]+: ]] && [[ -n "$current_section" ]]; then
|
local current_section=""
|
||||||
local label_name=$(echo "$line" | cut -d: -f1)
|
while IFS= read -r line; do
|
||||||
echo " - $label_name"
|
if [[ "$line" =~ ^#\ ===.*===\ $ ]]; then
|
||||||
fi
|
current_section=$(echo "$line" | sed 's/# === \(.*\) ===/\1/')
|
||||||
done < "$REGISTRY_FILE"
|
echo " $current_section:"
|
||||||
|
elif [[ "$line" =~ ^[^#]+: ]] && [[ -n "$current_section" ]]; then
|
||||||
|
local label_name=$(echo "$line" | cut -d: -f1)
|
||||||
|
echo " - $label_name"
|
||||||
|
fi
|
||||||
|
done < "$REGISTRY_FILE"
|
||||||
|
else
|
||||||
|
echo "Registry file not found!"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main function
|
# Main function
|
||||||
|
|
@ -405,7 +441,7 @@ main() {
|
||||||
local name="$2"
|
local name="$2"
|
||||||
local color="${3:-ff6b6b}"
|
local color="${3:-ff6b6b}"
|
||||||
local context="${4:-auto_generated}"
|
local context="${4:-auto_generated}"
|
||||||
local usage="${5:-all_templates}"
|
local usage="${5:-manual_assignment}"
|
||||||
|
|
||||||
if [[ -z "$name" ]]; then
|
if [[ -z "$name" ]]; then
|
||||||
log_error "Usage: $0 add <name> [color] [context] [usage]"
|
log_error "Usage: $0 add <name> [color] [context] [usage]"
|
||||||
|
|
@ -413,8 +449,12 @@ main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
add_label_to_registry "$name" "$color" "$context" "$usage"
|
add_label_to_registry "$name" "$color" "$context" "$usage"
|
||||||
parse_registry
|
|
||||||
main update
|
# Only update scripts if not in auto-update mode
|
||||||
|
if [[ "${FURT_AUTO_UPDATE:-}" != "true" ]]; then
|
||||||
|
parse_registry
|
||||||
|
main update
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
status)
|
status)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue