Skip to content

Commit 25ee649

Browse files
Remove support for copying repositories into the release org. (#45268)
This support was helpful to get started but creates problems with the current terraform-managed ros2-gbp org and with encouraging split-brain releases where some are made from external release repositories and some are made from the official release org. Before running the migration, check the source distribution for release repository urls outside the release org and mirror them to the release org before continuing. The rosdistro-bloom rewrite of this script intends to support this workflow with a separate subcommand for mirroring repos.
1 parent da119fb commit 25ee649

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

migration-tools/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,17 @@ Make sure rosdep is initialized if it isn't already.
2020

2121
sudo rosdep init
2222

23-
Configure a GitHub access token and release repository organization.
24-
The token only needs public repository access and must belong to a member of the target GitHub organization with repository creation permissions.
25-
26-
```
27-
GITHUB_TOKEN={token with public repository access}
28-
export GITHUB_TOKEN
29-
```
23+
This script used to copy release repositories into the release org as-needed.
24+
This worked for the initial bootstrapping but creates split-brain problems when releases are split between the official release org and others.
25+
Instead, use `git clone --mirror` and `git push --mirror` on release repositories that are not yet in the release org and update your rosdistro before running this script.
3026

3127
## Script arguments
3228

3329
The migration script has several named arguments, all of which are required.
3430
* `--dest DEST_ROSDISTRO`: The rosdistro which will receive the newly bloomed repositories.
3531
* `--source SOURCE_ROSDISTRO`: The rosdistro to take release repositories from for migration.
3632
* `--source-ref GIT_COMMIT_ID_OR_REF`: The migration may be attempted multiple times. Each attempt must specify ref or commit to start from so that future changes to the source distribution do not unintentionally affect migration. This also enables platform migration without changing the rosdistro name.
37-
* `--release-org GITHUB_ORG`: A GitHub organization for storing release repositories. If the repository does not exist in this organization a new repository will be created.
33+
* `--release-org GITHUB_ORG`: A GitHub organization for storing release repositories.
3834

3935
## Features
4036

migration-tools/migrate-rosdistro.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ def write_tracks_file(tracks, commit_msg=None):
4949

5050
args = parser.parse_args()
5151

52-
gclient = github.Github(os.environ['GITHUB_TOKEN'])
53-
release_org = gclient.get_organization(args.release_org)
54-
org_release_repos = [r.name for r in release_org.get_repos() if r.name]
55-
5652
if not os.path.isfile('index-v4.yaml'):
5753
raise RuntimeError('This script must be run from a rosdistro index directory.')
5854
rosdistro_dir = os.path.abspath(os.getcwd())
@@ -134,6 +130,10 @@ def write_tracks_file(tracks, commit_msg=None):
134130
if release_spec.version is None:
135131
raise ValueError(f'{repo_name} is not released in the source distribution (release version is missing or blank).')
136132
remote_url = release_spec.url
133+
134+
if not remote_url.startswith(f'https://github.com/{args.release_org}/'):
135+
raise ValueError(f'{remote_url} is not in the release org. Mirror the repository there to continue.')
136+
137137
release_repo = remote_url.split('/')[-1]
138138
if release_repo.endswith('.git'):
139139
release_repo = release_repo[:-4]
@@ -144,13 +144,6 @@ def write_tracks_file(tracks, commit_msg=None):
144144
if not tracks['tracks'].get(args.source):
145145
raise ValueError('Repository has not been released.')
146146

147-
if release_repo not in org_release_repos:
148-
release_org.create_repo(release_repo)
149-
new_release_repo_url = f'https://github.com/{args.release_org}/{release_repo}.git'
150-
subprocess.check_call(['git', 'remote', 'rename', 'origin', 'oldorigin'])
151-
subprocess.check_call(['git', 'remote', 'set-url', '--push', 'oldorigin', 'no_push'])
152-
subprocess.check_call(['git', 'remote', 'add', 'origin', new_release_repo_url])
153-
154147
if args.source != args.dest:
155148
# Copy a bloom .ignored file from source to target distro.
156149
if os.path.isfile(f'{args.source}.ignored'):
@@ -164,7 +157,7 @@ def write_tracks_file(tracks, commit_msg=None):
164157
dest_track = copy.deepcopy(tracks['tracks'][args.source])
165158
dest_track['ros_distro'] = args.dest
166159
tracks['tracks'][args.dest] = dest_track
167-
ls_remote = subprocess.check_output(['git', 'ls-remote', '--heads', 'oldorigin', f'*{args.source}*'], universal_newlines=True)
160+
ls_remote = subprocess.check_output(['git', 'ls-remote', '--heads', 'origin', f'*{args.source}*'], universal_newlines=True)
168161
for line in ls_remote.split('\n'):
169162
if line == '':
170163
continue
@@ -218,8 +211,6 @@ def write_tracks_file(tracks, commit_msg=None):
218211
# currently in the release track.
219212
release_inc = str(max(int(source_inc), int(dest_track['release_inc'])) + 1)
220213

221-
# Bloom will not run with multiple remotes.
222-
subprocess.check_call(['git', 'remote', 'remove', 'oldorigin'])
223214
subprocess.check_call(['git', 'bloom-release', '--non-interactive', '--release-increment', release_inc, '--unsafe', args.dest], stdin=subprocess.DEVNULL, env=os.environ)
224215
subprocess.check_call(['git', 'push', 'origin', '--all', '--force'])
225216
subprocess.check_call(['git', 'push', 'origin', '--tags', '--force'])

0 commit comments

Comments
 (0)