From 383229c98d78191637ae13fc18914a67b596d8ac Mon Sep 17 00:00:00 2001 From: Aaron Schneider Date: Fri, 4 Apr 2025 18:28:59 -0400 Subject: [PATCH 1/4] jira create new project and issue importer --- documents/overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documents/overview.md b/documents/overview.md index e586627..998507f 100644 --- a/documents/overview.md +++ b/documents/overview.md @@ -75,6 +75,6 @@ PMAC will become the foundation of: ## Get Involved -- GitHub: TBD +- GitHub: Jira Tools are going here: https://github.com/schneidergithub/pmac-tools/blob/master/jira-import-readme.md - Email: TBD - License: MIT + CC BY 4.0 \ No newline at end of file From 8d654ffd91d6b3535d86a95aa767712ea41b1d32 Mon Sep 17 00:00:00 2001 From: Aaron Schneider Date: Mon, 7 Apr 2025 12:07:52 -0400 Subject: [PATCH 2/4] Test for AI prompts used on claude3.7 --- json_experiments/github_init.json | 279 ++++++++++++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 json_experiments/github_init.json diff --git a/json_experiments/github_init.json b/json_experiments/github_init.json new file mode 100644 index 0000000..f129051 --- /dev/null +++ b/json_experiments/github_init.json @@ -0,0 +1,279 @@ +{ + "project": "GitFlow Security Automation", + "description": "A robust bash script to automate the creation and configuration of GitHub repositories with GitFlow branching model and comprehensive security best practices, with special attention to GitHub UI integration", + "epics": [ + { + "id": "EPIC-1", + "title": "Repository Creation and Configuration", + "description": "Setup and initialization of GitHub repositories with proper structure and essential files", + "userStories": [ + { + "id": "US-1.1", + "title": "Create new GitHub repository", + "description": "As a developer, I want to quickly create a new GitHub repository so that I can start working on a new project", + "acceptanceCriteria": [ + "Script successfully creates both public and private repositories using GitHub CLI", + "Repository is created with a properly formatted README.md file that includes project name and description", + "Repository is cloned to the local machine with proper error handling", + "User can specify repository name and description through command line arguments", + "Script verifies repository creation before proceeding to next steps", + "Optional commit verification and signing is configured if GPG keys are available" + ], + "priority": "High", + "effort": "2", + "implementation": "Use `gh repo create` with proper visibility flags, error handling, and verification steps" + }, + { + "id": "US-1.2", + "title": "Add collaborators and teams", + "description": "As a developer, I want to add team members to my repository so that we can collaborate effectively", + "acceptanceCriteria": [ + "Individual collaborators can be added through comma-separated command line arguments", + "Teams can be added through comma-separated command line arguments", + "Proper permissions (push level) are set for collaborators and teams", + "Script handles errors gracefully when collaborators or teams cannot be added", + "Script reports success or failure for each collaborator/team addition attempt" + ], + "priority": "Medium", + "effort": "1", + "implementation": "Use `gh repo add-collaborator` and `gh api` commands with proper error handling" + }, + { + "id": "US-1.3", + "title": "Create LICENSE and baseline documentation", + "description": "As a developer, I want the repository to include proper licensing and basic documentation to establish project governance", + "acceptanceCriteria": [ + "MIT License file is created with current year and proper formatting", + "README.md includes sections for project overview, getting started, and usage", + "All created files are properly committed and pushed to the repository", + "Files are correctly formatted with proper markdown syntax" + ], + "priority": "Medium", + "effort": "1", + "implementation": "Generate license file with current year from system date and create comprehensive README with clear sections" + } + ] + }, + { + "id": "EPIC-2", + "title": "GitFlow Branch Structure", + "description": "Implementation of GitFlow branching model in repositories with verification of branch creation", + "userStories": [ + { + "id": "US-2.1", + "title": "Initialize GitFlow branch structure", + "description": "As a developer, I want to set up a GitFlow branch structure so that I can follow best practices for feature development and releases", + "acceptanceCriteria": [ + "Creates and verifies main branch as the primary branch with initial content", + "Creates and verifies develop branch from main with appropriate content", + "Creates example feature, release, and hotfix branches with appropriate content", + "Pushes all branches to the remote repository with proper upstream tracking", + "Handles cases where repository may be empty or have no initial commit", + "Works with or without git-flow installed, using native git commands as fallback", + "Provides explicit verification steps to ensure all branches exist remotely", + "Returns to develop branch at the end of the process" + ], + "priority": "High", + "effort": "3", + "implementation": "Use conditional checks for git-flow availability, explicit branch creation with content files, and verification function to confirm all branches exist remotely" + }, + { + "id": "US-2.2", + "title": "Set up branch protection rules", + "description": "As a developer, I want to protect important branches so that code quality and review processes are enforced", + "acceptanceCriteria": [ + "Protects main and develop branches from direct pushes", + "Requires at least one pull request review before merging", + "Configures status checks requirement if CI is enabled", + "Works with both free and paid GitHub accounts, with clear feedback about limitations", + "Provides appropriate warning messages when protection rules cannot be applied", + "Verifies protection rules are applied and reports status", + "Handles API request errors gracefully with informative messages" + ], + "priority": "High", + "effort": "2", + "implementation": "Use GitHub API via `gh api` commands to configure branch protection with appropriate error handling and fallbacks for free accounts" + } + ] + }, + { + "id": "EPIC-3", + "title": "Security Configuration", + "description": "Setup of security documentation and tools with GitHub Security tab integration", + "userStories": [ + { + "id": "US-3.1", + "title": "Add security documentation", + "description": "As a developer, I want to add security documentation so that contributors know how to report vulnerabilities and that appears in GitHub's Security tab", + "acceptanceCriteria": [ + "Adds SECURITY.md in the standardized format recognized by GitHub Security tab", + "Includes supported versions section with example data in SECURITY.md", + "Adds detailed vulnerability reporting instructions in SECURITY.md", + "Creates .github/CODEOWNERS file with appropriate ownership assignments", + "Creates security issue templates as .yml files in the GitHub Forms format", + "Creates a config.yml file to disable blank issues and direct to security policy", + "All security files are properly committed and pushed", + "Security tab in GitHub UI shows the security policy" + ], + "priority": "High", + "effort": "1", + "implementation": "Create security documentation files in GitHub-recognized formats and locations, using the GitHub Forms format for issue templates" + }, + { + "id": "US-3.2", + "title": "Set up security scanning", + "description": "As a developer, I want to set up automated security scanning that integrates with GitHub's Security tab so that vulnerabilities are detected early and visible in the UI", + "acceptanceCriteria": [ + "Sets up GitHub Actions workflow for security scanning in .github/workflows", + "Configures Trivy for dependency scanning with SARIF output format", + "Configures CodeQL for code scanning with proper language detection", + "Adds GitLeaks for secret scanning", + "Sets up Dependency Review for pull requests", + "Configures weekly scheduled scans", + "Ensures output is sent to GitHub Security tab using upload-sarif action", + "Creates .github/codeql/codeql-config.yml for advanced CodeQL configuration", + "All security scanning configuration is properly committed and pushed" + ], + "priority": "Medium", + "effort": "2", + "implementation": "Create workflow files that use GitHub security scanning actions with SARIF output format to ensure visibility in Security tab" + }, + { + "id": "US-3.3", + "title": "Enable Security Advisories and alerts", + "description": "As a developer, I want to enable GitHub Security Advisories so that security vulnerabilities can be managed and tracked", + "acceptanceCriteria": [ + "Creates workflow file that enables GitHub Security Advisories integration", + "Configures Dependabot alerts via .github/dependabot.yml", + "Sets up security scanning with proper repository permissions", + "All configurations appear in GitHub Security tab", + "Security alerts are enabled for the repository", + "All security advisory configurations are properly committed and pushed" + ], + "priority": "High", + "effort": "1", + "implementation": "Configure Security Advisories using GitHub's integrations with proper permissions and configurations" + } + ] + }, + { + "id": "EPIC-4", + "title": "CI/CD and Automation", + "description": "Setup of continuous integration and delivery workflows", + "userStories": [ + { + "id": "US-4.1", + "title": "Set up CI workflow", + "description": "As a developer, I want to set up continuous integration so that code is automatically built and tested", + "acceptanceCriteria": [ + "Creates GitHub Actions workflow for CI in .github/workflows/ci.yml", + "Configures workflow to run on pushes to main and develop branches", + "Configures workflow to run on pull requests to main and develop branches", + "Includes sample build, test, and linting steps that can be customized later", + "Configuration is properly committed and pushed", + "CI workflow appears in GitHub Actions tab" + ], + "priority": "Medium", + "effort": "2", + "implementation": "Create GitHub Actions workflow file with appropriate triggers and sample steps" + }, + { + "id": "US-4.2", + "title": "Set up release automation", + "description": "As a developer, I want to automate the release process so that releases are consistent and well-documented", + "acceptanceCriteria": [ + "Creates GitHub Actions workflow for releases in .github/workflows/release.yml", + "Configures workflow to trigger on version tags (v*.*.* pattern)", + "Configures automatic release notes generation", + "Includes sample build and release steps that can be customized later", + "Configuration is properly committed and pushed", + "Release workflow appears in GitHub Actions tab" + ], + "priority": "Low", + "effort": "2", + "implementation": "Create GitHub Actions workflow file that triggers on version tags with automatic release notes generation" + }, + { + "id": "US-4.3", + "title": "Set up enhanced dependency management", + "description": "As a developer, I want to automate dependency updates so that the project stays up-to-date and secure with clear visibility in GitHub", + "acceptanceCriteria": [ + "Configures Dependabot for GitHub Actions in .github/dependabot.yml", + "Configures Dependabot for npm dependencies with weekly updates", + "Sets appropriate reviewers and assignees for Dependabot PRs", + "Includes security and dependency labels for better organization", + "Sets target branch to develop for dependency updates", + "Configures commit message format for dependency updates", + "Configuration is properly committed and pushed", + "Dependabot appears in GitHub Insights tab" + ], + "priority": "Medium", + "effort": "1", + "implementation": "Create comprehensive Dependabot configuration with reviewers, labels, and commit message formatting" + } + ] + }, + { + "id": "EPIC-5", + "title": "Configuration Files", + "description": "Setup of standard configuration files", + "userStories": [ + { + "id": "US-5.1", + "title": "Add comprehensive .gitignore file", + "description": "As a developer, I want to have a proper .gitignore file so that unnecessary files are not committed", + "acceptanceCriteria": [ + "Creates .gitignore with common exclusions for various project types", + "Includes exclusions for major IDEs and editors (VS Code, JetBrains, Sublime, etc.)", + "Includes exclusions for common build outputs and dependencies", + "Includes exclusions for OS-specific files (.DS_Store, Thumbs.db, etc.)", + "Includes exclusions for environment files and security-sensitive files", + "Includes exclusions for testing and coverage reports", + "File is properly committed and pushed" + ], + "priority": "High", + "effort": "1", + "implementation": "Create comprehensive .gitignore file covering multiple development environments and sensitive file patterns" + }, + { + "id": "US-5.2", + "title": "Add .editorconfig file", + "description": "As a developer, I want to have an .editorconfig file so that coding styles are consistent across the team", + "acceptanceCriteria": [ + "Creates .editorconfig with root = true designation", + "Configures common settings for all files (charset, line endings, etc.)", + "Configures specific rules for different file types (Python, Markdown, etc.)", + "Sets consistent indentation and whitespace rules", + "Includes appropriate settings for Makefiles and batch files", + "File is properly committed and pushed" + ], + "priority": "Medium", + "effort": "1", + "implementation": "Create .editorconfig file with appropriate settings for different file types and common coding style rules" + } + ] + } + ], + "technicalRequirements": [ + "Script must be compatible with macOS, Linux, and Windows (Git Bash)", + "Script must check for prerequisites (git, GitHub CLI) before proceeding with appropriate error messages", + "Script must handle errors gracefully and provide helpful, specific error messages for each step", + "Script must work with both free and paid GitHub accounts with appropriate behavior for account limitations", + "Script must verify each step's success before proceeding to the next step", + "Script must create a consistent branch structure regardless of git-flow availability", + "Script must verify branch existence both locally and remotely before completing", + "Script must integrate properly with GitHub's Security tab and other UI elements", + "Script must use proper exit codes to indicate success or failure", + "Script must provide verbose output during execution with color-coded status messages", + "Script must not proceed if repository creation or clone fails", + "All created files must follow industry standard formatting and best practices" + ], + "implementation": { + "architecture": "Bash script with modular functions for each component", + "errorHandling": "Each function should handle its own errors and return appropriate status codes", + "verification": "A verification step should follow each critical operation to ensure success", + "githubIntegration": "Use GitHub CLI and API commands for maximum compatibility and UI integration", + "userFeedback": "Provide clear, color-coded status messages throughout execution", + "bestPractices": "Use modern bash scripting practices with proper variable handling and quoting" + } + } \ No newline at end of file From 62fd34b5b57599ada194fc3a0253703c0d5e18f3 Mon Sep 17 00:00:00 2001 From: Aaron Schneider Date: Mon, 7 Apr 2025 12:58:58 -0400 Subject: [PATCH 3/4] Claude ai generated solution from json --- .../claude3.7_generated_result.sh | 1213 +++++++++++++++++ 1 file changed, 1213 insertions(+) create mode 100644 json_experiments/claude3.7_generated_result.sh diff --git a/json_experiments/claude3.7_generated_result.sh b/json_experiments/claude3.7_generated_result.sh new file mode 100644 index 0000000..eff4ae5 --- /dev/null +++ b/json_experiments/claude3.7_generated_result.sh @@ -0,0 +1,1213 @@ +#!/bin/bash +# +# GitFlow Security Automation Script +# A robust bash script to automate the creation and configuration of GitHub repositories +# with GitFlow branching model and comprehensive security best practices. +# + +# Colors for console output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Script configuration +DEBUG=false +SCRIPT_VERSION="1.0.0" + +# Default values +DEFAULT_LICENSE="MIT" +DEFAULT_BRANCH="main" +GIT_FLOW_INSTALLED=false + +# Function to display help information +show_help() { + echo -e "${BLUE}GitFlow Security Automation${NC} v${SCRIPT_VERSION}" + echo + echo "Usage: $0 [options]" + echo + echo "Options:" + echo " -h, --help Show this help message" + echo " -n, --name REPO_NAME Specify repository name (required)" + echo " -d, --description DESC Specify repository description (optional)" + echo " -p, --private Create a private repository (default: public)" + echo " -c, --collaborators LIST Add collaborators (comma-separated)" + echo " -t, --teams LIST Add teams (comma-separated)" + echo " -v, --verbose Enable verbose output" + echo + echo "Example:" + echo " $0 --name my-new-repo --description \"My new project\" --private --collaborators user1,user2 --teams dev-team,security-team" + echo +} + +# Function to log messages +log() { + local level=$1 + local message=$2 + + case $level in + "info") + echo -e "${GREEN}[INFO]${NC} $message" + ;; + "warn") + echo -e "${YELLOW}[WARNING]${NC} $message" + ;; + "error") + echo -e "${RED}[ERROR]${NC} $message" + ;; + "debug") + if [ "$DEBUG" = true ]; then + echo -e "${BLUE}[DEBUG]${NC} $message" + fi + ;; + *) + echo -e "$message" + ;; + esac +} + +# Function to check for prerequisites +check_prerequisites() { + log "info" "Checking prerequisites..." + + # Check for git + if ! command -v git &> /dev/null; then + log "error" "git is not installed. Please install git and try again." + exit 1 + else + log "debug" "git is installed: $(git --version)" + fi + + # Check for GitHub CLI + if ! command -v gh &> /dev/null; then + log "error" "GitHub CLI is not installed. Please install GitHub CLI (gh) and try again." + log "info" "Visit https://cli.github.com/ for installation instructions." + exit 1 + else + log "debug" "GitHub CLI is installed: $(gh --version | head -n 1)" + fi + + # Check if authenticated with GitHub + if ! gh auth status &> /dev/null; then + log "error" "Not authenticated with GitHub. Please run 'gh auth login' first." + exit 1 + else + log "debug" "Authenticated with GitHub" + fi + + # Check for git-flow (optional) + if command -v git flow &> /dev/null; then + GIT_FLOW_INSTALLED=true + log "debug" "git-flow is installed: $(git flow version)" + else + log "warn" "git-flow is not installed. Will use native git commands instead." + fi + + log "info" "All required prerequisites are satisfied." + return 0 +} + +# Function to create a new GitHub repository +create_repository() { + local repo_name=$1 + local description=$2 + local visibility=$3 + + log "info" "Creating GitHub repository: ${repo_name}..." + + # Create repository using GitHub CLI + if [ "$visibility" = "private" ]; then + gh repo create "$repo_name" --private --description "$description" --clone + else + gh repo create "$repo_name" --public --description "$description" --clone + fi + + if [ $? -ne 0 ]; then + log "error" "Failed to create repository: ${repo_name}" + exit 1 + fi + + # Navigate to the repository directory + if [ -d "$repo_name" ]; then + cd "$repo_name" || { + log "error" "Failed to navigate to directory: ${repo_name}" + exit 1 + } + log "info" "Repository created successfully and cloned locally." + return 0 + else + log "error" "Repository directory not found: ${repo_name}" + exit 1 + fi +} + +# Function to verify repository exists remotely +verify_repository() { + local repo_name=$1 + + log "debug" "Verifying repository exists remotely: ${repo_name}..." + + if gh repo view "$repo_name" &> /dev/null; then + log "debug" "Repository verified: ${repo_name}" + return 0 + else + log "error" "Repository verification failed: ${repo_name}" + return 1 + fi +} + +# Function to add collaborators +add_collaborators() { + local repo_name=$1 + local collaborators=$2 + + if [ -z "$collaborators" ]; then + log "debug" "No collaborators specified. Skipping." + return 0 + fi + + log "info" "Adding collaborators to repository..." + + IFS=',' read -ra COLLAB_ARRAY <<< "$collaborators" + for collab in "${COLLAB_ARRAY[@]}"; do + log "debug" "Adding collaborator: ${collab}" + gh repo add-collaborator "$repo_name" "$collab" --permission push + + if [ $? -eq 0 ]; then + log "info" "Added collaborator: ${collab}" + else + log "warn" "Failed to add collaborator: ${collab}" + fi + done + + return 0 +} + +# Function to add teams +add_teams() { + local repo_name=$1 + local teams=$2 + + if [ -z "$teams" ]; then + log "debug" "No teams specified. Skipping." + return 0 + fi + + log "info" "Adding teams to repository..." + + # Get the GitHub username/organization from the repository name + local org_name + org_name=$(gh repo view "$repo_name" --json owner -q '.owner.login') + + IFS=',' read -ra TEAM_ARRAY <<< "$teams" + for team in "${TEAM_ARRAY[@]}"; do + log "debug" "Adding team: ${team}" + gh api -X PUT "repos/${org_name}/${repo_name}/teams/${team}" --input - <<< '{"permission":"push"}' + + if [ $? -eq 0 ]; then + log "info" "Added team: ${team}" + else + log "warn" "Failed to add team: ${team}. Make sure the team exists and you have proper permissions." + fi + done + + return 0 +} + +# Function to create LICENSE file +create_license() { + local license_type=$1 + + log "info" "Creating LICENSE file (${license_type})..." + + local current_year + current_year=$(date +"%Y") + local github_user + github_user=$(gh api user -q '.name') + + if [ -z "$github_user" ]; then + github_user=$(gh api user -q '.login') + fi + + case $license_type in + "MIT") + cat > LICENSE < README.md < DEVELOPMENT.md + git add DEVELOPMENT.md + git commit -m "Initialize develop branch" --quiet + git push -u origin develop --quiet + + # Verify branches were created + verify_branch "$DEFAULT_BRANCH" + verify_branch "develop" + + # Create an example feature branch + log "debug" "Creating example feature branch..." + if [ "$GIT_FLOW_INSTALLED" = true ]; then + git flow feature start example-feature + else + git checkout -b feature/example-feature develop --quiet + fi + + echo "# Example Feature" > FEATURE.md + git add FEATURE.md + git commit -m "Add example feature" --quiet + git push -u origin feature/example-feature --quiet + + # Create an example release branch + log "debug" "Creating example release branch..." + if [ "$GIT_FLOW_INSTALLED" = true ]; then + git flow release start 0.1.0 + else + git checkout -b release/0.1.0 develop --quiet + fi + + echo "# Example Release" > RELEASE.md + git add RELEASE.md + git commit -m "Prepare for release 0.1.0" --quiet + git push -u origin release/0.1.0 --quiet + + # Create an example hotfix branch + log "debug" "Creating example hotfix branch..." + if [ "$GIT_FLOW_INSTALLED" = true ]; then + git checkout "$DEFAULT_BRANCH" --quiet + git flow hotfix start 0.1.1 + else + git checkout -b hotfix/0.1.1 "$DEFAULT_BRANCH" --quiet + fi + + echo "# Example Hotfix" > HOTFIX.md + git add HOTFIX.md + git commit -m "Fix critical issue" --quiet + git push -u origin hotfix/0.1.1 --quiet + + # Return to develop branch + git checkout develop --quiet + + log "info" "GitFlow branch structure initialized successfully." + return 0 +} + +# Function to verify a branch exists both locally and remotely +verify_branch() { + local branch_name=$1 + + # Check if branch exists locally + if git branch --list "$branch_name" | grep -q "$branch_name"; then + log "debug" "Branch exists locally: ${branch_name}" + else + log "error" "Branch does not exist locally: ${branch_name}" + return 1 + fi + + # Check if branch exists remotely + if git ls-remote --heads origin "$branch_name" | grep -q "$branch_name"; then + log "debug" "Branch exists remotely: ${branch_name}" + else + log "error" "Branch does not exist remotely: ${branch_name}" + return 1 + fi + + log "debug" "Branch verified: ${branch_name}" + return 0 +} + +# Function to set up branch protection rules +setup_branch_protection() { + local repo_name=$1 + + log "info" "Setting up branch protection rules..." + + # Get repository full name + local repo_full_name + repo_full_name=$(gh repo view --json nameWithOwner -q .nameWithOwner) + + # Try to set up branch protection rules for main branch + log "debug" "Setting up protection for $DEFAULT_BRANCH branch..." + gh api -X PUT "repos/${repo_full_name}/branches/${DEFAULT_BRANCH}/protection" \ + -f required_status_checks='{"strict":true,"contexts":[]}' \ + -f enforce_admins=false \ + -f required_pull_request_reviews='{"dismissal_restrictions":{},"dismiss_stale_reviews":true,"require_code_owner_reviews":true,"required_approving_review_count":1}' \ + -f restrictions=null 2>/dev/null + + if [ $? -eq 0 ]; then + log "info" "Branch protection rules set for ${DEFAULT_BRANCH} branch." + else + log "warn" "Failed to set branch protection rules for ${DEFAULT_BRANCH} branch. This might be due to using a free GitHub account which has limited branch protection features." + log "warn" "You can still manually set up branch protection rules in the GitHub repository settings." + fi + + # Try to set up branch protection rules for develop branch + log "debug" "Setting up protection for develop branch..." + gh api -X PUT "repos/${repo_full_name}/branches/develop/protection" \ + -f required_status_checks='{"strict":true,"contexts":[]}' \ + -f enforce_admins=false \ + -f required_pull_request_reviews='{"dismissal_restrictions":{},"dismiss_stale_reviews":true,"require_code_owner_reviews":true,"required_approving_review_count":1}' \ + -f restrictions=null 2>/dev/null + + if [ $? -eq 0 ]; then + log "info" "Branch protection rules set for develop branch." + else + log "warn" "Failed to set branch protection rules for develop branch. This might be due to using a free GitHub account which has limited branch protection features." + log "warn" "You can still manually set up branch protection rules in the GitHub repository settings." + fi + + return 0 +} + +# Function to create security documentation +create_security_documentation() { + log "info" "Creating security documentation..." + + # Create .github directory if it doesn't exist + mkdir -p .github + + # Create SECURITY.md + log "debug" "Creating SECURITY.md..." + cat > SECURITY.md < .github/CODEOWNERS < .github/ISSUE_TEMPLATE/security_vulnerability.yml < .github/ISSUE_TEMPLATE/config.yml < .github/workflows/codeql-analysis.yml < .github/workflows/trivy-scan.yml < .github/workflows/gitleaks.yml < .github/workflows/dependency-review.yml < .github/codeql/codeql-config.yml < .github/dependabot.yml < .github/workflows/ci.yml < .github/workflows/release.yml < .gitignore < .editorconfig < Date: Tue, 8 Apr 2025 06:55:35 -0400 Subject: [PATCH 4/4] chatgpt4o generated solution --- .../chatgpt4o_generated_result.sh | 89 +++++++++++++++++++ json_experiments/chatgptreo | 1 + 2 files changed, 90 insertions(+) create mode 100644 json_experiments/chatgpt4o_generated_result.sh create mode 160000 json_experiments/chatgptreo diff --git a/json_experiments/chatgpt4o_generated_result.sh b/json_experiments/chatgpt4o_generated_result.sh new file mode 100644 index 0000000..2e14bfd --- /dev/null +++ b/json_experiments/chatgpt4o_generated_result.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +set -e + +# === Color Constants === +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# === Logging Helpers === +log_success() { echo -e "${GREEN}[✔] $1${NC}"; } +log_error() { echo -e "${RED}[✖] $1${NC}"; } +log_info() { echo -e "${YELLOW}[➤] $1${NC}"; } + +# === Check prerequisites === +check_prerequisites() { + log_info "Checking prerequisites..." + command -v git >/dev/null 2>&1 || { log_error "Git is not installed"; exit 1; } + command -v gh >/dev/null 2>&1 || { log_error "GitHub CLI is not installed"; exit 1; } + log_success "All prerequisites met" +} + +# === Create GitHub repository === +create_repository() { + local REPO_NAME="$1" + local REPO_DESC="$2" + local VISIBILITY="$3" # public or private + + log_info "Creating GitHub repository: $REPO_NAME" + + if gh repo view "$REPO_NAME" >/dev/null 2>&1; then + log_error "Repository $REPO_NAME already exists." + exit 2 + fi + + gh repo create "$REPO_NAME" --$VISIBILITY --description "$REPO_DESC" --confirm || { + log_error "Failed to create repository" + exit 3 + } + log_success "Repository created successfully" + + git clone "https://github.com/$(gh api user | jq -r '.login')/$REPO_NAME.git" || { + log_error "Failed to clone repository" + exit 4 + } + cd "$REPO_NAME" + log_success "Repository cloned and switched to directory: $REPO_NAME" +} + +# === Initialize README and LICENSE === +initialize_docs() { + local PROJECT_NAME="$1" + local DESCRIPTION="$2" + + log_info "Initializing documentation files..." + + echo "# $PROJECT_NAME" > README.md + echo "$DESCRIPTION" >> README.md + + YEAR=$(date +%Y) + echo "MIT License" > LICENSE + echo "Copyright (c) $YEAR $(gh api user | jq -r '.name')" >> LICENSE + + git add README.md LICENSE + git commit -m "Add README and LICENSE" + git push origin main + + log_success "Documentation initialized and pushed" +} + +# === MAIN EXECUTION === +main() { + check_prerequisites + + REPO_NAME="$1" + REPO_DESC="$2" + VISIBILITY="$3" + + if [[ -z "$REPO_NAME" || -z "$REPO_DESC" || -z "$VISIBILITY" ]]; then + log_error "Usage: $0 " + exit 9 + fi + + create_repository "$REPO_NAME" "$REPO_DESC" "$VISIBILITY" + initialize_docs "$REPO_NAME" "$REPO_DESC" +} + +main "$@" diff --git a/json_experiments/chatgptreo b/json_experiments/chatgptreo new file mode 160000 index 0000000..b57dfe5 --- /dev/null +++ b/json_experiments/chatgptreo @@ -0,0 +1 @@ +Subproject commit b57dfe513cddeffc747b88edc7cfef15e2ec7031