Git Product home page Git Product logo

github-repo-automation's Introduction

Google Inc. logo

GitHub Repo Automation

A set of tools to automate multiple GitHub repository management.

This is not an officially supported Google product.

As we publish Node.js client libraries to multiple repositories under googleapis, we need a set of small tools to perform management of those repositories, such as updating continuous integration setup, updating dependencies, and so on.

This repository contains some scripts that may be useful for this kind of tasks.

Installation

Googlers: You should install this tool on your laptop or workstation, as folks have run into timeout issues when using a Google Cloud Compute Engine instance.

If you're not familiar with Node.js development you can still use the tools included as they don't require writing any Javascript code. Before running the scripts, make sure you have Node.js version 8+ installed (e.g. from here) and available in your PATH, and install the required dependencies:

$ npm install -g @google/repo

You need to make your own config.yaml and put your GitHub token there. Example:

baseUrl: https://git.mycompany.com/api/v3 # optional, if you are using GitHub Enterprise
githubToken: your-github-token
clonePath: /User/my-user/.repo # optional
repoSearch: org:googleapis language:typescript language:javascript is:public archived:false

The repoSearch field uses the GitHub Repository Search syntax.

You can set the path to the config file with the REPO_CONFIG_PATH environment variable:

$ echo $REPO_CONFIG_PATH
/User/beckwith/config.yaml

Now you are good to go!

Usage

PR based workflows

The following commands operate over a collection of PRs.

repo approve

$ repo approve [--title title]

Iterates over all open pull requests matching title (this can be a regex, and all PRs will be processed if no regex for title is given) in all configured repositories. For each pull request, asks (in console) if it should be approved and merged. Useful for managing GreenKeeper's PRs:

$ repo approve 🚀

or all PRs with the word test in the title:

$ repo approve test

repo list

$ repo list [--title title]

Iterates over all open pull requests matching title (this can be a regex, and all PRs will be processed if no regex for title is given) in all configured repositories, and prints them.

$ repo list --title 🚀

or all PRs with the word test in the title:

$ repo list --title test

repo reject

$ repo reject [--title title] [--clean]

Iterates over all open pull requests matching title (this can be a regex, and all PRs will be processed if no regex for title is given) and closes them. For example, close all PRs with the word test in the title:

$ repo reject --title test

If --clean is specified, the branch associated with the PR will also be deleted. Branches on forked PRs will be ignored.

repo rename

$ repo rename --title title 'new title'

Iterates over all open pull requests matching title (this can be a regex, and all PRs will be processed if no regex for title is given), and renames them.

repo apply

$ repo apply --branch branch
             --message message
             --comment comment
             [--reviewers username[,username...]]
             [--silent]
             command

Iterates over all configured repositories, clones each of them into a temporary folder, and runs command to apply any changes you need. After command is run, git status is executed and all added and changed files are committed into a new branch branch with commit message message, and then a new pull request is created with comment comment and the given list of reviewers.

Please note that because of GitHub API does not support inserting multiple files into one commit, each file will be committed separately. It can be fixed by changing this library to use the low-level Git data API, your contributions are welcome!

repo check

$ repo check

Iterates all configured repositories and checks that each repository is configured properly (branch protection, continuous integration, valid README.md, etc.).

Repository based workflows

In some cases, you may want to clone all of the repositories that match a given filter, and perform operations over them all locally.

repo sync

To clone or reset all repositories in a given filter set, run:

$ repo sync

This will clone all repositories in the configured clonePath. From there, you can open the entire codebase in your favorite editor, and make changes.

repo exec

After cloning all repositories and making a set of batch changes, you will likely want to commit those changes, push upstream, and submit a pull request. For these, you can use repo exec. This command executes a given command over every cloned repository brought in via repo sync:

$ repo exec -- git status

For example - to go through a typical PR workflow, you would run:

$ repo exec -- git checkout -b my-branch-name
$ repo exec -- git add -A
$ repo exec -- git commit -m \"chore: do something fun\"
$ repo exec -- git push origin my-branch-name
$ repo exec --concurrency 1 -- gh pr create --fill

The gh tool referenced above uses https://cli.github.com/, and the --concurrency flag allows you to control how many pull requests are sent to the GitHub API at once. This is useful if you run into rate limiting or abuse errors.

List of libraries

The tools listed above use the following libraries available in lib/ folder. Feel free to use them directly from your JavaScript code if you need more flexibility than provided by the tools. The files in samples/ folder can serve as samples that show library usage.

lib/update-repo.js

Iterates over all configured repositories, clones each of them into a temporary folder, and calls the provided function to apply any changes you need. The function must return a promise resolving to the list of files to create or modify. These files are committed into a new branch with the given commit message, and then a new pull request is created with the given comment and the given list of reviewers.

Please note that because of GitHub API does not support inserting multiple files into one commit, each file will be committed separately. It can be fixed by changing this library to use the low-level Git data API, your contributions are welcome!

const updateRepo = require('./lib/update-repo.js');

async function callbackFunction(repoPath) {
  // make any changes to the cloned repo in repoPath
  let files = ['path/to/updated/file', 'path/to/new/file'];
  return Promise.resolve(files);
}

async function example() {
  await updateRepo({
    updateCallback: callbackFunction,
    branch: 'new-branch',
    message: 'commit message',
    comment: 'pull request comment',
    reviewers: ['github-username1', 'github-username2'],
  });
}

lib/update-file.js

A function that applies the same fix to one file in all configured repositories, and sends pull requests (that can be approved and merged later by approve-pr.js or manually). Useful if you need to make the same boring change to all the repositories, such as change some configuration file in a certain way.

const updateFile = require('./lib/update-file.js');

function callbackFunction(content) {
  let newContent = content;
  // make any changes to file content
  return newContent;
}

