@@ -172,9 +172,18 @@ should_skip_plugin() {
172172}
173173
174174# Check if a branch exists on remote
175+ # Returns: 0 if exists, 1 if doesn't exist, 2 on error
175176branch_exists_remote () {
176177 local branch=" $1 "
177- git ls-remote --heads origin " $branch " 2> /dev/null | grep -q " refs/heads/${branch} $"
178+ local output
179+
180+ output=$( git ls-remote --heads origin " $branch " 2>&1 )
181+ if [ $? -ne 0 ]; then
182+ echo " ⚠️ Cannot check remote: $output " >&2
183+ return 2 # Error - caller should abort
184+ fi
185+
186+ echo " $output " | grep -q " refs/heads/${branch} $"
178187}
179188
180189# Check if a branch exists locally
@@ -186,6 +195,7 @@ branch_exists_local() {
186195# Get unique branch name for the release
187196# In test mode: release-X.Y.Z-test, release-X.Y.Z-test-2, release-X.Y.Z-test-3, ...
188197# In non-test mode: release-X.Y.Z (fails if exists - real releases shouldn't have duplicates)
198+ # Returns: 0 success, 1 no available branch, 2 on error
189199get_unique_branch_name () {
190200 local plugin=" $1 "
191201 local version=" $2 "
@@ -197,22 +207,29 @@ get_unique_branch_name() {
197207 local attempt=2
198208 local max_attempts=20
199209
200- while branch_exists_remote " $candidate " || branch_exists_local " $candidate " ; do
210+ while true ; do
211+ branch_exists_remote " $candidate "
212+ local status=$?
213+
214+ [ $status -eq 2 ] && return 2 # Propagate error
215+
216+ if [ $status -eq 1 ] && ! branch_exists_local " $candidate " ; then
217+ echo " $candidate "
218+ return 0
219+ fi
220+
201221 candidate=" ${base_name} -test-${attempt} "
202222 attempt=$(( attempt + 1 ))
203- if [ $attempt -gt $max_attempts ]; then
204- echo " "
205- return 1
206- fi
223+ [ $attempt -gt $max_attempts ] && return 1
207224 done
208-
209- echo " $candidate "
210225 else
211- # Non-test mode: use base name, return empty if exists
212- if branch_exists_remote " $base_name " ; then
213- echo " "
214- return 1
215- fi
226+ # Non-test mode: use base name, fail if exists
227+ branch_exists_remote " $base_name "
228+ local status=$?
229+
230+ [ $status -eq 2 ] && return 2 # Propagate error
231+ [ $status -eq 0 ] && return 1 # Branch exists
232+
216233 echo " $base_name "
217234 fi
218235}
@@ -241,39 +258,47 @@ validate_inputs() {
241258 fi
242259}
243260
244- # Calculate new plugin versions
261+ # Calculate new plugin versions using smart proxy-based bumping
262+ # For each plugin:
263+ # 1. Get the plugin's latest release version
264+ # 2. Get the proxy version that release was built with
265+ # 3. Compare proxy major version changes to determine bump type
245266calculate_plugin_versions () {
246- echo -e " ${BLUE} Calculating plugin versions...${NC} "
247-
248- # Get current proxy version to determine bump type
249- CURRENT_PROXY_VERSION=$( grep " s.version" " $REPO_ROOT /AirshipFrameworkProxy.podspec" | grep -o " [0-9]*\.[0-9]*\.[0-9]*" )
250- BUMP_TYPE=$( determine_bump_type " $CURRENT_PROXY_VERSION " " $PROXY_VERSION " )
251-
252- echo -e " Current proxy: ${BOLD}${CURRENT_PROXY_VERSION}${NC} "
253- echo -e " New proxy: ${BOLD}${PROXY_VERSION}${NC} "
254- echo -e " Bump type: ${BOLD}${BUMP_TYPE}${NC} "
267+ echo -e " ${BLUE} Calculating plugin versions (smart proxy-based bumping)...${NC} "
255268 echo " "
256269
257- if [ " $BUMP_TYPE " = " none" ]; then
258- echo -e " ${RED} Error: No version bump detected${NC} "
259- exit 1
260- fi
261-
262- # Fetch latest versions for each plugin and calculate new versions
263270 for plugin in " ${PLUGIN_KEYS[@]} " ; do
264271 local repo=$( get_repo_name " $plugin " )
272+ local full_repo=" urbanairship/${repo} "
265273
266- # Fetch latest version (uses shared function from version_utils.sh)
267- local latest_version=$( get_latest_release_version " urbanairship/ ${repo} " )
274+ # Get plugin's latest release version
275+ local latest_version=$( get_latest_release_version " $full_repo " )
268276 if [ $? -ne 0 ] || [ -z " $latest_version " ]; then
269277 echo -e " ${RED} Failed to fetch version for ${repo}${NC} "
270278 exit 1
271279 fi
272280
273- IFS=' .' read -r major minor patch <<< " $latest_version"
281+ # Get proxy version from that release
282+ local release_proxy_version=$( get_proxy_version_from_release " $full_repo " " $plugin " )
283+
284+ echo -e " ${BOLD}${plugin}${NC} "
285+ echo -e " Current version: ${latest_version} "
286+ echo -e " Release proxy: ${release_proxy_version} "
287+ echo -e " New proxy: ${PROXY_VERSION} "
288+
289+ # Determine bump type based on proxy version change
290+ local bump_type=$( determine_plugin_bump_type " $release_proxy_version " " $PROXY_VERSION " )
274291
275- # Apply bump type
276- case " $BUMP_TYPE " in
292+ if [ " $bump_type " = " none" ]; then
293+ echo -e " Bump: ${YELLOW} none (skipping - already up to date)${NC} "
294+ set_new_version " $plugin " " "
295+ echo " "
296+ continue
297+ fi
298+
299+ # Apply bump to plugin version
300+ IFS=' .' read -r major minor patch <<< " $latest_version"
301+ case " $bump_type " in
277302 major)
278303 major=$(( major + 1 ))
279304 minor=0
@@ -290,9 +315,25 @@ calculate_plugin_versions() {
290315
291316 local new_version=" ${major} .${minor} .${patch} "
292317 set_new_version " $plugin " " $new_version "
293- echo -e " ${plugin} : ${latest_version} → ${BOLD}${new_version}${NC} "
318+
319+ echo -e " Bump: ${GREEN}${bump_type}${NC} "
320+ echo -e " New version: ${BOLD}${new_version}${NC} "
321+ echo " "
294322 done
295- echo " "
323+
324+ # Check if any plugins need updating
325+ local any_update=false
326+ for plugin in " ${PLUGIN_KEYS[@]} " ; do
327+ if [ -n " $( get_new_version " $plugin " ) " ]; then
328+ any_update=true
329+ break
330+ fi
331+ done
332+
333+ if [ " $any_update " = false ]; then
334+ echo -e " ${YELLOW} No plugins need updating - all are already on proxy ${PROXY_VERSION}${NC} "
335+ exit 0
336+ fi
296337}
297338
298339# Clone plugin repositories
@@ -524,6 +565,13 @@ update_plugin() {
524565 # Get unique branch name (handles test mode auto-increment)
525566 local branch_name
526567 branch_name=$( get_unique_branch_name " $plugin " " $plugin_version " )
568+ local branch_status=$?
569+
570+ if [ $branch_status -eq 2 ]; then
571+ echo " ✗ Cannot verify branch availability (network/auth error)"
572+ echo " Fix the error above and retry"
573+ return 1
574+ fi
527575
528576 if [ -z " $branch_name " ]; then
529577 if [ " $TEST_MODE " = true ]; then
@@ -684,17 +732,24 @@ main() {
684732 # Disable exit-on-error for plugin updates so one failure doesn't kill all
685733 set +e
686734 for plugin in " ${PLUGIN_KEYS[@]} " ; do
687- # Skip if plugin is disabled
735+ # Skip if plugin is disabled via CLI flag
688736 if should_skip_plugin " $plugin " ; then
689737 set_pr_url " $plugin " " SKIPPED"
690738 continue
691739 fi
692740
741+ # Skip if no version update needed (empty version = already up to date)
742+ local plugin_version=" $( get_new_version " $plugin " ) "
743+ if [ -z " $plugin_version " ]; then
744+ set_pr_url " $plugin " " UP-TO-DATE"
745+ continue
746+ fi
747+
693748 echo " "
694749
695750 # Update plugin (with error handling)
696751 local error_file=$( mktemp)
697- if pr_url=$( update_plugin " $plugin " " $( get_new_version " $plugin " ) " " $WORK_DIR /$( get_repo_name " $plugin " ) " 2> " $error_file " ) ; then
752+ if pr_url=$( update_plugin " $plugin " " $plugin_version " " $WORK_DIR /$( get_repo_name " $plugin " ) " 2> " $error_file " ) ; then
698753 set_pr_url " $plugin " " $pr_url "
699754 echo -e " ${GREEN} ✓ PR created: $pr_url ${NC} "
700755 else
@@ -715,6 +770,7 @@ main() {
715770
716771 for plugin in " ${PLUGIN_KEYS[@]} " ; do
717772 local pr_url=" $( get_pr_url " $plugin " ) "
773+ local plugin_version=" $( get_new_version " $plugin " ) "
718774 local status_icon=" ✓"
719775 local color=" $GREEN "
720776 if [ " $pr_url " = " FAILED" ]; then
@@ -723,8 +779,11 @@ main() {
723779 elif [ " $pr_url " = " SKIPPED" ]; then
724780 status_icon=" ○"
725781 color=" $YELLOW "
782+ elif [ " $pr_url " = " UP-TO-DATE" ]; then
783+ status_icon=" ="
784+ color=" $BLUE "
726785 fi
727- echo -e " ${color}${status_icon} $( get_display_name " $plugin " ) $( get_new_version " $plugin " ) : ${pr_url}${NC} "
786+ echo -e " ${color}${status_icon} $( get_display_name " $plugin " ) ${plugin_version :- current} : ${pr_url}${NC} "
728787 done
729788
730789 echo " "
@@ -737,7 +796,7 @@ main() {
737796 done
738797 fi
739798
740- # Check if any plugins succeeded
799+ # Check if any plugins succeeded (UP-TO-DATE counts as success)
741800 local any_success=false
742801 for plugin in " ${PLUGIN_KEYS[@]} " ; do
743802 local url=" $( get_pr_url " $plugin " ) "
0 commit comments