@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 49 lines 1.1 kB view raw
1<?php 2 3echo pht('Stripping remotes from repository default branches...')."\n"; 4 5$table = new PhabricatorRepository(); 6$table->openTransaction(); 7$conn_w = $table->establishConnection('w'); 8 9$repos = queryfx_all( 10 $conn_w, 11 'SELECT id, name, details FROM %T WHERE versionControlSystem = %s FOR UPDATE', 12 $table->getTableName(), 13 'git'); 14 15foreach ($repos as $repo) { 16 $details = json_decode($repo['details'], true); 17 18 $old = idx($details, 'default-branch', ''); 19 if (strpos($old, '/') === false) { 20 continue; 21 } 22 23 $parts = explode('/', $old); 24 $parts = array_filter($parts); 25 $new = end($parts); 26 27 $details['default-branch'] = $new; 28 $new_details = json_encode($details); 29 30 $id = $repo['id']; 31 $name = $repo['name']; 32 33 echo pht( 34 "Updating default branch for repository #%d '%s' from ". 35 "'%s' to '%s' to remove the explicit remote.\n", 36 $id, 37 $name, 38 $old, 39 $new); 40 queryfx( 41 $conn_w, 42 'UPDATE %T SET details = %s WHERE id = %d', 43 $table->getTableName(), 44 $new_details, 45 $id); 46} 47 48$table->saveTransaction(); 49echo pht('Done.')."\n";