@@ -24,6 +24,7 @@ SYNC_BRANCH=""
2424RESUME=false
2525SKIP_PR=false
2626SKIP_MAPPING_UPDATE=false
27+ DRY_RUN=false
2728
2829MAPPING_FILE=" $REPO_ROOT /util/opentelemetry-util-genai/upstream_version_map.json"
2930VERSION_FILE=" $REPO_ROOT /util/opentelemetry-util-genai/src/opentelemetry/util/genai/version.py"
@@ -46,6 +47,8 @@ Options:
4647 --resume Continue after manual conflict resolution
4748 --skip-pr Do not create pull request automatically
4849 --skip-mapping-update Do not update util-genai upstream mapping files
50+ --dry-run Do everything except push and create PR (local validation).
51+ Uses current branch as base so script stays available.
4952 -h, --help Show this help message
5053
5154Typical flow:
@@ -102,6 +105,10 @@ while [[ $# -gt 0 ]]; do
102105 SKIP_MAPPING_UPDATE=true
103106 shift
104107 ;;
108+ --dry-run)
109+ DRY_RUN=true
110+ shift
111+ ;;
105112 -h|--help)
106113 usage
107114 exit 0
@@ -192,11 +199,18 @@ update_mapping_and_readme() {
192199}
193200
194201push_branch () {
202+ if [[ " $DRY_RUN " == true ]]; then
203+ echo " [DRY-RUN] Would push branch: $SYNC_BRANCH -> origin"
204+ return
205+ fi
195206 git push -u origin " $SYNC_BRANCH "
196207}
197208
198209create_pr () {
199- if [[ " $SKIP_PR " == true ]]; then
210+ if [[ " $SKIP_PR " == true ]] || [[ " $DRY_RUN " == true ]]; then
211+ if [[ " $DRY_RUN " == true ]]; then
212+ echo " [DRY-RUN] Would create PR for branch: $SYNC_BRANCH -> $BASE_BRANCH "
213+ fi
200214 return
201215 fi
202216 require_command gh
233247require_command git
234248require_command python3
235249
250+ if [[ " $DRY_RUN " == true ]]; then
251+ echo " === DRY-RUN mode: will not push or create PR ==="
252+ fi
253+
236254ensure_remote
237255git fetch origin " $BASE_BRANCH "
238256git fetch " $UPSTREAM_REMOTE " " $UPSTREAM_BRANCH "
@@ -271,12 +289,20 @@ else
271289 # ── Start a new sync ──
272290 ensure_clean_worktree
273291
292+ ORIG_BRANCH=$( git branch --show-current) # save for dry-run cleanup hint
274293 if [[ -z " $SYNC_BRANCH " ]]; then
275294 SYNC_BRANCH=" sync/upstream-$( date -u +%Y%m%d-%H%M%S) "
276295 fi
277296
278- echo " Creating sync branch: $SYNC_BRANCH (from origin/$BASE_BRANCH )"
279- git checkout -B " $SYNC_BRANCH " " origin/$BASE_BRANCH "
297+ # Dry-run: use current branch as base so sync script and mapping infra stay in place
298+ if [[ " $DRY_RUN " == true ]]; then
299+ BASE_REF=" HEAD"
300+ echo " Creating sync branch: $SYNC_BRANCH (from current branch $ORIG_BRANCH )"
301+ else
302+ BASE_REF=" origin/$BASE_BRANCH "
303+ echo " Creating sync branch: $SYNC_BRANCH (from origin/$BASE_BRANCH )"
304+ fi
305+ git checkout -B " $SYNC_BRANCH " " $BASE_REF "
280306
281307 UPSTREAM_TARGET=$( get_upstream_target)
282308 if [[ -n " $UPSTREAM_COMMIT " ]]; then
@@ -316,4 +342,10 @@ push_branch
316342create_pr
317343
318344echo " "
319- echo " Done. Sync branch: $SYNC_BRANCH "
345+ if [[ " $DRY_RUN " == true ]]; then
346+ echo " DRY-RUN complete. Sync branch exists locally: $SYNC_BRANCH "
347+ echo " To discard: git checkout ${ORIG_BRANCH:- $BASE_BRANCH } && git branch -D $SYNC_BRANCH "
348+ echo " To push manually: git push -u origin $SYNC_BRANCH "
349+ else
350+ echo " Done. Sync branch: $SYNC_BRANCH "
351+ fi
0 commit comments