From 496d5b6ef2ae41a179513017c7adf8a315139f89 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Mar 2026 18:01:29 +0000 Subject: [PATCH 1/4] Initial plan From 4411cc51cf9950e9d7e485fb3b025daa2ff53665 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Mar 2026 18:03:52 +0000 Subject: [PATCH 2/4] Add ShellCheck CI workflow Co-authored-by: mlutonsky <423848+mlutonsky@users.noreply.github.com> --- .github/workflows/shellcheck.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..ba2c9b1 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,18 @@ +name: ShellCheck + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + shellcheck: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + - uses: ludeeus/action-shellcheck@master + with: + additional_files: git-co git-branch-clean git-branch-close From 3944f77d194e1dbbaab3b070fb274c23efd2b3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Lutonsk=C3=BD?= Date: Sat, 14 Mar 2026 19:07:28 +0100 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .github/workflows/shellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index ba2c9b1..f7a26d8 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -13,6 +13,6 @@ jobs: contents: read steps: - uses: actions/checkout@v4 - - uses: ludeeus/action-shellcheck@master + - uses: ludeeus/action-shellcheck@v2.0.0 with: additional_files: git-co git-branch-clean git-branch-close From cf45f119135990a4b4ff4235423473986dec6451 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Mar 2026 18:14:40 +0000 Subject: [PATCH 4/4] Fix ShellCheck CI: correct action tag and fix SC2155/SC2162 warnings in git-co Co-authored-by: mlutonsky <423848+mlutonsky@users.noreply.github.com> --- .github/workflows/shellcheck.yml | 2 +- git-co | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index f7a26d8..7fb8ad3 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -13,6 +13,6 @@ jobs: contents: read steps: - uses: actions/checkout@v4 - - uses: ludeeus/action-shellcheck@v2.0.0 + - uses: ludeeus/action-shellcheck@2.0.0 with: additional_files: git-co git-branch-clean git-branch-close diff --git a/git-co b/git-co index 441c68a..439d9de 100755 --- a/git-co +++ b/git-co @@ -51,7 +51,8 @@ _find_branches_by_levenshtein() { local results="" while IFS= read -r branch; do if [ -n "$branch" ]; then - local distance=$(_levenshtein_distance "$input" "$branch") + local distance + distance=$(_levenshtein_distance "$input" "$branch") if [ -n "$distance" ] && [ "$distance" -le "$max_distance" ]; then # Format: distance|branch (for sorting) results="$results"$'\n'"$distance|$branch" @@ -68,7 +69,8 @@ _find_similar_branches() { local input_lower="${input,,}" # Get all branches (local and remote) - local all_branches=$( + local all_branches + all_branches=$( { git for-each-ref --format='%(refname:short)' refs/heads/ 2>/dev/null; git for-each-ref --format='%(refname:short)' refs/remotes/origin/ 2>/dev/null | sed 's|^origin/||'; } | grep -v '^HEAD$' | sort -u @@ -97,7 +99,8 @@ _find_similar_branches() { fi # Count results - local result_count=$(echo "$results" | grep -c '^' 2>/dev/null || echo "0") + local result_count + result_count=$(echo "$results" | grep -c '^' 2>/dev/null || echo "0") # If we got fewer than 3 results, try Levenshtein distance as fallback if [ "$result_count" -lt 3 ] && command -v python3 &> /dev/null; then @@ -107,7 +110,8 @@ _find_similar_branches() { [ "$max_distance" -lt 3 ] && max_distance=3 [ "$max_distance" -gt 8 ] && max_distance=8 - local levenshtein_results=$(_find_branches_by_levenshtein "$input" "$all_branches" "$max_distance") + local levenshtein_results + levenshtein_results=$(_find_branches_by_levenshtein "$input" "$all_branches" "$max_distance") # Merge results (prioritize fzf/substring matches, then add Levenshtein matches) if [ -n "$results" ]; then @@ -151,7 +155,8 @@ co() { similar_branches=$(_find_similar_branches "$1") if [ -n "$similar_branches" ]; then - local branch_count=$(echo "$similar_branches" | grep -c '^') + local branch_count + branch_count=$(echo "$similar_branches" | grep -c '^') if [ "$branch_count" -eq 1 ]; then local branch_name="$similar_branches" @@ -166,10 +171,11 @@ co() { echo "Branch '$1' not found. Did you mean one of these?" echo "$similar_branches" | nl echo "" - read -p "Select branch number (or press Enter to cancel): " selection + read -r -p "Select branch number (or press Enter to cancel): " selection if [ -n "$selection" ] && [ "$selection" -gt 0 ]; then - local branch_name=$(echo "$similar_branches" | sed -n "${selection}p") + local branch_name + branch_name=$(echo "$similar_branches" | sed -n "${selection}p") if [ -n "$branch_name" ]; then echo "Switching to '$branch_name'..." if git rev-parse --verify "$branch_name" >/dev/null 2>&1; then