Skip to content

Commit a8ed6ae

Browse files
authored
Add pre-commit hook for including the MPLv2 in all source code files (#10617)
* 10614: Add pre-commit hook for including the MPLv2 Adds to Python, JS, SCSS, Jinja HTML, Fluent templates and shell scripts Note that the order of application of the hooks is important - we want to add a missing license before we check the formatting of files * 10614: Update MPLv2 comments on all templates to match standard format produced by pre-commit hook * Updates existing MPLv2 text to use a https URL * Amend a handful of Fluent templates that used a token instead of the string "Mozilla" - this standardised things; translation was not used or needed * Add missing MPLv2 where needed * Update three tests that regressed with these changes, above * 10614: Update pre-commit config to not add MPL to JS libraries; Remove MPL from the four files which should not have had it
1 parent d8389a1 commit a8ed6ae

File tree

1,614 files changed

+5166
-2279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,614 files changed

+5166
-2279
lines changed

.eslintrc.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
*/
6+
17
module.exports = {
28
env: {
39
browser: true,

.pre-commit-config.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,52 @@ exclude: >
1111
| lib/fluent_migrations
1212
)
1313
repos:
14+
# Note: hooks that add content must run before ones which check formatting, lint, etc
15+
- repo: https://github.com/Lucas-C/pre-commit-hooks
16+
rev: v1.1.10
17+
hooks:
18+
- id: insert-license
19+
language: python
20+
files: \.py$
21+
args:
22+
- --license-filepath
23+
- license_header/mpl2_header.txt
24+
- --comment-style
25+
- "|#|"
26+
- id: insert-license
27+
exclude: media\/.*\/libs\/.*$
28+
files: \.js$
29+
args:
30+
- --license-filepath
31+
- license_header/mpl2_header.txt
32+
- --comment-style
33+
- /*|*|*/
34+
- id: insert-license
35+
files: \.scss$
36+
args:
37+
- --license-filepath
38+
- license_header/mpl2_header.txt
39+
- --comment-style
40+
- //
41+
- id: insert-license
42+
files: \.sh$
43+
args:
44+
- --license-filepath
45+
- license_header/mpl2_header.txt
46+
- id: insert-license
47+
files: \.html$ # jinja2
48+
args:
49+
- --license-filepath
50+
- license_header/mpl2_header.txt
51+
- --comment-style
52+
- '{#||#}'
53+
- id: insert-license
54+
files: \.ftl$ # fluent templates
55+
args:
56+
- --license-filepath
57+
- license_header/mpl2_header.txt
58+
- --comment-style
59+
- "|#|"
1460
- repo: https://github.com/psf/black
1561
rev: 21.9b0
1662
hooks:

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ Exhibit A - Source Code Form License Notice
357357

358358
This Source Code Form is subject to the terms of the Mozilla Public
359359
License, v. 2.0. If a copy of the MPL was not distributed with this
360-
file, You can obtain one at http://mozilla.org/MPL/2.0/.
360+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
361361

362362
If it is not possible or desirable to put the notice in a particular
363363
file, then You may include the notice in a location (such as a LICENSE

bedrock/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

bedrock/base/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

bedrock/base/cache.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
15
from django.core.cache.backends.locmem import DEFAULT_TIMEOUT, LocMemCache
26

37

bedrock/base/config_manager.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
15
from everett.manager import ConfigEnvFileEnv, ConfigManager, ConfigOSEnv
26

37
config = ConfigManager(

bedrock/base/context_processors.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
15
from django.conf import settings
26

37
from bedrock.base.geo import get_country_from_request

bedrock/base/geo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This Source Code Form is subject to the terms of the Mozilla Public
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55
from django.conf import settings
66

bedrock/base/log_settings.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
15
import logging
26
import logging.handlers
37
import socket

bedrock/base/management/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

bedrock/base/management/commands/update_www_config.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
15
import os
26

37
from django.conf import settings

bedrock/base/middleware.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
15
"""
26
Taken from zamboni.amo.middleware.
37

bedrock/base/migrations/0001_initial.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# -*- coding: utf-8 -*-
22

3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this
5+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
6+
37
from django.db import migrations, models
48

59

bedrock/base/migrations/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

bedrock/base/models.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
15
from django.db import models
26

37

bedrock/base/templates/404.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% extends "base-error.html" %}
68

bedrock/base/templates/500.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% extends "base-error.html" %}
68

bedrock/base/templates/base-article.html

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
6+
17
{% from "macros-protocol.html" import sidemenu_lists with context %}
28

39
{% extends 'base-protocol-mozilla.html' %}

bedrock/base/templates/base-error.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% extends 'base-protocol-mozilla.html' %}
68

bedrock/base/templates/base-protocol-mozilla.html

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
6+
17
{% extends 'base-protocol.html' %}
28

39
{% block body_class %}mzp-t-mozilla{% endblock %}

bedrock/base/templates/base-protocol.html

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
6+
17
{% set_lang_files "main" %}
28
<!doctype html>
39
{# Note the "windows" class, without javascript platform-specific assets default to windows #}

bedrock/base/templates/cron-health-check.html

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
6+
17
<!doctype html>
28
<html lang="en">
39
<head>

bedrock/base/templates/includes/banners/base.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
<aside class="c-banner hide-from-legacy-ie {% block banner_class %}{% endblock %}" id="{% block banner_id %}{% endblock %}">
68
{# Exclude banners from search result snippets using `data-nosnippet` (issue 8739) #}

bedrock/base/templates/includes/banners/fundraiser.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% extends 'includes/banners/base.html' %}
68

bedrock/base/templates/includes/banners/mobile/firefox-app-store.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% set android_url = firefox_adjust_url('android', 'app-store-banner') %}
68
{% set ios_url = firefox_adjust_url('ios', 'app-store-banner') %}

bedrock/base/templates/includes/banners/mobile/focus-app-store.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% set android_url = focus_adjust_url('android', 'app-store-banner') %}
68
{% set ios_url = focus_adjust_url('ios', 'app-store-banner') %}

bedrock/base/templates/includes/banners/mobile/mobile-compare.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
<aside class="c-banner hide-from-legacy-ie mzp-t-dark" id="mobile-compare-banner">
68
{# Exclude banners from search result snippets using `data-nosnippet` (issue 8739) #}

bedrock/base/templates/includes/banners/mr1/eu-banner.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% from "macros.html" import google_play_button with context %}
68

bedrock/base/templates/includes/canonical-url.html

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
6+
17
<link rel="canonical" href="{{ settings.CANONICAL_URL + '/' + LANG + canonical_path }}">
28
<link rel="alternate" hreflang="x-default" href="{{ settings.CANONICAL_URL }}{{ canonical_path }}">
39
{% if translations -%}

bedrock/base/templates/includes/careers-teaser.html

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
6+
17
_.-~-.
28
7'' Q..\
39
_7 (_

bedrock/base/templates/includes/google-analytics.html

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
6+
17
<!--
28
Read more about our custom configuration and use of Google Analytics here:
39
https://bugzilla.mozilla.org/show_bug.cgi?id=1122305#c8

bedrock/base/templates/includes/protocol/footer/footer.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% set utm_params = 'utm_source=www.mozilla.org&utm_medium=referral&utm_campaign=footer' %}
68

bedrock/base/templates/includes/protocol/lang-switcher.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% if translations|length > 1 %}
68
<form id="lang_form" class="mzp-c-language-switcher" method="get" action="#">

bedrock/base/templates/includes/protocol/navigation/menus/firefox.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% set utm_params = 'utm_source=www.mozilla.org&utm_medium=referral&utm_campaign=nav&utm_content=firefox' %}
68

bedrock/base/templates/includes/protocol/navigation/menus/innovation.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#}
1+
{#
2+
This Source Code Form is subject to the terms of the Mozilla Public
3+
License, v. 2.0. If a copy of the MPL was not distributed with this
4+
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
#}
46

57
{% set utm_params = 'utm_source=www.mozilla.org&utm_medium=referral&utm_campaign=nav&utm_content=innovation' %}
68

0 commit comments

Comments
 (0)