<filename>server/tasks/_commit_message.py<gh_stars>10-100
# Copyright 2017, Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Contains a function which builds a detailed commit message."""

from datetime import date


def build(added, deleted, updated, subject=None):
    """Returns a detailed commit message.

    Args:
        added (set): a set of API IDs that have been added.
        deleted (set): a set of API IDs that have been deleted.
        updated (set): a set of API IDs that have been updated.
        subject (str, optional): if provided, replaces the default subject.

    Returns:
        str: a commit message.
    """
    commitmsg = ''
    if subject:
        commitmsg = '{}\n'.format(subject)
    else:
        today = date.today().isoformat()
        commitmsg = 'Autogenerated update ({})\n'.format(today)
    if added:
        commitmsg += '\nAdd:\n'
        for id_ in sorted(added):
            commitmsg += '- {}\n'.format(id_)
    if deleted:
        commitmsg += '\nDelete:\n'
        for id_ in sorted(deleted):
            commitmsg += '- {}\n'.format(id_)
    if updated:
        commitmsg += '\nUpdate:\n'
        for id_ in sorted(updated):
            commitmsg += '- {}\n'.format(id_)
    return commitmsg.rstrip()

<filename>server/tasks/_commit_message.py<gh_stars>10-100
# Copyright 2017, Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Contains a function which builds a detailed commit message."""

from datetime import date


def build(added, deleted, updated, subject=None):
    """Returns a detailed commit message.

    Args:
        added (set): a set of API IDs that have been added.
        deleted (set): a set of API IDs that have been deleted.
        updated (set): a set of API IDs that have been updated.
        subject (str, optional): if provided, replaces the default subject.

    Returns:
        str: a commit message.
    """
    commitmsg = ''
    if subject:
        commitmsg = '{}\n'.format(subject)
    else:
        today = date.today().isoformat()
        commitmsg = 'Autogenerated update ({})\n'.format(today)
    if added:
        commitmsg += '\nAdd:\n'
        for id_ in sorted(added):
            commitmsg += '- {}\n'.format(id_)
    if deleted:
        commitmsg += '\nDelete:\n'
        for id_ in sorted(deleted):
            commitmsg += '- {}\n'.format(id_)
    if updated:
        commitmsg += '\nUpdate:\n'
        for id_ in sorted(updated):
            commitmsg += '- {}\n'.format(id_)
    return commitmsg.rstrip()

# Copyright 2017, Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #     http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. Contains a function which builds a detailed commit message. Returns a detailed commit message.      Args:         added (set): a set of API IDs that have been added.         deleted (set): a set of API IDs that have been deleted.         updated (set): a set of API IDs that have been updated.         subject (str, optional): if provided, replaces the default subject.      Returns:         str: a commit message.