async function example() {
  await updateFile({
    path: 'path/to/file/in/repository',
    patchFunction: callbackFunction,
    branch: 'new-branch',
    message: 'commit message',
    comment: 'pull request comment',
    reviewers: ['github-username1', 'github-username2'],
  });
}

lib/update-file-in-branch.js

A function that does pretty much the same, but to the file in the given branch in all configured repositories, and does not send any pull requests. Useful if you created a bunch of PRs using update-file.js, but then decided to apply a quick change in all created branches.

const updateFileInBranch = require('./lib/update-file-in-branch.js');

function callbackFunction(content) {
  let newContent = content;
  // make any changes to file content
  return newContent;
}

async function example() {
  await updateFileInBranch({
    path: 'path/to/file/in/repository',
    patchFunction: callbackFunction,
    branch: 'existing-branch',
    message: 'commit message',
  });
}

Other files in lib/

lib/github.js

A simple wrapper to GitHub client API (@octokit/rest) that at least lets you pass less parameters to each API call.

lib/question.js

A promisified version of readline.question to provide some primitive interaction.

Handling large numbers of repositories

If you are running GitHub Repo Automation against a large number of repositories, you may find that the default settings lead to quota issues.

There are settings you can configure to make this less likely:

  1. Set --concurrency=N to reduce the # of concurrent requests you are performing:
repo approve --concurrency=4 --title='.*foo dep.*'
  1. Set --retry to automatically retry exceptions with an exponential backoff:
repo approve --retry --title='.*foo dep.*'
  1. Set --delay=N to introduce a delay between requests, allowing you to spread out operations over a longer timeframe:
repo approve --delay=2500

When running against a large number of repos, try the following as a starting point:

repo [command] --delay=1000 --concurrency=2 --retry --title='.*some title.*'

If you are continuing to run into problems, run with:

NODE_DEBUG=repo repo [command] --delay=1000 --concurrency=2 --retry --title='.*some title.*'

And share the debug output in an issue, along with the command you are running.

github-repo-automation's People

Contributors

alexander-fenster avatar bcoe avatar busunkim96 avatar callmehiphop avatar chingor13 avatar dpebot avatar elharo avatar fhinkel avatar gcf-merge-on-green[bot] avatar gcf-owl-bot[bot] avatar google-cloud-policy-bot[bot] avatar jkwlui avatar justinbeckwith avatar pauloaraga0 avatar prototypicalpro avatar release-please[bot] avatar renovate-bot avatar renovate[bot] avatar sofisl avatar stephenplusplus avatar summer-ji-eng avatar surferjeffatgoogle avatar theacodes avatar xiaozhenliu-gg5 avatar yoshi-automation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

github-repo-automation's Issues

Set up publishing to npm in CI

Right now I'm using np to publish this, which is bad. We should move to using CircleCI and the shared team github token.

Synthesis failed for github-repo-automation

Hello! Autosynth couldn't regenerate github-repo-automation. 💔

Here's the output from running synth.py:

usage: synth.py [-h] [--github-user GITHUB_USER] [--github-email GITHUB_EMAIL]
                [--github-token GITHUB_TOKEN] --repository REPOSITORY
                [--synth-path SYNTH_PATH] [--metadata-path METADATA_PATH]
                [--deprecated-execution] [--branch-suffix BRANCH_SUFFIX]
                [--pr-title PR_TITLE]
                ...
synth.py: error: the following arguments are required: --repository

Google internal developers can see the full log here.

`repo apply` always shows me a 404 error

$ repo apply --branch relocate-post-processor     --message "chore: relocate owl bot post processor"     --comment "chore: relocate owl bot post processor"   /usr/local/google/home/rennie/gitrepos/repo-automation-bots/scripts/public-post-processors.sh
Loaded 432 repositories from JSON config.
Total 430 unique repositories loaded.
google-api-nodejs-client
Executing command: /usr/local/google/home/rennie/gitrepos/repo-automation-bots/scripts/public-post-processors.sh
Going to commit the following files:
  .github/.OwlBot.lock.yaml
  .github/.OwlBot.yaml
Do it? [y/n]y
  cannot create branch relocate-post-processor, skipping this repository: Error: Request failed with status code 404
google-api-python-client
Executing command: /usr/local/google/home/rennie/gitrepos/repo-automation-bots/scripts/public-post-processors.sh
Going to commit the following files:
  .github/.OwlBot.lock.yaml
  .github/.OwlBot.yaml
Do it? [y/n]y
  cannot create branch relocate-post-processor, skipping this repository: Error: Request failed with status code 404

Other repo commands succeed, so I don't think it's an auth error:

$ repo list --title e
Loaded 432 repositories from JSON config.
Total 432 unique repositories loaded.
✔ [432/432] repositories scanned, 661 matching PRs found
✔ [661/661] PRs listed
Successfully processed: 661 PRs
  https://github.com/googleapis/nodejs-dialogflow/pull/868                chore: release 4.4.0
  https://github.com/googleapis/google-auth-library-nodejs/pull/1251      feat: Add workforce config support.
  https://github.com/googleapis/google-auth-library-nodejs/pull/1238      feat: add api key support for ADC
  https://github.com/googleapis/google-auth-library-nodejs/pull/1212      chore(serverless): add missing var to snippet block
  https://github.com/googleapis/google-oauth-java-client/pull/744         chore(deps): update dependency org.apache.maven.plugins:maven-javadoc-plugin to v3.3.1
  https://github.com/googleapis/google-oauth-java-client/pull/743         cleanup: Added throws clause Fixes #598
  https://github.com/googleapis/google-oauth-java-client/pull/680         chore(1.31.4-sp): release 1.31.4-sp.2-SNAPSHOT

My github token looks good:
image

cannot delete branch after merging

 [JustinBeckwith] https://github.com/googleapis/nodejs-logging/pull/214: Retry npm install in CI
