Ensure all uses of git specify a branch name

This commit is contained in:
Paul McLanahan 2022-04-15 14:25:02 -04:00 коммит произвёл Paul McLanahan
Родитель c92de71516
Коммит 8464dcc4dd
9 изменённых файлов: 13 добавлений и 9 удалений

Просмотреть файл

@ -56,7 +56,7 @@ S3_BASE_URL = f"https://s3-{REGION_NAME}.amazonaws.com/{BUCKET_NAME}"
def get_l10n_repo_info():
fluent_repo = git.GitRepo(settings.FLUENT_REPO_PATH, settings.FLUENT_REPO_URL)
fluent_repo = git.GitRepo(settings.FLUENT_REPO_PATH, settings.FLUENT_REPO_URL, settings.FLUENT_REPO_BRANCH)
data = {
"latest_ref": fluent_repo.current_hash,
"last_updated": fluent_repo.last_updated,

Просмотреть файл

@ -256,12 +256,14 @@ FLUENT_DEFAULT_FILES = [
FLUENT_DEFAULT_PERCENT_REQUIRED = config("FLUENT_DEFAULT_PERCENT_REQUIRED", default="80", parser=int)
FLUENT_REPO = config("FLUENT_REPO", default="mozmeao/www-l10n")
FLUENT_REPO_URL = f"https://github.com/{FLUENT_REPO}"
FLUENT_REPO_BRANCH = config("FLUENT_REPO_BRANCH", default="master")
FLUENT_REPO_PATH = DATA_PATH / "www-l10n"
# will be something like "<github username>:<github token>"
FLUENT_REPO_AUTH = config("FLUENT_REPO_AUTH", default="")
FLUENT_LOCAL_PATH = ROOT_PATH / "l10n"
FLUENT_L10N_TEAM_REPO = config("FLUENT_L10N_TEAM_REPO", default="mozilla-l10n/www-l10n")
FLUENT_L10N_TEAM_REPO_URL = f"https://github.com/{FLUENT_L10N_TEAM_REPO}"
FLUENT_L10N_TEAM_REPO_BRANCH = config("FLUENT_L10N_TEAM_REPO_BRANCH", default="master")
FLUENT_L10N_TEAM_REPO_PATH = DATA_PATH / "l10n-team"
# 10 seconds during dev and 10 min in prod
FLUENT_CACHE_TIMEOUT = config("FLUENT_CACHE_TIMEOUT", default="10" if DEBUG else "600", parser=int)
@ -464,6 +466,7 @@ EXTRA_INDEX_URLS = {
}
SITEMAPS_REPO = config("SITEMAPS_REPO", default="https://github.com/mozmeao/www-sitemap-generator.git")
SITEMAPS_REPO_BRANCH = config("SITEMAPS_REPO_BRANCH", default="master")
SITEMAPS_PATH = DATA_PATH / "sitemaps"
# Pages that have different URLs for different locales, e.g.
@ -1081,7 +1084,7 @@ RELEASE_NOTES_BRANCH = config("RELEASE_NOTES_BRANCH", default="master")
WWW_CONFIG_PATH = config("WWW_CONFIG_PATH", default=data_path("www_config"))
WWW_CONFIG_REPO = config("WWW_CONFIG_REPO", default="https://github.com/mozmeao/www-config.git")
WWW_CONFIG_BRANCH = config("WWW_CONFIG_BRANCH", default="master")
WWW_CONFIG_BRANCH = config("WWW_CONFIG_BRANCH", default="main")
LEGAL_DOCS_PATH = DATA_PATH / "legal_docs"
LEGAL_DOCS_REPO = config("LEGAL_DOCS_REPO", default="https://github.com/mozilla/legal-docs.git")

Просмотреть файл

@ -22,7 +22,7 @@ class Command(BaseCommand):
self.stdout._out = StringIO()
data_path = settings.SITEMAPS_PATH.joinpath("data")
repo = GitRepo(settings.SITEMAPS_PATH, settings.SITEMAPS_REPO)
repo = GitRepo(settings.SITEMAPS_PATH, settings.SITEMAPS_REPO, settings.SITEMAPS_REPO_BRANCH)
repo.update()
for src_path in data_path.rglob("*.*"):

Просмотреть файл

@ -23,7 +23,7 @@ class Command(BaseCommand):
if options["quiet"]:
self.stdout._out = StringIO()
repo = GitRepo(settings.SITEMAPS_PATH, settings.SITEMAPS_REPO, name="Sitemaps")
repo = GitRepo(settings.SITEMAPS_PATH, settings.SITEMAPS_REPO, settings.SITEMAPS_REPO_BRANCH, name="Sitemaps")
self.stdout.write("Updating git repo")
repo.update()
if not (options["force"] or repo.has_changes()):

Просмотреть файл

@ -79,7 +79,7 @@ def test_git_clone():
g.clone()
git_mock["path"].mkdir.assert_called_with(parents=True, exist_ok=True)
git_mock["git"].assert_called_with("clone", "--depth", "1", "--branch", "master", "https://example.com", ".")
git_mock["git"].assert_called_with("clone", "--depth", "1", "--branch", "main", "https://example.com", ".")
@patch.object(git, "rmtree")

Просмотреть файл

@ -17,5 +17,6 @@ source docker/bin/set_git_env_vars.sh
docker run --rm \
-e FLUENT_REPO_AUTH \
-e FLUENT_L10N_TEAM_REPO \
-e FLUENT_L10N_TEAM_REPO_BRANCH \
"$DEPLOYMENT_DOCKER_IMAGE" \
python manage.py open_ftl_pr

Просмотреть файл

@ -24,8 +24,8 @@ class FTLRepoCommand(BaseCommand):
if options["quiet"]:
self.stdout._out = StringIO()
self.l10n_repo = GitRepo(settings.FLUENT_L10N_TEAM_REPO_PATH, settings.FLUENT_L10N_TEAM_REPO_URL)
self.meao_repo = GitRepo(settings.FLUENT_REPO_PATH, settings.FLUENT_REPO_URL)
self.l10n_repo = GitRepo(settings.FLUENT_L10N_TEAM_REPO_PATH, settings.FLUENT_L10N_TEAM_REPO_URL, settings.FLUENT_L10N_TEAM_REPO_BRANCH)
self.meao_repo = GitRepo(settings.FLUENT_REPO_PATH, settings.FLUENT_REPO_URL, settings.FLUENT_REPO_BRANCH)
def update_l10n_team_files(self):
try:

Просмотреть файл

@ -25,7 +25,7 @@ class Command(BaseCommand):
self.update_fluent_files(options["clean"])
def update_fluent_files(self, clean=False):
repo = GitRepo(settings.FLUENT_REPO_PATH, settings.FLUENT_REPO_URL)
repo = GitRepo(settings.FLUENT_REPO_PATH, settings.FLUENT_REPO_URL, settings.FLUENT_REPO_BRANCH)
if clean:
repo.reclone()
else:

Просмотреть файл

@ -129,7 +129,7 @@ class Command(FTLRepoCommand):
pr = self.github.create_pull(
title=title,
body=body,
base="master",
base=self.l10n_repo.branch_name,
head=self.branch_name,
)
self.stdout.write(f"Opened a pull-request: {pr.html_url}")