-
Notifications
You must be signed in to change notification settings - Fork 0
Add script to sync suggestions from previous draft branch #111
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
base: main
Are you sure you want to change the base?
Changes from all commits
65d2388
217c0f0
560806f
6f83f0f
f9bf593
e527183
64e63b1
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,80 @@ | ||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||
| # scripts/sync-suggestions.sh | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # 前のドラフトブランチから教員の Suggest を取り込むスクリプト | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # Usage: | ||||||||||||||||||||||||||
| # ./scripts/sync-suggestions.sh # 現在のブランチに対して自動判定 | ||||||||||||||||||||||||||
| # ./scripts/sync-suggestions.sh 2nd-draft # 指定ブランチに対して実行 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| set -e | |
| set -euo pipefail |
Copilot
AI
Nov 27, 2025
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.
The git checkout on line 15 can fail if the branch doesn't exist locally or if there are uncommitted changes, but no error message is provided to explain what went wrong. Add validation and user-friendly error messages before attempting checkout.
| CURRENT_BRANCH="$1" | |
| CURRENT_BRANCH="$1" | |
| # Check if branch exists locally | |
| if ! git rev-parse --verify "$CURRENT_BRANCH" >/dev/null 2>&1; then | |
| echo "Error: ブランチ '$CURRENT_BRANCH' はローカルに存在しません。" | |
| exit 1 | |
| fi | |
| # Check for uncommitted changes | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "Error: 作業ディレクトリにコミットされていない変更があります。ブランチを切り替える前にコミットまたはスタッシュしてください。" | |
| exit 1 | |
| fi |
Copilot
AI
Nov 27, 2025
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.
If the remote branches don't exist, git fetch will fail but won't provide user-friendly error messages. Add error handling with clear messages like 'Branch $PREV_BRANCH not found on remote' to help users understand what went wrong.
| git fetch origin "$PREV_BRANCH" | |
| git fetch origin "$CURRENT_BRANCH" | |
| if ! git fetch origin "$PREV_BRANCH"; then | |
| echo "Error: Branch $PREV_BRANCH not found on remote (origin)" | |
| exit 1 | |
| fi | |
| if ! git fetch origin "$CURRENT_BRANCH"; then | |
| echo "Error: Branch $CURRENT_BRANCH not found on remote (origin)" | |
| exit 1 | |
| fi |
Copilot
AI
Nov 27, 2025
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.
The merge command will fail if there are merge conflicts, but users won't get guidance on how to resolve them. Consider wrapping this in a conditional that checks the exit status and provides instructions for conflict resolution (e.g., 'Conflicts detected. Please resolve them manually and run git merge --continue').
| git merge "origin/$PREV_BRANCH" --no-ff -m "Merge suggestions from $PREV_BRANCH" | |
| if ! git merge "origin/$PREV_BRANCH" --no-ff -m "Merge suggestions from $PREV_BRANCH"; then | |
| echo "" | |
| echo "⚠️ マージ中にコンフリクトが発生しました。" | |
| echo "以下の手順でコンフリクトを解消してください:" | |
| echo " 1. ファイルのコンフリクト箇所を手動で修正" | |
| echo " 2. 修正後、'git add <修正したファイル>' を実行" | |
| echo " 3. 'git merge --continue' または 'git commit' を実行" | |
| echo "" | |
| echo "解消後、再度 'git push origin $CURRENT_BRANCH' を実行してください。" | |
| exit 1 | |
| fi |
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.
The script lacks execute permissions declaration. Add
chmod +xinstruction to the documentation or consider adding a check at the beginning of the script to ensure it has execute permissions.