Skip to content

refactor: extract shared utilities from duplicated shell code - #3

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1781782834-refactor-shared-utils
Open

refactor: extract shared utilities from duplicated shell code#3
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1781782834-refactor-shared-utils

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Introduces scripts/lib/shared.sh — a single source-able library consolidating 6 duplicated patterns found across 15+ shell scripts:

Utility Was duplicated in What it does
find_project_root [dir] format-on-save.sh, auto-test.sh, context-recovery.sh Walk up to find .git/package.json/etc.
strip_crlf <file> sync_impl_tooling.sh, sync_spec_tooling.sh CRLF→LF via python3 one-liner
gh_current_repo [dir] 10+ scripts (inline gh repo view --json nameWithOwner) Resolve owner/name with gh→git-remote fallback
OPENCODE_STATE_LABELS + transition_issue_state issue-state-transition.sh, triage.sh Canonical state label list + swap logic
oc_root 8+ scripts (OC="${OPENCODE_CONFIG:-...}") Standardized config dir resolution
source_fetch_spec_prd [bin_dir] feature-context, issue-expand-bundle Locate and source fetch_spec_prd.sh with fallback chain

bin/stack/common.sh now delegates stack_gh_repo_from_dirgh_current_repo (preserving the public function name for callers).

All existing tests (test_read_spec_repo.sh, block-dangerous-git.sh --self-test, check-crlf.sh, Python unit tests) pass. The one pre-existing failure in test_migrate_repos_registry.py is unrelated.

Link to Devin session: https://app.devin.ai/sessions/04daea238562403aa751c7732b76f65b
Requested by: @roborew

Create scripts/lib/shared.sh consolidating repeated patterns:
- find_project_root(): was duplicated in 3 scripts
- strip_crlf(): was duplicated in 2 stack sync scripts
- gh_current_repo(): was inline in 10+ scripts
- OPENCODE_STATE_LABELS + transition_issue_state(): duplicated in 2 scripts
- oc_root(): standardizes config dir resolution
- source_fetch_spec_prd(): dedups fetch_spec_prd sourcing logic

Refactored 15 scripts to source shared.sh instead of maintaining
their own copies of these utilities.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant