-
Notifications
You must be signed in to change notification settings - Fork 3.2k
added mf tool #33380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added mf tool #33380
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| MF_ORIGIN_URL=https://github.com/musescore/muse_framework.git | ||||||||||||||||
| MF_FORK_URL="" | ||||||||||||||||
| TASK="" | ||||||||||||||||
|
|
||||||||||||||||
| while [[ "$#" -gt 0 ]]; do | ||||||||||||||||
| case $1 in | ||||||||||||||||
| -f|--fork) MF_FORK_URL="$2"; shift ;; | ||||||||||||||||
| -t|--task) TASK="$2"; shift ;; | ||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||
| *) echo "Unknown parameter passed: $1"; exit 1 ;; | ||||||||||||||||
| esac | ||||||||||||||||
| shift | ||||||||||||||||
| done | ||||||||||||||||
|
|
||||||||||||||||
| if [ -z "$MF_FORK_URL" ]; then MF_FORK_URL=$(cat mf_fork_url.local); fi | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling and whitespace trimming for file reading. The 🛡️ Proposed fix to add file validation and whitespace trimming-if [ -z "$MF_FORK_URL" ]; then MF_FORK_URL=$(cat mf_fork_url.local); fi
+if [ -z "$MF_FORK_URL" ]; then
+ if [ -f "mf_fork_url.local" ]; then
+ MF_FORK_URL=$(cat mf_fork_url.local | tr -d '[:space:]')
+ fi
+fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| if [ -z "$MF_FORK_URL" ]; then echo "error: not set MF_FORK_URL"; exit 1; fi | ||||||||||||||||
|
|
||||||||||||||||
| if [ -z "$TASK" ]; then echo "error: not set TASK"; exit 1; fi | ||||||||||||||||
|
|
||||||||||||||||
| echo "MF_FORK_URL: $MF_FORK_URL" | ||||||||||||||||
| echo "TASK: $TASK" | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| function use_fork() { | ||||||||||||||||
| git submodule set-url muse $MF_FORK_URL | ||||||||||||||||
| cd muse | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for directory changes. Both 🛡️ Proposed fix to add cd error handling function use_fork() {
git submodule set-url muse "$MF_FORK_URL"
- cd muse
+ cd muse || { echo "error: failed to cd into muse directory"; exit 1; }
git remote set-url origin "$MF_FORK_URL"
git remote remove upstream
git remote add upstream "$MF_ORIGIN_URL"
git remote -v
cd ..
}
function use_origin() {
git submodule set-url muse "$MF_ORIGIN_URL"
git submodule update --init
- cd muse
+ cd muse || { echo "error: failed to cd into muse directory"; exit 1; }
git remote set-url origin "$MF_ORIGIN_URL"
git remote remove upstream
git remote -v
cd ..
}Also applies to: 39-39 🧰 Tools🪛 Shellcheck (0.11.0)[warning] 28-28: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164) 🤖 Prompt for AI Agents |
||||||||||||||||
| git remote set-url origin $MF_FORK_URL | ||||||||||||||||
| git remote remove upstream | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle missing remote gracefully. The 🛡️ Proposed fix to handle missing remoteOption 1: Check if remote exists before removing: function use_fork() {
git submodule set-url muse "$MF_FORK_URL"
cd muse || exit 1
git remote set-url origin "$MF_FORK_URL"
- git remote remove upstream
+ git remote get-url upstream &>/dev/null && git remote remove upstream
git remote add upstream "$MF_ORIGIN_URL"
git remote -v
cd ..
}
function use_origin() {
git submodule set-url muse "$MF_ORIGIN_URL"
git submodule update --init
cd muse || exit 1
git remote set-url origin "$MF_ORIGIN_URL"
- git remote remove upstream
+ git remote get-url upstream &>/dev/null && git remote remove upstream
git remote -v
cd ..
}Option 2: Suppress error if remote doesn't exist: - git remote remove upstream
+ git remote remove upstream 2>/dev/null || trueAlso applies to: 41-41 🤖 Prompt for AI Agents |
||||||||||||||||
| git remote add upstream $MF_ORIGIN_URL | ||||||||||||||||
| git remote -v | ||||||||||||||||
| cd .. | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| function use_origin() { | ||||||||||||||||
| git submodule set-url muse $MF_ORIGIN_URL | ||||||||||||||||
| git submodule update --init | ||||||||||||||||
| cd muse | ||||||||||||||||
| git remote set-url origin $MF_ORIGIN_URL | ||||||||||||||||
| git remote remove upstream | ||||||||||||||||
| git remote -v | ||||||||||||||||
| cd .. | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| case "$TASK" in | ||||||||||||||||
| "use-fork") | ||||||||||||||||
| use_fork | ||||||||||||||||
| ;; | ||||||||||||||||
|
Comment on lines
+47
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding submodule update for consistency. The Is this intentional, or should 📝 Proposed fix if update should be included "use-fork")
git submodule set-url muse "$MF_FORK_URL"
+ git submodule update --init
;;📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.11.0)[info] 27-27: Double quote to prevent globbing and word splitting. (SC2086) 🤖 Prompt for AI Agents |
||||||||||||||||
| "use-origin") | ||||||||||||||||
| use_origin | ||||||||||||||||
| ;; | ||||||||||||||||
| "sync-origin") | ||||||||||||||||
| use_origin | ||||||||||||||||
| git submodule update --init --remote ./muse | ||||||||||||||||
| ;; | ||||||||||||||||
| *) echo "Unknown task: $TASK"; exit 1 ;; | ||||||||||||||||
| esac | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for Git command failures.
The script executes multiple git commands without checking their exit status. If any git command fails (e.g., network issues, invalid URL, permissions), the script continues silently, which can cause confusion.
🛡️ Proposed fix to add error handling
Add
set -eafter the shebang to exit immediately if any command fails:#!/usr/bin/env bash +set -eAlternatively, for stricter error handling, use:
set -euo pipefailThis will exit on:
-e)-u)-o pipefail)📝 Committable suggestion
🤖 Prompt for AI Agents