Skip to content

Commit fe7e38b

Browse files
committed
update issue title with source repo prefix after transfer
1 parent 752256f commit fe7e38b

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

monorepo-migration/migrate_issues.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,36 @@ if [[ -z "$ISSUE_NUMBERS" ]]; then
6161
exit 0
6262
fi
6363

64+
# Extract short name from SOURCE_REPO (e.g., java-bigquery from googleapis/java-bigquery)
65+
REPO_SHORT_NAME=$(echo "$SOURCE_REPO" | cut -d'/' -f2)
66+
6467
# Process each issue
6568
for ISSUE_NUMBER in $ISSUE_NUMBERS; do
66-
echo "Transferring Issue #$ISSUE_NUMBER..."
69+
echo "Processing Issue #$ISSUE_NUMBER..."
70+
71+
# Get the current title
72+
TITLE=$(gh issue view "$ISSUE_NUMBER" --repo "$SOURCE_REPO" --json title --jq '.title')
73+
NEW_TITLE="[$REPO_SHORT_NAME] $TITLE"
6774

6875
if [ "$DRY_RUN" = true ]; then
69-
echo " Command: gh issue transfer $ISSUE_NUMBER $TARGET_REPO --repo $SOURCE_REPO"
76+
echo " [DRY RUN] Would transfer #$ISSUE_NUMBER to $TARGET_REPO"
77+
echo " [DRY RUN] Would update title to: $NEW_TITLE"
7078
else
71-
gh issue transfer "$ISSUE_NUMBER" "$TARGET_REPO" --repo "$SOURCE_REPO"
72-
echo " Transferred #$ISSUE_NUMBER"
79+
echo " Transferring #$ISSUE_NUMBER..."
80+
# Capture the output of transfer to get the new issue URL
81+
TRANSFER_OUTPUT=$(gh issue transfer "$ISSUE_NUMBER" "$TARGET_REPO" --repo "$SOURCE_REPO")
82+
83+
# The output is typically something like: https://github.com/googleapis/google-cloud-java/issues/1234
84+
NEW_ISSUE_URL=$(echo "$TRANSFER_OUTPUT" | grep -o 'https://github.com/[^ ]*')
85+
NEW_ISSUE_NUMBER=$(echo "$NEW_ISSUE_URL" | awk -F'/' '{print $NF}')
86+
87+
if [[ -n "$NEW_ISSUE_NUMBER" ]]; then
88+
echo " Transferred to $TARGET_REPO as #$NEW_ISSUE_NUMBER. Updating title..."
89+
gh issue edit "$NEW_ISSUE_NUMBER" --repo "$TARGET_REPO" --title "$NEW_TITLE"
90+
echo " Title updated."
91+
else
92+
echo " Warning: Could not determine new issue number from output: $TRANSFER_OUTPUT"
93+
fi
7394
fi
7495
done
7596

0 commit comments

Comments
 (0)