Merged
Conversation
Co-authored-by: mlutonsky <423848+mlutonsky@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add ShellCheck CI workflow for shell scripts
Add ShellCheck CI workflow
Mar 14, 2026
Owner
|
@copilot When I ran the GH action, it failed on some scripts. Also fix the scripts according to the shellcheck |
There was a problem hiding this comment.
Pull request overview
Adds initial CI to the repo by introducing a GitHub Actions workflow that runs ShellCheck against the repository’s shell scripts on pushes and PRs to main.
Changes:
- Add a new GitHub Actions workflow to run ShellCheck on
ubuntu-latest. - Configure the workflow to include non-
.shscripts viaadditional_files.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
mlutonsky
requested changes
Mar 14, 2026
…in git-co Co-authored-by: mlutonsky <423848+mlutonsky@users.noreply.github.com>
Author
Fixed in cf45f11. Two issues addressed:
|
mlutonsky
approved these changes
Mar 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No CI existed in this repo. This adds a GitHub Actions workflow that runs ShellCheck on all shell scripts on every push and PR to
main.Changes
.github/workflows/shellcheck.yml: New workflow usingactions/checkout@v4+ludeeus/action-shellcheck@master.shextensions (git-co,git-branch-clean,git-branch-close) are passed viaadditional_files;idle-power-manager.shis picked up by the action's default scanpermissions: contents: readscopes theGITHUB_TOKENto the minimum requiredOriginal prompt
Add ShellCheck CI workflow
Add a GitHub Actions workflow file at
.github/workflows/shellcheck.ymlthat runs ShellCheck on all shell scripts in the repository on every push and pull request tomain.The workflow should:
pushandpull_requesttargetingmainubuntu-latestactions/checkout@v4to check out the codeludeeus/action-shellcheck@masterto run ShellCheckgit-co,git-branch-clean,git-branch-close,idle-power-manager.shThe scripts do not have
.shextensions (exceptidle-power-manager.sh), so make sure ShellCheck picks them all up — you can set thescandirto.or list files explicitly in the action config.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: How could I improve this repository?
Assistant: Here's a thorough review of your
mlutonsky/utilsrepository with concrete suggestions across several areas:🏗️ Repository & Project Structure
1. Add a license
The repo has no license file. Anyone who finds it won't know if they can use or adapt the scripts. A permissive license like MIT takes 30 seconds to add.
2. Add a repository description and topics
The GitHub repo has no description or topics set. Adding a one-line description ("Small shell utilities for git workflow and power management") and topics like
shell,bash,git,gnome,productivitymakes it more discoverable.3. Add a top-level
install.shscriptEvery script currently requires a manual
ln -scommand. A singleinstall.shthat symlinks all scripts to~/.local/bin/would make onboarding much easier.4. Organize scripts into subdirectories (optional, but worth considering)
As the collection grows, a flat root directory will get cluttered. A structure like
git/andsystem/would help.🐚 Script Quality & Robustness
git-co5. Add
set -euo pipefail— None of the scripts use strict mode.git-cohas numerous subshell calls and variable expansions that could silently fail.6. Calling
python3in a loop is expensive_levenshtein_distance()spawns a newpython3process for every branch, which can be very slow on a repo with many branches. Consider inlining the Levenshtein calculation in pure Bash (it's feasible for small strings), or batching all branch names into a single Python invocation.7.
git pull --allaftergit switch -cis unexpectedAfter tracking a new remote branch,
git pull --allfetches and pulls all remotes, which is likely unintentional.git pullor even nothing (sincegit switch -c branch origin/branchalready sets up tracking) would be more appropriate.8. Input validation is missing
No check that
$selectionis actually a number before the-gt 0comparison — this can produce a cryptic Bash error ([: foo: integer expression expected).git-branch-clean9. Uses
git branch -D(force delete) instead of-d-Dwill delete branches even if they have unmerged commits. Since the intent is to clean up branches whose remote is gone (presumably merged),-dis safer and will warn if something looks wrong.10. No exit code on fetch failure
If
git fetch --prunefails (e.g., no network), the script silently continues and may incorrectly delete branches. It should check the exit code:git-branch-close11. Already solid! This is the most robust of the three git scripts — good use of
|| { ... ; exit 1; }error handling throughout.12. Minor: could add a
--dry-runflag to preview what would happen without making any changes.idle-power-manager.sh13. Log rotation is missing
The log file grows unboundedly. With
CHECK_INTERVAL=30it writes ~2 lines/minute → ~1 MB/day. Consider capping the log size or usingloggerto send output to systemd journal instead (whichjournalctlalready manages).14.
switch_profilesuccess check is fragileThis would match any string containing "true" (e.g., an error message that says "profile 'true-performance' not found"). Checking the exit code of
gdbus calldirectly would be more reliable.15. No
DBUS_SESSION_BUS_ADDRESSfallbackWhen run as a systemd user service,
DBUS_SESSION_BUS_ADDRESSis usually inherited, but it's not guaranteed. A fallback like:…would make the service more resilient.
✅ Testing & CI
16. Add a GitHub Actions workflow
There's no CI at all. Even a simple ShellCheck workflow would catch common bash bugs automatically: