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


from taskgraph.target_tasks import _target_task, filter_for_tasks_for


@_target_task('default')
def target_tasks_default(full_task_graph, parameters, graph_config):
    """Target the tasks which have indicated they should be run on this project
    via the `run_on_projects` attributes."""

    # Temporary until we have official beta support
    def releases(task, parameters):
        return task.attributes.get("release-type", "") == 'release'

    _filter = filter_for_tasks_for

    if parameters["tasks_for"] == "github-release":
        _filter = releases

    return [l for l, t in full_task_graph.tasks.items() if _filter(t, parameters)]


@_target_task('release')
def target_tasks_default(full_task_graph, parameters, graph_config):

    # TODO Use shipping-phase once we retire github-releases
    def filter(task, parameters):
        # Mark-as-shipped is always red on github-release and it confuses people.
        # This task cannot be green if we kick off a release through github-releases, so
        # let's exlude that task there.
        if task.kind == "mark-as-shipped" and parameters["tasks_for"] == "github-release":
            return False

        return task.attributes.get("release-type", "") == parameters["release_type"]

    return [l for l, t in full_task_graph.tasks.items() if filter(t, parameters)]


@_target_task('nightly')
def target_tasks_nightly(full_task_graph, parameters, graph_config):
    """Select the set of tasks required for a nightly build."""

    def filter(task):
        return task.attributes.get("nightly-task", False)

    return [l for l, t in full_task_graph.tasks.items() if filter(t)]
@@ -482,24 +482,60 @@
 ibutes.%22%22%22%0A%0A
+    _filter = filter_for_tasks_for%0A%0A
     # Tempor
@@ -551,34 +551,43 @@
  we 
-have official beta support
+move to shipit for release and beta
 %0A   
@@ -598,17 +598,16 @@
  release
-s
 (task, p
@@ -695,807 +695,251 @@
     
-_filter = filter_for_tasks_for%0A%0A    if parameters%5B%22tasks_for%22%5D == %22github-release%22:%0A        _filter = releases%0A%0A    return %5Bl for l, t in full_task_graph.tasks.items() if _filter(t, parameters)%5D%0A%0A%0A@_target_task('release')%0Adef target_tasks_default(full_task_graph, parameters, graph_config):%0A%0A    # TODO Use shipping-phase once we retire github-releases%0A    def filter(task, parameters):%0A        # Mark-as-shipped is always red on github-release and it confuses people.%0A        # This task cannot be green if we kick off a release through github-releases, so%0A        # let's exlude that task there.%0A        if task.kind == %22mark-as-shipped%22 and parameters%5B%22tasks_for%22%5D == %22github-release%22:%0A            return False%0A%0A        return task.attributes.get(%22release-type%22, %22%22) == parameters%5B%22release_type%22%5D
+def beta(task, parameters):%0A        return task.attributes.get(%22release-type%22, %22%22) == 'beta'%0A%0A    if parameters%5B%22tasks_for%22%5D == %22github-release%22:%0A        _filter = release%0A        if 'beta' in parameters%5B%22head_tag%22%5D:%0A            _filter = beta
 %0A%0A  
@@ -987,32 +987,33 @@
 asks.items() if 
+_
 filter(t, parame

Modify target_task default to support beta releases