What to do? [a]pprove and merge, show [p]atch, [s]kip: a
    approved!
    merged!
    error trying to delete branch https://github.com/googleapis/nodejs-logging/pull/214: {"message":"Reference does not exist","documentation_url":"https://developer.github.com/v3/git/refs/#delete-a-reference"}

Commands on many repositories frequently time out

I consistently see repo commands fail with timeout errors when I try to do something across all the python repositories in googleapis.

busunkim@busunkim:~/repo-automation-scripts$ repo tag --title "bazel monolith" owlbot:run
Loaded 133 repositories from JSON config.
Total 133 unique repositories loaded.
✔ [57/133] repositories scanned, 0 matching PRs found
✔ [0/0] PRs tagged
Successfully processed: 0 PRs
Error when processing PRs: cannot list open PRs: FetchError: request to https://api.github.com/repos/googleapis/python-assured-workloads/pulls?state=open&page=1 failed, reason: connect ETIMEDOUT 192.30.255.117:443

Setting --concurrency to a smaller number seems to help. repo makes it through more repositories but still fails with a timeout error.

busunkim@busunkim:~/repo-automation-scripts$ repo tag --title "bazel monolith" --concurrency  3 owlbot:run 
Loaded 133 repositories from JSON config.
Total 133 unique repositories loaded.
✔ [94/133] repositories scanned, 0 matching PRs found
✔ [0/0] PRs tagged
Successfully processed: 0 PRs
Error when processing PRs: cannot list open PRs: FetchError: request to https://api.github.com/repos/googleapis/python-assured-workloads/pulls?state=open&page=1 failed, reason: connect ETIMEDOUT 192.30.255.116:443

My config.yaml:

githubToken: ....
repoSearch: org:googleapis language:python is:public archived:false
clonePath: /usr/local/google/home/busunkim/repo-automation-scripts/.repo

Is there something I should change in my ssh config?

CC @parthea who reported seeing similar behavior.

GitHub: should search for repositories failed

This test failed!

To configure my behavior, see the Flaky Bot documentation.

If I'm commenting on this issue too often, add the flakybot: quiet label and
I will stop commenting.


commit: 8aea69d
buildURL: Build Status, Sponge
status: failed

Test output
request to https://api.github.com/search/repositories?per_page=100&page=1&q=a-search failed, reason: Nock: No match for request {
  "method": "GET",
  "url": "https://api.github.com/search/repositories",
  "headers": {
    "authorization": [
      "token test-github-token"
    ],
    "accept": [
      "application/json"
    ],
    "user-agent": [
      "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ]
  }
}
FetchError: request to https://api.github.com/search/repositories?per_page=100&page=1&q=a-search failed, reason: Nock: No match for request {
  "method": "GET",
  "url": "https://api.github.com/search/repositories",
  "headers": {
    "authorization": [
      "token test-github-token"
    ],
    "accept": [
      "application/json"
    ],
    "user-agent": [
      "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ]
  }
}
    at OverriddenClientRequest. (node_modules/node-fetch/lib/index.js:1494:11)
    at Socket. (node_modules/propagate/index.js:64:17)
    at /workspace/node_modules/nock/lib/socket.js:100:14
    at processTicksAndRejections (internal/process/task_queues.js:79:11)

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

adding support for individual files over 1MB over Github Database API

Is your feature request related to a problem? Please describe.

I noticed in the README of the repository that there is a clear note about no support for Github Database API (in the context of multiple files in one commit).

Unfortunately, in my case, that seems to cause an issue for one very specific use case: package-lock.json 😃 As part of a polyrepo update, I sometimes need to bump the package version, and this file often exceeds that 1MB limit, which requires me to clone the repo separately and use npm cli or manual update in the same branch.

Describe the solution you'd like

Support file size checking and use Github Database API selectively when a file that is being committed exceeds the 1MB limit.

Describe alternatives you've considered

None. Manual updates via Github CLI only.

Additional context

I have the implementation ready on my side for both "getFile" and "updateFileInBranch" with the use of Github DB API. It does not resolve the single-commit-per-file issue though as it would require some refactoring of the "updateRepo" implementation.

Enable `gts check` on the CI

After the TypeScript transition, I had to turn off linting. We should get gts check passing, and turn it back on.

Add a command to enable auto merge

Is your feature request related to a problem? Please describe.
It would be nice to queue a merge once required status checks had passed.

Describe the solution you'd like
Now that GitHub supports auto merge it would be great if there was a new command repo automerge ... that enabled it. Maybe this could also attempt to enable the option on the repo if it's disabled too.

Not sure if it's possible to enable from the API yet, but it probably will be soon

GitHub: should get a list of repos when using the query syntax failed

This test failed!

To configure my behavior, see the Flaky Bot documentation.

If I'm commenting on this issue too often, add the flakybot: quiet label and
I will stop commenting.


commit: 8aea69d
buildURL: Build Status, Sponge
status: failed

Test output
request to https://api.github.com/search/repositories?per_page=100&page=1&q=org%3Atesty%20language%3Apython failed, reason: Nock: No match for request {
  "method": "GET",
  "url": "https://api.github.com/search/repositories",
  "headers": {
    "authorization": [
      "token test-github-token"
    ],
    "accept": [
      "application/json"
    ],
    "user-agent": [
      "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ]
  }
}
FetchError: request to https://api.github.com/search/repositories?per_page=100&page=1&q=org%3Atesty%20language%3Apython failed, reason: Nock: No match for request {
  "method": "GET",
  "url": "https://api.github.com/search/repositories",
  "headers": {
    "authorization": [
      "token test-github-token"
    ],
    "accept": [
      "application/json"
    ],
    "user-agent": [
      "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ]
  }
}
    at OverriddenClientRequest. (node_modules/node-fetch/lib/index.js:1494:11)
    at Socket. (node_modules/propagate/index.js:64:17)
    at /workspace/node_modules/nock/lib/socket.js:100:14
    at processTicksAndRejections (internal/process/task_queues.js:79:11)

