Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/093.gitremotes.php
| <?php | <?php | ||||
| echo "Stripping remotes from repository default branches...\n"; | echo pht('Stripping remotes from repository default branches...')."\n"; | ||||
| $table = new PhabricatorRepository(); | $table = new PhabricatorRepository(); | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| $repos = queryfx_all( | $repos = queryfx_all( | ||||
| $conn_w, | $conn_w, | ||||
| 'SELECT id, name, details FROM %T WHERE versionControlSystem = %s FOR UPDATE', | 'SELECT id, name, details FROM %T WHERE versionControlSystem = %s FOR UPDATE', | ||||
| Show All 13 Lines | foreach ($repos as $repo) { | ||||
| $new = end($parts); | $new = end($parts); | ||||
| $details['default-branch'] = $new; | $details['default-branch'] = $new; | ||||
| $new_details = json_encode($details); | $new_details = json_encode($details); | ||||
| $id = $repo['id']; | $id = $repo['id']; | ||||
| $name = $repo['name']; | $name = $repo['name']; | ||||
| echo "Updating default branch for repository #{$id} '{$name}' from ". | echo pht( | ||||
| "'{$old}' to '{$new}' to remove the explicit remote.\n"; | "Updating default branch for repository #%d '%s' from ". | ||||
| "'%s' to '%s' to remove the explicit remote.\n", | |||||
| $id, | |||||
| $name, | |||||
| $old, | |||||
| $new); | |||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'UPDATE %T SET details = %s WHERE id = %d', | 'UPDATE %T SET details = %s WHERE id = %d', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| $new_details, | $new_details, | ||||
| $id); | $id); | ||||
| } | } | ||||
| $table->saveTransaction(); | $table->saveTransaction(); | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||