Skip to content

Commit

Permalink
Ensure all uses of git specify a branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
pmac committed Apr 15, 2022
1 parent c92de71 commit 8464dcc
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bedrock/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_template_names(self):


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,
Expand Down
5 changes: 4 additions & 1 deletion bedrock/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,14 @@ def data_path(*args):
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)
Expand Down Expand Up @@ -464,6 +466,7 @@ def lazy_langs():
}

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.
Expand Down Expand Up @@ -1081,7 +1084,7 @@ def get_app_name(hostname):

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")
Expand Down
2 changes: 1 addition & 1 deletion bedrock/sitemaps/management/commands/fetch_sitemaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def handle(self, *args, **options):
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("*.*"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def handle(self, *args, **options):
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()):
Expand Down
2 changes: 1 addition & 1 deletion bedrock/utils/tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions bin/open-ftl-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/l10n_utils/management/commands/_ftl_repo_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def handle(self, *args, **options):
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:
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n_utils/management/commands/l10n_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def handle(self, *args, **options):
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:
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n_utils/management/commands/open_ftl_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def open_pr(self):
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}")

0 comments on commit 8464dcc

Please sign in to comment.