SERVER-94187 Switch git ssh to https in copybara (#27211)

GitOrigin-RevId: 872162766296a1908bda09c3845615e3e5dde576
This commit is contained in:
Mikhail Shchatko 2024-11-20 22:30:38 +02:00 committed by MongoDB Bot
parent c30eb1a854
commit f8bb4ea493
6 changed files with 235 additions and 132 deletions

View File

@ -53,7 +53,8 @@ filters:
- "copy.bara.sky": - "copy.bara.sky":
approvers: approvers:
- IamXander - IamXander
- "copybara.staging.sky": - smcclure15
- "copy.bara.staging.sky":
approvers: approvers:
- devprod-correctness - devprod-correctness
- "jsconfig.json": - "jsconfig.json":

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import argparse import argparse
import fileinput
import subprocess import subprocess
import os import os
import sys import sys
@ -16,41 +17,77 @@ from buildscripts.util.read_config import read_config_file
from evergreen.api import RetryingEvergreenApi from evergreen.api import RetryingEvergreenApi
class CopybaraBranchNames(NamedTuple): class CopybaraRepoConfig(NamedTuple):
"""Copybara sync branch names.""" """Copybara source and destination repo sync configuration."""
source: Optional[str] git_url: Optional[str] = None
destination: Optional[str] repo_name: Optional[str] = None
branch: Optional[str] = None
class CopybaraConfig(NamedTuple):
"""Copybara sync configuration."""
source: Optional[CopybaraRepoConfig] = None
destination: Optional[CopybaraRepoConfig] = None
@classmethod @classmethod
def empty(cls) -> CopybaraBranchNames: def empty(cls) -> CopybaraConfig:
return cls( return cls(
source=None, source=None,
destination=None, destination=None,
) )
@classmethod @classmethod
def from_copybara_sky_file(cls, file_path: str) -> CopybaraBranchNames: def from_copybara_sky_file(cls, file_path: str) -> CopybaraConfig:
source_branch_name_pattern = re.compile(r'ref = "(.+?)"') with open(file_path, "r") as file:
destination_branch_name_pattern = re.compile(r'push = "(.+?)"')
with open(file_path, 'r') as file:
content = file.read() content = file.read()
source_branch_name_match = source_branch_name_pattern.search(content) # Delete comments
destination_branch_name_match = destination_branch_name_pattern.search(content) content = re.sub(r"#.*", "", content)
# Check if both required patterns were found and return them source_url_match = re.search(r'sourceUrl = "(.+?)"', content)
if source_branch_name_match and destination_branch_name_match: if source_url_match is None:
return cls( return cls.empty()
source=source_branch_name_match.group(1),
destination=destination_branch_name_match.group(1),
)
# Return empty if any pattern is not found source_branch_name_match = re.search(r'ref = "(.+?)"', content)
return cls.empty() if source_branch_name_match is None:
return cls.empty()
destination_url_match = re.search(r'destinationUrl = "(.+?)"', content)
if destination_url_match is None:
return cls.empty()
destination_branch_name_match = re.search(r'push = "(.+?)"', content)
if destination_branch_name_match is None:
return cls.empty()
repo_name_regex = re.compile(r"([^:/]+/[^:/]+)\.git")
source_git_url = source_url_match.group(1)
source_repo_name_match = repo_name_regex.search(source_git_url)
if source_repo_name_match is None:
return cls.empty()
destination_git_url = destination_url_match.group(1)
destination_repo_name_match = repo_name_regex.search(destination_git_url)
if destination_repo_name_match is None:
return cls.empty()
return cls(
source=CopybaraRepoConfig(
git_url=source_git_url,
repo_name=source_repo_name_match.group(1),
branch=source_branch_name_match.group(1),
),
destination=CopybaraRepoConfig(
git_url=destination_git_url,
repo_name=destination_repo_name_match.group(1),
branch=destination_branch_name_match.group(1),
),
)
def is_complete(self) -> bool: def is_complete(self) -> bool:
return self.source and self.destination return self.source is not None and self.destination is not None
def run_command(command): def run_command(command):
@ -135,51 +172,51 @@ def send_failure_message_to_slack(expansions):
) )
def check_destination_branch_exists(repo_url: str, branch_name: str) -> bool: def check_destination_branch_exists(copybara_config: CopybaraConfig) -> bool:
""" """
Check if a specific branch exists in a remote git repository. Check if a specific branch exists in the destination git repository.
Args: Args:
- repo_url (str): The URL of the remote git repository. - copybara_config (CopybaraConfig): Copybara configuration.
- branch_name (str): The name of the branch to check for existence.
Returns Returns
- bool: `True` if the branch exists in the remote repository, `False` otherwise. - bool: `True` if the branch exists in the destination repository, `False` otherwise.
""" """
command = f"git ls-remote {repo_url} {branch_name}" command = (
f"git ls-remote {copybara_config.destination.git_url} {copybara_config.destination.branch}")
output = run_command(command) output = run_command(command)
return branch_name in output return copybara_config.destination.branch in output
def find_matching_commit(dir_10gen_mongo: str, dir_mongodb_mongo: str) -> str: def find_matching_commit(dir_source_repo: str, dir_destination_repo: str) -> Optional[str]:
""" """
Finds a matching commit in the dir_mongodb_mongo repository based on the private hash from the dir_10gen_mongo repository. Finds a matching commit in the destination repository based on the commit hash from the source repository.
Args: Args:
- dir_10gen_mongo: The directory of the 10gen-mongo repository. - dir_source_repo: The directory of the source repository.
- dir_mongodb_mongo: The directory of the mongodb-mongo repository. - dir_destination_repo: The directory of the destination repository.
Returns Returns
The hash of the matching commit if found; otherwise, prints a message and returns None. The hash of the matching commit if found; otherwise, prints a message and returns None.
""" """
# Navigate to the 10gen-mongo repository # Navigate to the source repository
os.chdir(dir_10gen_mongo) os.chdir(dir_source_repo)
# Find the latest commit hash. # Find the latest commit hash.
private_hash = run_command("git log --pretty=format:\"%H\" -1") source_hash = run_command('git log --pretty=format:"%H" -1')
# Attempt to find a matching commit in the mongodb-mongo repository. # Attempt to find a matching commit in the destination repository.
commit = run_command( commit = run_command(
f"git --git-dir={dir_mongodb_mongo}/.git log -1 --pretty=format:\"%H\" --grep \"GitOrigin-RevId: {private_hash}\"" f'git --git-dir={dir_destination_repo}/.git log -1 --pretty=format:"%H" --grep "GitOrigin-RevId: {source_hash}"'
) )
first_commit = run_command("git rev-list --max-parents=0 HEAD") first_commit = run_command("git rev-list --max-parents=0 HEAD")
# Loop until a matching commit is found or the first commit is reached. # Loop until a matching commit is found or the first commit is reached.
while len(commit.splitlines()) != 1: while len(commit.splitlines()) != 1:
current_commit = run_command("git log --pretty=format:\"%H\" -1") current_commit = run_command('git log --pretty=format:"%H" -1')
if current_commit.strip() == first_commit.strip(): if current_commit.strip() == first_commit.strip():
print( print(
@ -187,84 +224,82 @@ def find_matching_commit(dir_10gen_mongo: str, dir_mongodb_mongo: str) -> str:
) )
return None return None
# Revert to the previous commit in the 10gen-mongo repository and try again. # Revert to the previous commit in the source repository and try again.
run_command("git checkout HEAD~1") run_command("git checkout HEAD~1")
private_hash = run_command("git log --pretty=format:\"%H\" -1") source_hash = run_command('git log --pretty=format:"%H" -1')
# Attempt to find a matching commit again in the mongodb-mongo repository. # Attempt to find a matching commit again in the destination repository.
commit = run_command( commit = run_command(
f"git --git-dir={dir_mongodb_mongo}/.git log -1 --pretty=format:\"%H\" --grep \"GitOrigin-RevId: {private_hash}\"" f'git --git-dir={dir_destination_repo}/.git log -1 --pretty=format:"%H" --grep "GitOrigin-RevId: {source_hash}"'
) )
return commit return commit
def is_only_mongodb_mongo_repo(): def has_only_destination_repo_remote(repo_name: str):
""" """
Check if the current directory's Git repository only contains the 'mongodb/mongo.git' remote URL. Check if the current directory's Git repository only contains the destination repository remote URL.
Returns Returns
bool: True if the repository only contains the 'mongodb/mongo.git' remote URL, False otherwise. bool: True if the repository only contains the destination repository remote URL, False otherwise.
""" """
git_config_path = os.path.join('.git', 'config') git_config_path = os.path.join('.git', 'config')
with open(git_config_path, 'r') as f: with open(git_config_path, 'r') as f:
config_content = f.read() config_content = f.read()
# Define a regular expression pattern to match the mongodb/mongo.git # Define a regular expression pattern to match the '{owner}/{repo}.git'
url_pattern = r'url\s*=\s*(.*?\.git\s*)' url_pattern = r"url\s*=\s*(.*?\.git\s*)"
matches = re.findall(url_pattern, config_content) matches = re.findall(url_pattern, config_content)
if len(matches) == 1 and matches[0].strip().endswith('mongodb/mongo.git'): if len(matches) == 1 and matches[0].strip().endswith(f"{repo_name}.git"):
return True return True
print( print(
"The current directory's Git repository does not only contain the 'mongodb/mongo.git' remote URL." f"The current directory's Git repository contains not only the '{repo_name}.git' remote URL."
) )
return False return False
def push_branch_to_public_repo(mongodb_mongo_dir: str, repo_url: str, destination_branch_name: str, def push_branch_to_destination_repo(destination_repo_dir: str, copybara_config: CopybaraConfig,
branching_off_commit: str): branching_off_commit: str):
""" """
Pushes a new branch to the remote repository after ensuring it branches off the public repository. Pushes a new branch to the remote repository after ensuring it branches off the public repository.
Args: Args:
mongodb_mongo_dir (str): Path to the cloned 'mongodb-mongo' repository. destination_repo_dir (str): Path to the cloned destination repository.
repo_url (str): The URL of the remote repository where the new branch will be pushed. copybara_config (CopybaraConfig): Copybara configuration.
destination_branch_name (str): The name for the new branch to be pushed to the remote repository. branching_off_commit (str): The commit hash of the matching commit in the destination repository.
commit (str): The commit hash of the matching commit in the 'mongodb-mongo' repository.
Raises Raises
Exception: If the new branch is not branching off the public repository. Exception: If the new branch is not branching off the destination repository.
""" """
os.chdir(mongodb_mongo_dir) os.chdir(destination_repo_dir)
# Check the current repo is only mongodb/mongo repo. # Check the current repo has only destination repository remote.
if not is_only_mongodb_mongo_repo(): if not has_only_destination_repo_remote(copybara_config.destination.repo_name):
raise Exception("Not only mongodb repo") raise Exception(f"{destination_repo_dir} git repo has not only the destination repo remote")
# Confirm the top commit is matching the found commit before pushing # Confirm the top commit is matching the found commit before pushing
new_branch_top_commit = run_command("git log --pretty=format:\"%H\" -1") new_branch_top_commit = run_command('git log --pretty=format:"%H" -1')
if not new_branch_top_commit == branching_off_commit: if not new_branch_top_commit == branching_off_commit:
raise Exception( raise Exception(
"The new branch top commit does not match the branching_off_commit. Aborting push.") "The new branch top commit does not match the branching_off_commit. Aborting push.")
# Confirming whether the commit exists in the remote public repository (mongodb/mongo/master) to ensure we are not pushing anything that isn't already in the public repository. # Confirming whether the commit exists in the destination repository to ensure
# run_command will raise an exception if the commit is not found in the remote branch. # we are not pushing anything that isn't already in the destination repository.
# run_command will raise an exception if the commit is not found in the destination branch.
run_command(f"git branch -r --contains {new_branch_top_commit}") run_command(f"git branch -r --contains {new_branch_top_commit}")
# Push the new branch to the remote repository # Push the new branch to the destination repository
run_command(f"git push {repo_url} {destination_branch_name}") run_command(
f"git push {copybara_config.destination.git_url} {copybara_config.destination.branch}")
def create_branch_from_matching_commit(repo_url: str, source_branch_name: str, def create_branch_from_matching_commit(copybara_config: CopybaraConfig) -> None:
destination_branch_name: str) -> None:
""" """
Creates a new branch in the mongodb/mongo repository based on a matching commit found in 10gen/mongo/branches and mongodb/mongo/master. Create a new branch in the copybara destination repository based on a matching commit found in source repository and destination repository.
Args: Args:
repo_url (str): The URL of the remote repository where the new branch will be pushed. copybara_config (CopybaraConfig): Copybara configuration.
source_branch_name (str): The name of the branch in the '10gen-mongo' repository.
destination_branch_name (str): The name for the new branch to be created in the 'mongodb-mongo' repository.
""" """
# Save original dirtory # Save original dirtory
@ -277,33 +312,33 @@ def create_branch_from_matching_commit(repo_url: str, source_branch_name: str,
os.makedirs(working_dir, exist_ok=True) os.makedirs(working_dir, exist_ok=True)
os.chdir(working_dir) os.chdir(working_dir)
# Clone the specified branch of the 10gen/mongo and master of mongodb/mongo repo # Clone the specified branch of the source repository and master of destination repository
cloned_10gen_mongo_dir = os.path.join(working_dir, "10gen-mongo") cloned_source_repo_dir = os.path.join(working_dir, "source-repo")
cloned_mongodb_mongo_dir = os.path.join(working_dir, "mongodb-mongo") cloned_destination_repo_dir = os.path.join(working_dir, "destination-repo")
run_command(f"git clone -b {copybara_config.source.branch}"
f" {copybara_config.source.git_url} {cloned_source_repo_dir}")
run_command( run_command(
f"git clone -b {source_branch_name} git@github.com:10gen/mongo.git {cloned_10gen_mongo_dir}" f"git clone {copybara_config.destination.git_url} {cloned_destination_repo_dir}")
)
run_command(f"git clone git@github.com:mongodb/mongo.git {cloned_mongodb_mongo_dir}")
# Find matching commits to branching off # Find matching commits to branching off
commit = find_matching_commit(cloned_10gen_mongo_dir, cloned_mongodb_mongo_dir) commit = find_matching_commit(cloned_source_repo_dir, cloned_destination_repo_dir)
if commit is not None: if commit is not None:
# Delete the cloned_10gen_mongo_dir folder # Delete the cloned_source_repo_dir folder
shutil.rmtree(cloned_10gen_mongo_dir) shutil.rmtree(cloned_source_repo_dir)
if os.path.exists(cloned_10gen_mongo_dir): if os.path.exists(cloned_source_repo_dir):
raise Exception(cloned_10gen_mongo_dir + ": did not get removed") raise Exception(cloned_source_repo_dir + ": did not get removed")
# Once a matching commit is found, create a new branch based on it. # Once a matching commit is found, create a new branch based on it.
os.chdir(cloned_mongodb_mongo_dir) os.chdir(cloned_destination_repo_dir)
run_command(f"git checkout -b {destination_branch_name} {commit}") run_command(f"git checkout -b {copybara_config.destination.branch} {commit}")
# Push the new branch to the remote repository # Push the new branch to the remote repository
push_branch_to_public_repo(cloned_mongodb_mongo_dir, repo_url, destination_branch_name, push_branch_to_destination_repo(cloned_destination_repo_dir, copybara_config, commit)
commit)
else: else:
print( print(
f"Could not find matching commits between mongodb/mongo/master and 10gen/mongo/{destination_branch_name} to branching off" f"Could not find matching commits between {copybara_config.destination.repo_name}/master"
f" and {copybara_config.source.repo_name}/{copybara_config.source.branch} to branching off"
) )
sys.exit(1) sys.exit(1)
except Exception as err: except Exception as err:
@ -335,39 +370,65 @@ def main():
# Read configurations # Read configurations
expansions = read_config_file(args.expansions_file) expansions = read_config_file(args.expansions_file)
access_token_copybara_syncer = get_installation_access_token( token_mongodb_mongo = get_installation_access_token(
expansions["app_id_copybara_syncer"], expansions["private_key_copybara_syncer"], expansions["app_id_copybara_syncer"],
expansions["installation_id_copybara_syncer"]) expansions["private_key_copybara_syncer"],
expansions["installation_id_copybara_syncer"],
)
token_10gen_mongo = get_installation_access_token(
expansions["app_id_copybara_syncer_10gen"],
expansions["private_key_copybara_syncer_10gen"],
expansions["installation_id_copybara_syncer_10gen"],
)
tokens_map = {
"https://github.com/mongodb/mongo.git": token_mongodb_mongo,
"https://github.com/10gen/mongo.git": token_10gen_mongo,
}
# Create the mongodb-bot.gitconfig file as necessary. # Create the mongodb-bot.gitconfig file as necessary.
create_mongodb_bot_gitconfig() create_mongodb_bot_gitconfig()
current_dir = os.getcwd() current_dir = os.getcwd()
config_file = f"{current_dir}/copy.bara.sky" config_file = f"{current_dir}/copy.bara.sky"
git_destination_url_with_token = f"https://x-access-token:{access_token_copybara_syncer}@github.com/mongodb/mongo.git"
# create destination branch if not exists # Overwrite repo urls in copybara config in-place
copybara_branch_names = CopybaraBranchNames.from_copybara_sky_file(config_file) with fileinput.FileInput(config_file, inplace=True) as file:
if not copybara_branch_names.is_complete(): for line in file:
token = None
for repo, value in tokens_map.items():
if repo in line:
token = value
if token:
print(
line.replace(
"https://github.com",
f"https://x-access-token:{token}@github.com",
),
end="",
)
else:
print(line, end="")
copybara_config = CopybaraConfig.from_copybara_sky_file(config_file)
# Create destination branch if it does not exist
if not copybara_config.is_complete():
print("ERROR!!!") print("ERROR!!!")
print( print(
f"ERROR!!! Source or destination branch name could not be parsed from the {config_file}." f"ERROR!!! Source or destination configuration could not be parsed from the {config_file}."
) )
print("ERROR!!!") print("ERROR!!!")
sys.exit(1) sys.exit(1)
else: else:
if not check_destination_branch_exists(git_destination_url_with_token, if not check_destination_branch_exists(copybara_config):
copybara_branch_names.destination): create_branch_from_matching_commit(copybara_config)
create_branch_from_matching_commit(git_destination_url_with_token, print(f"New branch named '{copybara_config.destination.branch}' has been created"
copybara_branch_names.source, f" for the '{copybara_config.destination.repo_name}' repo")
copybara_branch_names.destination)
print(
f"New branch named {copybara_branch_names.destination} has been created for the mongodb/mongo repo"
)
else: else:
print( print(f"The branch named '{copybara_config.destination.branch}' already exists"
f"The branch named {copybara_branch_names.destination} already exists in the mongodb/mongo repo." f" in the '{copybara_config.destination.repo_name}' repo.")
)
# Set up the Docker command and execute it # Set up the Docker command and execute it
docker_cmd = [ docker_cmd = [
@ -377,7 +438,7 @@ def main():
f'-v "{config_file}":/usr/src/app/copy.bara.sky', f'-v "{config_file}":/usr/src/app/copy.bara.sky',
"-e COPYBARA_CONFIG='copy.bara.sky'", "-e COPYBARA_CONFIG='copy.bara.sky'",
"-e COPYBARA_SUBCOMMAND='migrate'", "-e COPYBARA_SUBCOMMAND='migrate'",
f"-e COPYBARA_OPTIONS='-v --git-destination-url={git_destination_url_with_token}'", "-e COPYBARA_OPTIONS='-v'",
"copybara copybara", "copybara copybara",
] ]

View File

@ -3,7 +3,6 @@ import os
import sys import sys
import tempfile import tempfile
import traceback import traceback
from unittest.mock import patch
from buildscripts import sync_repo_with_copybara from buildscripts import sync_repo_with_copybara
@ -126,17 +125,27 @@ class TestBranchFunctions(unittest.TestCase):
def test_branch_exists(self): def test_branch_exists(self):
"""Perform a test to check that the branch exists in a repository.""" """Perform a test to check that the branch exists in a repository."""
test_name = "branch_exists_test" test_name = "branch_exists_test"
repo_url = "git@github.com:mongodb/mongo.git" copybara_config = sync_repo_with_copybara.CopybaraConfig(
branch_name = "v7.3" source=None,
result = sync_repo_with_copybara.check_destination_branch_exists(repo_url, branch_name) destination=sync_repo_with_copybara.CopybaraRepoConfig(
git_url="https://github.com/mongodb/mongo.git",
branch="v7.3",
),
)
result = sync_repo_with_copybara.check_destination_branch_exists(copybara_config)
self.assertTrue(result, f"{test_name}: SUCCESS!") self.assertTrue(result, f"{test_name}: SUCCESS!")
def test_branch_not_exists(self): def test_branch_not_exists(self):
"""Perform a test to check that the branch does not exists in a repository.""" """Perform a test to check that the branch does not exist in a repository."""
test_name = "branch_not_exists_test" test_name = "branch_not_exists_test"
repo_url = "git@github.com:mongodb/mongo.git" copybara_config = sync_repo_with_copybara.CopybaraConfig(
branch_name = "v7.3test" source=None,
result = sync_repo_with_copybara.check_destination_branch_exists(repo_url, branch_name) destination=sync_repo_with_copybara.CopybaraRepoConfig(
git_url="https://github.com/mongodb/mongo.git",
branch="..invalid-therefore-impossible-to-create-branch-name",
),
)
result = sync_repo_with_copybara.check_destination_branch_exists(copybara_config)
self.assertFalse(result, f"{test_name}: SUCCESS!") self.assertFalse(result, f"{test_name}: SUCCESS!")
def test_only_mongodb_mongo_repo(self): def test_only_mongodb_mongo_repo(self):
@ -155,7 +164,7 @@ class TestBranchFunctions(unittest.TestCase):
try: try:
# Check if the repository is only the MongoDB official repository # Check if the repository is only the MongoDB official repository
result = sync_repo_with_copybara.is_only_mongodb_mongo_repo() result = sync_repo_with_copybara.has_only_destination_repo_remote("mongodb/mongo")
except Exception as err: except Exception as err:
print(f"{test_name}: FAIL!\n Exception occurred: {err}\n {traceback.format_exc()}") print(f"{test_name}: FAIL!\n Exception occurred: {err}\n {traceback.format_exc()}")
self.fail(f"{test_name}: FAIL!") self.fail(f"{test_name}: FAIL!")
@ -180,11 +189,25 @@ class TestBranchFunctions(unittest.TestCase):
try: try:
# Call function to push branch to public repository, expecting an exception # Call function to push branch to public repository, expecting an exception
sync_repo_with_copybara.push_branch_to_public_repo(mongodb_mongo_dir, repo_url='', sync_repo_with_copybara.push_branch_to_destination_repo(
destination_branch_name='', mongodb_mongo_dir,
branching_off_commit='') copybara_config=sync_repo_with_copybara.CopybaraConfig(
source=sync_repo_with_copybara.CopybaraRepoConfig(
git_url="",
repo_name="",
branch="",
),
destination=sync_repo_with_copybara.CopybaraRepoConfig(
git_url="",
repo_name="",
branch="",
),
),
branching_off_commit="",
)
except Exception as err: except Exception as err:
if str(err) == "Not only mongodb repo": if (str(err) ==
f"{mongodb_mongo_dir} git repo has not only the destination repo remote"):
return return
self.fail(f"{test_name}: FAIL!") self.fail(f"{test_name}: FAIL!")
@ -211,8 +234,22 @@ class TestBranchFunctions(unittest.TestCase):
self.create_mock_repo_commits(mongodb_mongo_dir, 2) self.create_mock_repo_commits(mongodb_mongo_dir, 2)
try: try:
# Call function to push branch to public repository, expecting an exception # Call function to push branch to public repository, expecting an exception
sync_repo_with_copybara.push_branch_to_public_repo(mongodb_mongo_dir, '', '', sync_repo_with_copybara.push_branch_to_destination_repo(
invalid_branching_off_commit) mongodb_mongo_dir,
sync_repo_with_copybara.CopybaraConfig(
source=sync_repo_with_copybara.CopybaraRepoConfig(
git_url="",
repo_name="",
branch="",
),
destination=sync_repo_with_copybara.CopybaraRepoConfig(
git_url="",
repo_name="",
branch="",
),
),
invalid_branching_off_commit,
)
except Exception as err: except Exception as err:
if str( if str(
err err

View File

@ -5,8 +5,8 @@
# sourceUrl = "/path/to/source" # sourceUrl = "/path/to/source"
# destinationUrl = "/path/to/dest" # destinationUrl = "/path/to/dest"
sourceUrl = "git@github.com:10gen/mongo.git" sourceUrl = "https://github.com/10gen/mongo.git"
destinationUrl = "git@github.com:mongodb/mongo.git" destinationUrl = "https://github.com/mongodb/mongo.git"
core.workflow( core.workflow(
name = "default", name = "default",
@ -26,7 +26,7 @@ core.workflow(
# Change the path here to the folder you want to publish publicly # Change the path here to the folder you want to publish publicly
transformations = [ transformations = [
# (^.*?) - matches the first line (without the newline char) # (^.*?) - matches the first line (without the newline char)
# \n - matches the first newline (or nothing at all if there is no newline). If there is no match then nopthing happens # \n - matches the first newline (or nothing at all if there is no newline). If there is no match then nothing happens
# ((\n|.)*) - matches everything after # ((\n|.)*) - matches everything after
# Overall, this copies only the first line of the commit rather than the body # Overall, this copies only the first line of the commit rather than the body
metadata.scrubber("(^.*?)\n((\n|.)*)", replacement = "$1"), metadata.scrubber("(^.*?)\n((\n|.)*)", replacement = "$1"),

View File

@ -1,14 +1,13 @@
# This configuration is for migrating code from one Git repository to another using Copybara. # This configuration is for migrating code from one Git repository to another using Copybara.
# It selectively copies content, excluding specific paths and preserving authorship. # It selectively copies content, excluding specific paths and preserving authorship.
sourceUrl = "git@github.com:10gen/mongo.git" sourceUrl = "https://github.com/10gen/mongo.git"
destinationUrl = "git@github.com:10gen/mongo-copybara.git" destinationUrl = "https://github.com/10gen/mongo-copybara.git"
core.workflow( core.workflow(
name = "default", name = "default",
origin = git.origin( origin = git.origin(
url = sourceUrl, url = sourceUrl,
ref = "v8.0", ref = "v8.0",
# VersionSelector
), ),
destination = git.destination( destination = git.destination(
url = destinationUrl, url = destinationUrl,
@ -20,7 +19,11 @@ core.workflow(
authoring = authoring.pass_thru("MongoDB <mongodb@mongodb.com>"), authoring = authoring.pass_thru("MongoDB <mongodb@mongodb.com>"),
mode = "ITERATIVE", mode = "ITERATIVE",
# Change the path here to the folder you want to publish publicly # Change the path here to the folder you want to publish publicly
# transformations = [ transformations = [
# core.move("path/to/folder/you/want/exported", ""), # (^.*?) - matches the first line (without the newline char)
# ], # \n - matches the first newline (or nothing at all if there is no newline). If there is no match then nothing happens
# ((\n|.)*) - matches everything after
# Overall, this copies only the first line of the commit rather than the body
metadata.scrubber("(^.*?)\n((\n|.)*)", replacement = "$1"),
],
) )

View File

@ -1214,6 +1214,7 @@ tasks:
- name: sync_repo_with_copybara - name: sync_repo_with_copybara
tags: ["assigned_to_jira_team_devprod_correctness", "experimental"] tags: ["assigned_to_jira_team_devprod_correctness", "experimental"]
patchable: false
commands: commands:
- command: manifest.load - command: manifest.load
- func: "git get project and add git tag" - func: "git get project and add git tag"