def test_is_label_on_pr(self, mock_util, repo, gh_api):
        self.init_github()
        mock_util.add_issue_response(self._get_expected_issue(1))
        mock_util.add_issue_response(self._get_expected_issue(2))
        mock_util.mock_issue_labels(1, responses.GET, ["Octocat", "bogus 1", "bogus 2"])
        mock_util.mock_issue_labels(2, responses.GET, ["bogus 1", "bogus 2"])

        pull_request = ShortPullRequest(self._get_expected_pull_request(1, 1), gh_api)
        pull_request.number = 1
        assert is_label_on_pull_request(repo, pull_request, "Octocat")
        pull_request.number = 2
        assert not is_label_on_pull_request(repo, pull_request, "Octocat")
Example #2
0
    def _handle_branch_name_option(self, generator, branch_name):
        if "__" not in branch_name:
            self.logger.info(
                "Branch {} is not a child branch. Exiting...".format(
                    branch_name))
            return

        parent_branch_name = branch_name.split("__")[0]
        parent_pull_request = self._get_parent_pull_request(parent_branch_name)
        if is_label_on_pull_request(self.repo, parent_pull_request,
                                    self.build_notes_label):
            generator.aggregate_child_change_notes(parent_pull_request)
        else:
            generator.update_unaggregated_pr_header(parent_pull_request,
                                                    branch_name)
Example #3
0
    def _run_task(self):
        self._setup_self()

        if self.force_rebuild_change_notes:
            pull_request = self._get_parent_pull_request()
            if pull_request:
                self.generator.aggregate_child_change_notes(pull_request)

        elif self._has_parent_branch() and self._commit_is_merge():
            parent_pull_request = self._get_parent_pull_request()
            if parent_pull_request:
                if is_label_on_pull_request(
                    self.repo,
                    parent_pull_request,
                    self.options.get("build_notes_label"),
                ):
                    self.generator.aggregate_child_change_notes(parent_pull_request)
                else:
                    child_branch_name = self._get_child_branch_name_from_merge_commit()
                    if child_branch_name:
                        self._update_unaggregated_pr_header(
                            parent_pull_request, child_branch_name
                        )