Delete branches after PR merges

This tool saves us from manually going to each PR in the browser and clicking "Merge", however, to delete the branches, we still end up having to open the page up. Could we default to deleting a merged branch?

Dependency Dashboard

This issue contains a list of Renovate updates and their statuses.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update actions/setup-node action to v2

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.


  • Check this box to trigger a request for Renovate to run again on this repository

GitHub rate limiting issues

We use the repo tool to do bulk operations on 140+ repositories. Because GitHub has rate limits, we start hitting them after only a few repo commands.
Errors look something like this:

Error when processing PRs: cannot list open PRs: Error: Request failed with status code 403

GitHub: should include auth headers failed

This test failed!

To configure my behavior, see the Flaky Bot documentation.

If I'm commenting on this issue too often, add the flakybot: quiet label and
I will stop commenting.


commit: 8aea69d
buildURL: Build Status, Sponge
status: failed

Test output
Cannot read property 'getFile' of undefined
TypeError: Cannot read property 'getFile' of undefined
    at Context. (build/test/github.js:94:33)
        -> /workspace/test/github.ts:105:29
    at processImmediate (internal/timers.js:461:21)

repo check is broken

Got:

{ HttpError: {"message":"Not Found","documentation_url":"https://developer.github.com/v3/repos/branches/#get-branch-protection"}
    at response.text.then.message (/Users/jonathanlui/n/lib/node_modules/@google/repo/node_modules/@octokit/rest/lib/request/request.js:78:19)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  name: 'HttpError',

Synthesis failed for github-repo-automation

Hello! Autosynth couldn't regenerate github-repo-automation. 💔

Here's the output from running synth.py:

2020-05-15 10:26:24,237 autosynth [INFO] > logs will be written to: /usr/local/google/home/rennie/gitrepos/synthtool/logs/googleapis/github-repo-automation
2020-05-15 10:26:25,428 autosynth [DEBUG] > Running: git config --global core.excludesfile /usr/local/google/home/rennie/.autosynth-gitignore
2020-05-15 10:26:25,433 autosynth [DEBUG] > Running: git config user.name Jeffrey Rennie
2020-05-15 10:26:25,438 autosynth [DEBUG] > Running: git config user.email [email protected]
2020-05-15 10:26:25,444 autosynth [DEBUG] > Running: git config push.default simple
2020-05-15 10:26:25,450 autosynth [DEBUG] > Running: git branch -f autosynth
2020-05-15 10:26:25,458 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2020-05-15 10:26:25,763 autosynth [DEBUG] > Running: git rev-parse --show-toplevel
2020-05-15 10:26:25,774 autosynth [DEBUG] > Running: git log -1 --pretty=%H
2020-05-15 10:26:25,779 autosynth [DEBUG] > Running: git remote get-url origin
2020-05-15 10:26:26,253 autosynth [DEBUG] > Running: git log be74d3e532faa47eb59f1a0eaebde0860d1d8ab4..HEAD --pretty=%H --no-decorate
2020-05-15 10:26:26,261 autosynth [DEBUG] > Running: git log -1 --pretty=%at be74d3e532faa47eb59f1a0eaebde0860d1d8ab4
2020-05-15 10:26:26,269 autosynth [DEBUG] > Running: git log -1 --pretty=%at 4674113712c0c7ada19e6a8219d7963ff174b392
2020-05-15 10:26:26,275 autosynth [DEBUG] > Running: git log -1 --pretty=%at 5bbfd095faedfe273819d266f21e402192a29041
2020-05-15 10:26:26,281 autosynth [DEBUG] > Running: git log -1 --pretty=%at 4fa923bd3dafb91df8613accbe2230299cc5b98e
2020-05-15 10:26:26,289 autosynth [DEBUG] > Running: git log -1 --pretty=%at 55cdc844877d97139f25004229842624a6a86a02
2020-05-15 10:26:26,296 autosynth [DEBUG] > Running: git log -1 --pretty=%at 98c50772ec23295c64cf0d2ddf199ea52961fd4c
2020-05-15 10:26:26,304 autosynth [DEBUG] > Running: git log -1 --pretty=%at ba909fca409f6b38eae0fa735614e127d1fc0deb
2020-05-15 10:26:26,312 autosynth [DEBUG] > Running: git log -1 --pretty=%at 7482e79a82e353248769d819788adc1213e8c207
2020-05-15 10:26:26,322 autosynth [DEBUG] > Running: git log -1 --pretty=%at a7759f81c25396207d46532ed389ad4d34879857
2020-05-15 10:26:26,331 autosynth [DEBUG] > Running: git log -1 --pretty=%at 5b48b0716a36ca069db3038da7e205c87a22ed19
2020-05-15 10:26:26,339 autosynth [DEBUG] > Running: git log -1 --pretty=%at c585ac3b5eff5cd2097a5315ffd9cf4823cc1ed2
2020-05-15 10:26:26,349 autosynth [DEBUG] > Running: git log -1 --pretty=%at b0461724be19443075b08c10d4a345cb217002b5
2020-05-15 10:26:26,356 autosynth [DEBUG] > Running: git log -1 --pretty=%at 84c4156c49be9dcabacc8fd7b0585b6fd789ae47
2020-05-15 10:26:26,362 autosynth [DEBUG] > Running: git log -1 --pretty=%at f503622985e230a6792730bbc3b7746c11fce09e
2020-05-15 10:26:26,369 autosynth [DEBUG] > Running: git log -1 --pretty=%at 3d2a7d0e21387ed455c966da9f9897b0a4bc5bb8
2020-05-15 10:26:26,375 autosynth [DEBUG] > Running: git log -1 --pretty=%at 7b7f386b393947a542b87707499f4458136f4f61
2020-05-15 10:26:26,382 autosynth [DEBUG] > Running: git log -1 --pretty=%at f395615039665af6599f69305efcd886685e74f9
2020-05-15 10:26:26,388 autosynth [DEBUG] > Running: git log -1 --pretty=%at b6bdd4783f396f9252ce28af43f7215834a55c3c
2020-05-15 10:26:26,396 autosynth [DEBUG] > Running: git log -1 --pretty=%at 3593e3a995510c0570648d9a48fc756ab2bfc2cb
2020-05-15 10:26:26,403 autosynth [DEBUG] > Running: git log -1 --pretty=%at cb3433f7f554ea751584bdd3631d45ec56a32eb5
2020-05-15 10:26:26,412 autosynth [DEBUG] > Running: git checkout c4b4f40a3bf7a9e66d552ac377798dfa6ad030ae
Note: switching to 'c4b4f40a3bf7a9e66d552ac377798dfa6ad030ae'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at c4b4f40 fix(deps): update dependency tmp-promise to v3 (#406)
2020-05-15 10:26:26,426 autosynth [DEBUG] > Running: git checkout cb3433f7f554ea751584bdd3631d45ec56a32eb5
Note: switching to 'cb3433f7f554ea751584bdd3631d45ec56a32eb5'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at cb3433f fix: uses http for links to internal logs (#556)
2020-05-15 10:26:26,437 autosynth [DEBUG] > Running: git branch -f autosynth-20
2020-05-15 10:26:26,443 autosynth [DEBUG] > Running: git checkout autosynth-20
Switched to branch 'autosynth-20'
2020-05-15 10:26:26,452 autosynth [INFO] > Running synthtool
2020-05-15 10:26:26,452 autosynth [INFO] > ['/usr/local/google/home/rennie/env3.6/bin/python', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']
2020-05-15 10:26:26,456 autosynth [DEBUG] > Running: /usr/local/google/home/rennie/env3.6/bin/python -m synthtool --metadata synth.metadata synth.py --
/usr/local/google/home/rennie/env3.6/bin/python: No module named synthtool
2020-05-15 10:26:26,490 autosynth [ERROR] > Synthesis failed
2020-05-15 10:26:26,490 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at c4b4f40 fix(deps): update dependency tmp-promise to v3 (#406)
2020-05-15 10:26:26,496 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2020-05-15 10:26:26,503 autosynth [DEBUG] > Running: git clean -fdx
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/google/home/rennie/gitrepos/synthtool/autosynth/synth.py", line 612, in <module>
    main()
  File "/usr/local/google/home/rennie/gitrepos/synthtool/autosynth/synth.py", line 473, in main
    return _inner_main(temp_dir)
  File "/usr/local/google/home/rennie/gitrepos/synthtool/autosynth/synth.py", line 592, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/usr/local/google/home/rennie/gitrepos/synthtool/autosynth/synth.py", line 368, in synthesize_loop
    synthesize_inner_loop(toolbox, synthesizer)
  File "/usr/local/google/home/rennie/gitrepos/synthtool/autosynth/synth.py", line 378, in synthesize_inner_loop
    synthesizer, len(toolbox.versions) - 1
  File "/usr/local/google/home/rennie/gitrepos/synthtool/autosynth/synth.py", line 266, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/usr/local/google/home/rennie/gitrepos/synthtool/autosynth/synthesizer.py", line 119, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/usr/local/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/usr/local/google/home/rennie/env3.6/bin/python', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

Synthesis failed for github-repo-automation

Hello! Autosynth couldn't regenerate github-repo-automation. 💔

Here's the output from running synth.py:

Cloning into 'working_repo'...
Switched to branch 'autosynth'
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.1/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.1/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/git/autosynth/autosynth/synth.py", line 256, in <module>
    main()
  File "/tmpfs/src/git/autosynth/autosynth/synth.py", line 196, in main
    last_synth_commit_hash = get_last_metadata_commit(args.metadata_path)
  File "/tmpfs/src/git/autosynth/autosynth/synth.py", line 149, in get_last_metadata_commit
    text=True,
  File "/home/kbuilder/.pyenv/versions/3.6.1/lib/python3.6/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'text'

Google internal developers can see the full log here.

add support for multiple orgs

We have nodejs repositories across multiple organizations (GoogleCloudPlatform, googleapis, google, dataflow..). We need the ability to extend the config file to support multiple orgs.

add ability to commit to an existing branch using "update-repo" lib

Firstly, thank you all contributors for this library. This is an incredible tool for polyrepo support :)

Is your feature request related to a problem? Please describe.

The "updateRepo" function provides a way to create a new branch in a repo and update it, but does not let you use an existing branch.

Describe the solution you'd like

I would like to be able to use the same tool to re-create a branch with the same name, with the use of a flag and the "deleteBranch" function for the existing branch, while the default behaviour is preserved. It could look something like this:

await updateRepo({
    updateCallback: updateCallback,
    branch: branch,
    deleteBranchIfExists: true, <---
    message: 'chore: update README',
    comment: 'chore: update README',
    reviewers: [],
});

Describe alternatives you've considered

Using "updateFileInBranch", but it is limited to a single file only.

Additional context

Notably, trying to update an existing branch with the HEAD of the last commit of the default branch will not always work out due to potential conflicts. Therefore my suggestion is to delete the specified branch and recreate it before proceeding, rather than adding commits on top.

I am happy to implement this and raise a PR should this be considered an acceptable use case.

TIA!

Repo merge command should ensure status checks have passed

For those of us with admin rights on repositories, the repo merge command can be really dangerous. I think it lets me merge PRs that have failing status checks. As we start to explore expanding the admin role to more folks, I think we need to have repo merge ensure that the required status checks are all passing.

Allow reverts to be supported (or documented)

Currently, in order to revert any changes made I had to go through the following command:

repo apply --branch name --message header --comment body "git revert --no-commit \$(git log --grep=\"for text you need\" --pretty=format:\"%H\"); git reset"

it took a bit of time to figure out that if you simply only do git reverts, the repo tool looks for changes to make through git status and thus does not work naturally with the way that git revert works, hence that's why I had to add ;git reset. Can this be supported through like repo revert "insert query to match commit"?

If not, having the above documented somewhere could also be great for other folks wishing to do a massive revert.

Synthesis failed for github-repo-automation

Hello! Autosynth couldn't regenerate github-repo-automation. 💔

Here's the output from running synth.py:

e/docs-devsite.sh', wd=31, mask=IN_MODIFY, cookie=0, name=docs-devsite.sh>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/release/docs-devsite.sh', wd=31, mask=IN_ATTRIB, cookie=0, name=docs-devsite.sh>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/release/docs-devsite.sh', wd=31, mask=IN_ATTRIB, cookie=0, name=docs-devsite.sh>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/release/publish.cfg', wd=31, mask=IN_MODIFY, cookie=0, name=publish.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/release/publish.cfg', wd=31, mask=IN_MODIFY, cookie=0, name=publish.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/release/publish.cfg', wd=31, mask=IN_ATTRIB, cookie=0, name=publish.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/release/publish.cfg', wd=31, mask=IN_ATTRIB, cookie=0, name=publish.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/release/docs.cfg', wd=31, mask=IN_MODIFY, cookie=0, name=docs.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/release/docs.cfg', wd=31, mask=IN_MODIFY, cookie=0, name=docs.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/release/docs.cfg', wd=31, mask=IN_ATTRIB, cookie=0, name=docs.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/release/docs.cfg', wd=31, mask=IN_ATTRIB, cookie=0, name=docs.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/samples-test.cfg', wd=36, mask=IN_MODIFY, cookie=0, name=samples-test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/samples-test.cfg', wd=36, mask=IN_MODIFY, cookie=0, name=samples-test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/samples-test.cfg', wd=36, mask=IN_ATTRIB, cookie=0, name=samples-test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/lint.cfg', wd=36, mask=IN_MODIFY, cookie=0, name=lint.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/lint.cfg', wd=36, mask=IN_ATTRIB, cookie=0, name=lint.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/test.cfg', wd=36, mask=IN_MODIFY, cookie=0, name=test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/test.cfg', wd=36, mask=IN_MODIFY, cookie=0, name=test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/test.cfg', wd=36, mask=IN_ATTRIB, cookie=0, name=test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/common.cfg', wd=36, mask=IN_MODIFY, cookie=0, name=common.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/common.cfg', wd=36, mask=IN_MODIFY, cookie=0, name=common.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/common.cfg', wd=36, mask=IN_ATTRIB, cookie=0, name=common.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/system-test.cfg', wd=36, mask=IN_MODIFY, cookie=0, name=system-test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/system-test.cfg', wd=36, mask=IN_ATTRIB, cookie=0, name=system-test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/docs.cfg', wd=36, mask=IN_MODIFY, cookie=0, name=docs.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/docs.cfg', wd=36, mask=IN_MODIFY, cookie=0, name=docs.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node10/docs.cfg', wd=36, mask=IN_ATTRIB, cookie=0, name=docs.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node12/test.cfg', wd=38, mask=IN_MODIFY, cookie=0, name=test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node12/test.cfg', wd=38, mask=IN_ATTRIB, cookie=0, name=test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node12/test.cfg', wd=38, mask=IN_ATTRIB, cookie=0, name=test.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node12/common.cfg', wd=38, mask=IN_MODIFY, cookie=0, name=common.cfg>
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node12/common.cfg', wd=38, mask=IN_MODIFY, cookie=0, name=common.cfg>
2020-08-06 04:09:25,470 synthtool [DEBUG] > Installing dependencies...
DEBUG:synthtool:Installing dependencies...
DEBUG:watchdog.observers.inotify_buffer:in-event <InotifyEvent: src_path=b'./.kokoro/continuous/node12/common.cfg', wd=38, mask=IN_ATTRIB, cookie=0, name=common.cfg>
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@szmarczak%2fhttp-timer - Not found
npm ERR! 404 
npm ERR! 404  '@szmarczak/http-timer@^1.1.2' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'got'
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kbuilder/.npm/_logs/2020-08-06T11_09_30_561Z-debug.log
2020-08-06 04:09:30,578 synthtool [ERROR] > Failed executing npm install:

None
ERROR:synthtool:Failed executing npm install:

None
2020-08-06 04:09:30,597 synthtool [DEBUG] > Wrote metadata to synth.metadata.
DEBUG:synthtool:Wrote metadata to synth.metadata.
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/github-repo-automation/synth.py", line 13, in <module>
    node.install()
  File "/tmpfs/src/github/synthtool/synthtool/languages/node.py", line 167, in install
    shell.run(["npm", "install"], hide_output=hide_output)
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['npm', 'install']' returned non-zero exit status 1.
2020-08-06 04:09:30,649 autosynth [ERROR] > Synthesis failed
2020-08-06 04:09:30,650 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at 3b5f955 chore(node): fix kokoro build path for cloud-rad (#440)
2020-08-06 04:09:30,657 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2020-08-06 04:09:30,663 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 690, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 539, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 670, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 375, in synthesize_loop
    has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 273, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

Feature Request: Add ability to have multiple .repo folders

I'm a new user of the repo cli. In my workflow, I found it could be helpful to have multiple .repo folders when multitasking on 2 unrelated tasks that are still work in progress instead of just the one ~/.repo.

The cli already looks for a config.yaml file in the current working directory. Running repo sync could clone repositories in the current directory as well so that git reset --hard is less likely to erase changes. In this setup, I would maintain multiple copies of repositories.

As a workaround, I could use branches to maintain my work in progress, but having multiple config.yaml files would allow me have a better multitasking workflow.

If the recommended solution is to use branches to maintain work in progress, please feel free to close this issue. Perhaps I just need to get used to the fact that repo sync is analogous to git reset --hard and git pull.

In the current design:

  • Multiple config.yaml files are supported
  • Running repo sync will only sync repositories that match criteria in config.yaml file in the current working directory
  • repo exec -- git status will result in running git status on all repositories in ~/.repo

The proposed design:

  • Multiple config.yaml files are supported
  • Running repo sync will only sync repositories that match criteria in config.yaml file in the current working directory
  • repo exec -- git status will result in running git status on all repositories in <current working directory>/.repo

In other words, repo exec will only run on repositories that you are actively working on.

GitHub: should get the list of repositories failed

This test failed!

To configure my behavior, see the Flaky Bot documentation.

If I'm commenting on this issue too often, add the flakybot: quiet label and
I will stop commenting.


commit: 8aea69d
buildURL: Build Status, Sponge
status: failed

Test output
request to https://api.github.com/orgs/test-organization/repos?type=public&page=1&per_page=100 failed, reason: Nock: No match for request {
  "method": "GET",
  "url": "https://api.github.com/orgs/test-organization/repos",
  "headers": {
    "authorization": [
      "token test-github-token"
    ],
    "accept": [
      "application/json"
    ],
    "user-agent": [
      "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ]
  }
}
FetchError: request to https://api.github.com/orgs/test-organization/repos?type=public&page=1&per_page=100 failed, reason: Nock: No match for request {
  "method": "GET",
  "url": "https://api.github.com/orgs/test-organization/repos",
  "headers": {
    "authorization": [
      "token test-github-token"
    ],
    "accept": [
      "application/json"
    ],
    "user-agent": [
      "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ]
  }
}
    at OverriddenClientRequest. (node_modules/node-fetch/lib/index.js:1494:11)
    at Socket. (node_modules/propagate/index.js:64:17)
    at /workspace/node_modules/nock/lib/socket.js:100:14
    at processTicksAndRejections (internal/process/task_queues.js:79:11)

Support alternate master branch names

Is your feature request related to a problem? Please describe.
Hello! Recently there has been an increasing push to to change away from master/slave language in source control repositories. One notable impact of this shift is an increasing number of repositories without a master branch, instead shifting to names such asmain or trunk instead. At the moment, this toolkit does not support these repositories due to the base branch being hardcoded as master. An example of this is below:

async createPullRequest(branch: string, title: string, body: string) {
const owner = this.repository.owner.login;
const repo = this.repository.name;
const head = `refs/heads/${branch}`;
const base = 'refs/heads/master';
const url = `/repos/${owner}/${repo}/pulls`;
const result = await this.client.request({

Describe the solution you'd like
I've created a pull request which replaces this hardcoded value with the default branch, as indicated by GitHub. This pull request also adds an optional baseBranchOverride config value to the config.yml to allow changing of this behavior if necessary.

Tests tests tests

We have 0 (zero) test coverage for the command line tools which is kind of not good :)

approve: Print result summary at end of command

After a long approve/merge & release/update process, some requests inevitably fail. For example, if a branch is out of date and needs to be updated, or if the merge failed because of a CI task that didn't complete.

It would be great to see a basic report that reports the status before the command exits:

$ repo approve "Description"
... all the matching PRs and options ...

Done!
Successfully merged:
{repoName} {description} {url}
{repoName} {description} {url}

Unable to merge:
{repoName} {description} {url} - {reason}

repo untag feature

sometimes after tagging a PR, due to some reasons we need to untag. For instance, automerge is facing backend quota issue -- we need to untag the ones that did not go through successfully.

It would be helpful to have the feature to untag

Get the system and sample tests passing

Right now the tests are passing because we're missing the right SYSTEM_TESTS_ENCRYPTION_KEY env var in the CircleCI config. I think I copied over the compute credentials for this one, since there's no way to avoid decrypting a key as part of CI 😆

Synthesis failed for github-repo-automation

Hello! Autosynth couldn't regenerate github-repo-automation. 💔

Please investigate and fix this issue within 5 business days. While it remains broken,
this library cannot be updated with changes to the github-repo-automation API, and the library grows
stale.

See https://github.com/googleapis/synthtool/blob/master/autosynth/TroubleShooting.md
for trouble shooting tips.

Here's the output from running synth.py:

po-automation/synth.py.
On branch autosynth-68
nothing to commit, working tree clean
2021-04-08 01:52:24,471 synthtool [DEBUG] > Using precloned repo /home/kbuilder/.cache/synthtool/synthtool
DEBUG:synthtool:Using precloned repo /home/kbuilder/.cache/synthtool/synthtool
.eslintignore
.eslintrc.json
.gitattributes
.github/CODEOWNERS
.github/ISSUE_TEMPLATE/bug_report.md
.github/ISSUE_TEMPLATE/feature_request.md
.github/ISSUE_TEMPLATE/support_request.md
.github/PULL_REQUEST_TEMPLATE.md
.github/release-please.yml
.github/workflows/ci.yaml
.kokoro/.gitattributes
.kokoro/common.cfg
.kokoro/continuous/node10/common.cfg
.kokoro/continuous/node10/docs.cfg
.kokoro/continuous/node10/test.cfg
.kokoro/continuous/node12/common.cfg
.kokoro/continuous/node12/lint.cfg
.kokoro/continuous/node12/samples-test.cfg
.kokoro/continuous/node12/system-test.cfg
.kokoro/continuous/node12/test.cfg
.kokoro/docs.sh
.kokoro/lint.sh
.kokoro/populate-secrets.sh
.kokoro/presubmit/node10/common.cfg
.kokoro/presubmit/node12/common.cfg
.kokoro/presubmit/node12/samples-test.cfg
.kokoro/presubmit/node12/system-test.cfg
.kokoro/presubmit/node12/test.cfg
.kokoro/publish.sh
.kokoro/release/docs-devsite.cfg
.kokoro/release/docs-devsite.sh
.kokoro/release/docs.cfg
.kokoro/release/docs.sh
.kokoro/release/publish.cfg
.kokoro/samples-test.sh
.kokoro/system-test.sh
.kokoro/test.bat
.kokoro/test.sh
.kokoro/trampoline.sh
.kokoro/trampoline_v2.sh
.mocharc.js
.nycrc
.prettierignore
.prettierrc.js
.trampolinerc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
2021-04-08 01:52:24,571 synthtool [WARNING] > ensure you pass a string 'quality' to release_quality_badge
WARNING:synthtool:ensure you pass a string 'quality' to release_quality_badge
api-extractor.json
renovate.json
samples/README.md
2021-04-08 01:52:24,606 synthtool [DEBUG] > Installing dependencies...
DEBUG:synthtool:Installing dependencies...
npm WARN deprecated [email protected]: Breaking change found in this patch version
npm WARN deprecated [email protected]: NOTICE: ts-simple-ast has been renamed to ts-morph and version reset to 1.0.0. Switch at your leisure...
npm WARN deprecated [email protected]: Use cheerio-select instead
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: The package has been renamed to `open`
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated

> [email protected] postinstall /home/kbuilder/.cache/synthtool/github-repo-automation/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> @compodoc/[email protected] postinstall /home/kbuilder/.cache/synthtool/github-repo-automation/node_modules/@compodoc/compodoc
> opencollective-postinstall || exit 0

�[96m�[1mThank you for using @compodoc/compodoc!�[96m�[1m
�[0m�[96mIf you rely on this package, please consider supporting our open collective:�[22m�[39m
> �[94mhttps://opencollective.com/compodoc/donate�[0m


> @google/[email protected] prepare /home/kbuilder/.cache/synthtool/github-repo-automation
> npm run compile


> @google/[email protected] precompile /home/kbuilder/.cache/synthtool/github-repo-automation
> gts clean

version: 14
Removing build ...

> @google/[email protected] compile /home/kbuilder/.cache/synthtool/github-repo-automation
> tsc -p .

�[96mnode_modules/@types/sinon/index.d.ts�[0m:�[93m778�[0m:�[93m36�[0m - �[91merror�[0m�[90m TS2694: �[0mNamespace '"/home/kbuilder/.cache/synthtool/github-repo-automation/node_modules/@sinonjs/fake-timers/types/fake-timers-src"' has no exported member 'TimerId'.

�[7m778�[0m     type SinonTimerId = FakeTimers.TimerId;
�[7m   �[0m �[91m                                   ~~~~~~~�[0m

�[96mnode_modules/@types/sinon/index.d.ts�[0m:�[93m780�[0m:�[93m39�[0m - �[91merror�[0m�[90m TS2694: �[0mNamespace '"/home/kbuilder/.cache/synthtool/github-repo-automation/node_modules/@sinonjs/fake-timers/types/fake-timers-src"' has no exported member 'InstalledMethods'.

�[7m780�[0m     type SinonFakeTimers = FakeTimers.InstalledMethods &
�[7m   �[0m �[91m                                      ~~~~~~~~~~~~~~~~�[0m

�[96mnode_modules/@types/sinon/index.d.ts�[0m:�[93m781�[0m:�[93m20�[0m - �[91merror�[0m�[90m TS2694: �[0mNamespace '"/home/kbuilder/.cache/synthtool/github-repo-automation/node_modules/@sinonjs/fake-timers/types/fake-timers-src"' has no exported member 'NodeClock'.

�[7m781�[0m         FakeTimers.NodeClock &
�[7m   �[0m �[91m                   ~~~~~~~~~�[0m

�[96mnode_modules/@types/sinon/index.d.ts�[0m:�[93m782�[0m:�[93m20�[0m - �[91merror�[0m�[90m TS2694: �[0mNamespace '"/home/kbuilder/.cache/synthtool/github-repo-automation/node_modules/@sinonjs/fake-timers/types/fake-timers-src"' has no exported member 'BrowserClock'.

�[7m782�[0m         FakeTimers.BrowserClock & {
�[7m   �[0m �[91m                   ~~~~~~~~~~~~�[0m


Found 4 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @google/[email protected] compile: `tsc -p .`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @google/[email protected] compile script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kbuilder/.npm/_logs/2021-04-08T08_52_48_030Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @google/[email protected] prepare: `npm run compile`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @google/[email protected] prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kbuilder/.npm/_logs/2021-04-08T08_52_48_090Z-debug.log
2021-04-08 01:52:48,118 synthtool [ERROR] > Failed executing npm install:

None
ERROR:synthtool:Failed executing npm install:

None
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/github-repo-automation/synth.py", line 13, in <module>
    node.install()
  File "/tmpfs/src/github/synthtool/synthtool/languages/node.py", line 171, in install
    shell.run(["npm", "install"], hide_output=hide_output)
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['npm', 'install']' returned non-zero exit status 1.
2021-04-08 01:52:48,162 autosynth [ERROR] > Synthesis failed
2021-04-08 01:52:48,162 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at 7357932 chore: release 4.4.0 (#495)
2021-04-08 01:52:48,169 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2021-04-08 01:52:48,175 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Removing node_modules/
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 356, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 191, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 336, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 68, in synthesize_loop
    has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
  File "/tmpfs/src/github/synthtool/autosynth/synth_toolbox.py", line 259, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

Flag commits without tests

On the python-docs-samples repo, we have had a large influx of commits without tests and I'm having a bad time enforcing it. We should produce automation that disallows such commits.

add to sloth

Folks who have Node.js administrative permissions in sloth don't seem to have access to this repository.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.