<commit_before>/*
 * Copyright 2019 Netflix, Inc.
 *
 * 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.
 */
package com.netflix.spinnaker.gradle.dependency

import org.ajoberstar.grgit.Credentials
import org.ajoberstar.grgit.Grgit
import org.eclipse.egit.github.core.PullRequest
import org.eclipse.egit.github.core.PullRequestMarker
import org.eclipse.egit.github.core.Repository
import org.eclipse.egit.github.core.User
import org.eclipse.egit.github.core.client.GitHubClient
import org.eclipse.egit.github.core.client.GitHubRequest
import org.eclipse.egit.github.core.client.GitHubResponse
import org.eclipse.egit.github.core.service.PullRequestService
import org.eclipse.egit.github.core.service.RepositoryService
import org.eclipse.egit.github.core.service.UserService
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction

class BumpDependencies extends DefaultTask {

  private static final String COMMIT_BODY = '''\
    This is an automated PR!
    
    You can merge all of these PRs from the `%s` project using the command below and a Github access token.
    Generate a GH token from https://github.com/settings/tokens, and run the following:
    
    ```
    GITHUB_ACCESS_TOKEN=
    ./gradlew mergeAllAutoBumpPRs -Pgithub.token=$GITHUB_ACCESS_TOKEN
    ```
    
    If something has gone wrong, and you don't want to manually close all of the autobump PRs, you can
    close all open PRs with the 'autobump' label using this command:
    
    ```
    GITHUB_ACCESS_TOKEN=
    ./gradlew closeAllAutoBumpPRs -Pgithub.token=$GITHUB_ACCESS_TOKEN
    ```
    '''.stripIndent()

  @TaskAction
  void bumpDependencies() {
    GitHubClient client = new GitHubClient()
    String accessToken = project.property('github.token')
    client.setOAuth2Token(accessToken)

    UserService userSvc = new UserService(client)
    User user = userSvc.getUser()

    DependencyBumpExtension extension = project.extensions.findByType(DependencyBumpExtension)

    String reviewer<commit_msg>fix(autobump): Adds `-PenablePublishing=true` to merge and close commands (#83)<commit_after>/*
 * Copyright 2019 Netflix, Inc.
 *
 * 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.
 */
package com.netflix.spinnaker.gradle.dependency

import org.ajoberstar.grgit.Credentials
import org.ajoberstar.grgit.Grgit
import org.eclipse.egit.github.core.PullRequest
import org.eclipse.egit.github.core.PullRequestMarker
import org.eclipse.egit.github.core.Repository
import org.eclipse.egit.github.core.User
import org.eclipse.egit.github.core.client.GitHubClient
import org.eclipse.egit.github.core.client.GitHubRequest
import org.eclipse.egit.github.core.client.GitHubResponse
import org.eclipse.egit.github.core.service.PullRequestService
import org.eclipse.egit.github.core.service.RepositoryService
import org.eclipse.egit.github.core.service.UserService
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction

class BumpDependencies extends DefaultTask {

  private static final String COMMIT_BODY = '''\
    This is an automated PR!
    
    You can merge all of these PRs from the `%s` project using the command below and a Github access token.
    Generate a GH token from https://github.com/settings/tokens, and run the following:
    
    ```
    GITHUB_ACCESS_TOKEN=
    ./gradlew mergeAllAutoBumpPRs -Pgithub.token=$GITHUB_ACCESS_TOKEN -PenablePublishing=true
    ```
    
    If something has gone wrong, and you don't want to manually close all of the autobump PRs, you can
    close all open PRs with the 'autobump' label using this command:
    
    ```
    GITHUB_ACCESS_TOKEN=
    ./gradlew closeAllAutoBumpPRs -Pgithub.token=$GITHUB_ACCESS_TOKEN -PenablePublishing=true
    ```
    '''.stripIndent()

  @TaskAction
  void bumpDependencies() {
    GitHubClient client = new GitHubClient()
    String accessToken = project.property('github.token')
    client.setOAuth2Token(accessToken)

    UserService userSvc = new UserService(client)
    User user = userSvc.getUser()

    DependencyBumpExtension extension = project.extensions.findByType(DependencyBumpExtension)

    String reviewer
{'fraction_non_alphanumeric': 0.08278016399843811, 'fraction_numerical': 0.003904724716907458, 'mean_word_length': 4.164314516129032, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4269963', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1455, 'n_words': 447}