Skip to content

Commit f9fdc7f

Browse files
MikhailShchatkoMongoDB Bot
authored and
MongoDB Bot
committed
SERVER-94187 Switch git ssh to https in copybara (#27049)
GitOrigin-RevId: 25a14df
1 parent fb91aae commit f9fdc7f

File tree

9 files changed

+233
-133
lines changed

9 files changed

+233
-133
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ OWNERS.yml @IamXander @anna-wawrzyniak @dhly-etc @dstorch @kaloianm @markbenvenu
2323
.style.yapf @10gen/devprod-build @10gen/devprod-correctness @svc-auto-approve-bot
2424
BUILD.bazel @10gen/devprod-build @svc-auto-approve-bot
2525
copy.bara.sky @IamXander @smcclure15 @svc-auto-approve-bot
26-
copybara.staging.sky @10gen/devprod-correctness @svc-auto-approve-bot
26+
copy.bara.staging.sky @10gen/devprod-correctness @svc-auto-approve-bot
2727
jsconfig.json @10gen/devprod-correctness @svc-auto-approve-bot
2828
package.json @10gen/devprod-correctness @svc-auto-approve-bot
2929
pnpm-lock.yaml @10gen/devprod-correctness @svc-auto-approve-bot

OWNERS.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ filters:
6262
approvers:
6363
- IamXander
6464
- smcclure15
65-
- "copybara.staging.sky":
65+
- "copy.bara.staging.sky":
6666
approvers:
6767
- 10gen/devprod-correctness
6868
- "jsconfig.json":

buildscripts/sync_repo_with_copybara.py

Lines changed: 167 additions & 105 deletions
Large diffs are not rendered by default.

buildscripts/tests/test_sync_repo_with_copybara.py

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import sys
44
import tempfile
55
import traceback
6-
from unittest.mock import patch
76
from buildscripts import sync_repo_with_copybara
87

98

@@ -134,17 +133,27 @@ def test_no_commit_found(self):
134133
def test_branch_exists(self):
135134
"""Perform a test to check that the branch exists in a repository."""
136135
test_name = "branch_exists_test"
137-
repo_url = "[email protected]:mongodb/mongo.git"
138-
branch_name = "v7.3"
139-
result = sync_repo_with_copybara.check_destination_branch_exists(repo_url, branch_name)
136+
copybara_config = sync_repo_with_copybara.CopybaraConfig(
137+
source=None,
138+
destination=sync_repo_with_copybara.CopybaraRepoConfig(
139+
git_url="https://github.com/mongodb/mongo.git",
140+
branch="v7.3",
141+
),
142+
)
143+
result = sync_repo_with_copybara.check_destination_branch_exists(copybara_config)
140144
self.assertTrue(result, f"{test_name}: SUCCESS!")
141145

142146
def test_branch_not_exists(self):
143-
"""Perform a test to check that the branch does not exists in a repository."""
147+
"""Perform a test to check that the branch does not exist in a repository."""
144148
test_name = "branch_not_exists_test"
145-
repo_url = "[email protected]:mongodb/mongo.git"
146-
branch_name = "v7.3test"
147-
result = sync_repo_with_copybara.check_destination_branch_exists(repo_url, branch_name)
149+
copybara_config = sync_repo_with_copybara.CopybaraConfig(
150+
source=None,
151+
destination=sync_repo_with_copybara.CopybaraRepoConfig(
152+
git_url="https://github.com/mongodb/mongo.git",
153+
branch="..invalid-therefore-impossible-to-create-branch-name",
154+
),
155+
)
156+
result = sync_repo_with_copybara.check_destination_branch_exists(copybara_config)
148157
self.assertFalse(result, f"{test_name}: SUCCESS!")
149158

150159
def test_only_mongodb_mongo_repo(self):
@@ -163,7 +172,7 @@ def test_only_mongodb_mongo_repo(self):
163172

164173
try:
165174
# Check if the repository is only the MongoDB official repository
166-
result = sync_repo_with_copybara.is_only_mongodb_mongo_repo()
175+
result = sync_repo_with_copybara.has_only_destination_repo_remote("mongodb/mongo")
167176
except Exception as err:
168177
print(f"{test_name}: FAIL!\n Exception occurred: {err}\n {traceback.format_exc()}")
169178
self.fail(f"{test_name}: FAIL!")
@@ -188,14 +197,27 @@ def test_not_only_mongodb_mongo_repo(self):
188197

189198
try:
190199
# Call function to push branch to public repository, expecting an exception
191-
sync_repo_with_copybara.push_branch_to_public_repo(
200+
sync_repo_with_copybara.push_branch_to_destination_repo(
192201
mongodb_mongo_dir,
193-
repo_url="",
194-
destination_branch_name="",
202+
copybara_config=sync_repo_with_copybara.CopybaraConfig(
203+
source=sync_repo_with_copybara.CopybaraRepoConfig(
204+
git_url="",
205+
repo_name="",
206+
branch="",
207+
),
208+
destination=sync_repo_with_copybara.CopybaraRepoConfig(
209+
git_url="",
210+
repo_name="",
211+
branch="",
212+
),
213+
),
195214
branching_off_commit="",
196215
)
197216
except Exception as err:
198-
if str(err) == "Not only mongodb repo":
217+
if (
218+
str(err)
219+
== f"{mongodb_mongo_dir} git repo has not only the destination repo remote"
220+
):
199221
return
200222

201223
self.fail(f"{test_name}: FAIL!")
@@ -222,8 +244,21 @@ def test_new_branch_commits_not_match_branching_off_commit(self):
222244
self.create_mock_repo_commits(mongodb_mongo_dir, 2)
223245
try:
224246
# Call function to push branch to public repository, expecting an exception
225-
sync_repo_with_copybara.push_branch_to_public_repo(
226-
mongodb_mongo_dir, "", "", invalid_branching_off_commit
247+
sync_repo_with_copybara.push_branch_to_destination_repo(
248+
mongodb_mongo_dir,
249+
sync_repo_with_copybara.CopybaraConfig(
250+
source=sync_repo_with_copybara.CopybaraRepoConfig(
251+
git_url="",
252+
repo_name="",
253+
branch="",
254+
),
255+
destination=sync_repo_with_copybara.CopybaraRepoConfig(
256+
git_url="",
257+
repo_name="",
258+
branch="",
259+
),
260+
),
261+
invalid_branching_off_commit,
227262
)
228263
except Exception as err:
229264
if (

copy.bara.sky

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# sourceUrl = "/path/to/source"
66
# destinationUrl = "/path/to/dest"
77

8-
sourceUrl = "git@github.com:10gen/mongo.git"
9-
destinationUrl = "git@github.com:mongodb/mongo.git"
8+
sourceUrl = "https://github.com/10gen/mongo.git"
9+
destinationUrl = "https://github.com/mongodb/mongo.git"
1010

1111
core.workflow(
1212
name = "default",
@@ -26,7 +26,7 @@ core.workflow(
2626
# Change the path here to the folder you want to publish publicly
2727
transformations = [
2828
# (^.*?) - matches the first line (without the newline char)
29-
# \n - matches the first newline (or nothing at all if there is no newline). If there is no match then nopthing happens
29+
# \n - matches the first newline (or nothing at all if there is no newline). If there is no match then nothing happens
3030
# ((\n|.)*) - matches everything after
3131
# Overall, this copies only the first line of the commit rather than the body
3232
metadata.scrubber("(^.*?)\n((\n|.)*)", replacement = "$1"),
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# This configuration is for migrating code from one Git repository to another using Copybara.
22
# It selectively copies content, excluding specific paths and preserving authorship.
3-
sourceUrl = "git@github.com:10gen/mongo.git"
4-
destinationUrl = "git@github.com:10gen/mongo-copybara.git"
3+
sourceUrl = "https://github.com/10gen/mongo.git"
4+
destinationUrl = "https://github.com/10gen/mongo-copybara.git"
55

66
core.workflow(
77
name = "default",
88
origin = git.origin(
99
url = sourceUrl,
1010
ref = "master",
11-
# VersionSelector
1211
),
1312
destination = git.destination(
1413
url = destinationUrl,
@@ -20,7 +19,11 @@ core.workflow(
2019
authoring = authoring.pass_thru("MongoDB <[email protected]>"),
2120
mode = "ITERATIVE",
2221
# Change the path here to the folder you want to publish publicly
23-
# transformations = [
24-
# core.move("path/to/folder/you/want/exported", ""),
25-
# ],
22+
transformations = [
23+
# (^.*?) - matches the first line (without the newline char)
24+
# \n - matches the first newline (or nothing at all if there is no newline). If there is no match then nothing happens
25+
# ((\n|.)*) - matches everything after
26+
# Overall, this copies only the first line of the commit rather than the body
27+
metadata.scrubber("(^.*?)\n((\n|.)*)", replacement = "$1"),
28+
],
2629
)

docs/branching/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The reason they should be pushed as separate commits is in the case of needing t
3434

3535
### Copybara configuration
3636

37-
`copybara.sky` and `copybara.staging.sky`
37+
`copy.bara.sky` and `copy.bara.staging.sky`
3838

3939
- Update "master" branch references with a new branch name
4040

etc/evergreen_yml_components/definitions.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,6 @@ functions:
16081608
- command: subprocess.exec
16091609
display_name: "sync repo with copybara"
16101610
type: test
1611-
patchable: false
16121611
params:
16131612
binary: bash
16141613
args:

etc/evergreen_yml_components/tasks/misc_tasks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,7 @@ tasks:
14151415

14161416
- name: sync_repo_with_copybara
14171417
tags: ["assigned_to_jira_team_devprod_correctness", "auxiliary"]
1418+
patchable: false
14181419
commands:
14191420
- command: manifest.load
14201421
- func: "git get project and add git tag"

0 commit comments

Comments
 (0)