Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into AsyncIteratorsSto…
Browse files Browse the repository at this point in the history
…rageBlob
  • Loading branch information
HarshaNalluru committed May 29, 2019
2 parents 43d30c0 + 324b388 commit d9a99c4
Show file tree
Hide file tree
Showing 200 changed files with 18,142 additions and 12,366 deletions.
4 changes: 4 additions & 0 deletions .azure-pipelines/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
versionSpec: '$(NodeVersion)'
displayName: 'Install Node.js $(NodeVersion)'

- script: |
npm install -g npm@6.9.0
displayName: 'Install npm version 6.9.0'
- script: |
node common/scripts/install-run-rush.js install
displayName: 'Install dependencies'
Expand Down
4 changes: 1 addition & 3 deletions .docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ omitted_paths:
language: js
root_check_enabled: True
required_readme_sections:
- "Azure .+ client library for JS"
- ^Azure .+ client library for (JS|AMQP operations)
- ^Getting started$
- ^Key concepts$
- ^Examples$
Expand Down Expand Up @@ -79,11 +79,9 @@ known_content_issues:
- ['sdk/storage/storage-queue/samples/README.md', '#1583']
- ['sdk/storage/storage-queue/test/README.md', '#1583']
- ['sdk/storage/storage-datalake/README.md', '#1583']
- ['sdk/core/amqp-common/README.md', '#1583']

package_indexing_exclusion_list:
- '@azure/template'
- 'azure-sp'
- 'testhub'
- 'azure-sdk-for-js'

75 changes: 44 additions & 31 deletions .scripts/clean-autopr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,53 @@
*/

import { exec as execWithCallback } from "child_process";
import { getAuthenticatedClient } from "./github";
import { PullRequestsGetAllParams } from "@octokit/rest";
import Octokit from "@octokit/rest";

const _repositoryOwner = "Azure";
export function getToken(): string {
const token: string = process.env.SDK_GEN_GITHUB_TOKEN || "";
_validatePersonalAccessToken(token);

return token;
}

function _validatePersonalAccessToken(token: string): void {
if (!token) {
const text =
`Github personal access token was not found as a script parameter or as an
environmental variable. Please visit https://github.com/settings/tokens,
generate new token with "repo" scope and pass it with -token switch or set
it as environmental variable named SDK_GEN_GITHUB_TOKEN.`

console.error(text);
}
}

export function getAuthenticatedClient(): Octokit {
const octokit = new Octokit({ auth: getToken()});
return octokit;
}

async function cleanBranches() {
const octokit = getAuthenticatedClient();
const params: PullRequestsGetAllParams = {
owner: _repositoryOwner,
const params: Octokit.PullsListParams = {
owner: "Azure",
repo: "azure-sdk-for-js",
state: "open"
state: "open",
per_page: 100
}

let pullRequestsResponse = await octokit.pullRequests.getAll(params);

do {
const autoPullRequests = pullRequestsResponse.data.filter(pr => pr.title.startsWith("[AutoPR")).map(pr => pr.head.ref);
console.log(JSON.stringify(autoPullRequests, undefined, " "));
console.log(JSON.stringify(autoPullRequests.length, undefined, " "));

for (const branch of autoPullRequests) {
try {
await exec(`git push origin :${branch}`);
} catch (err) {
console.log(`Branch ${branch} doesn't exist. Skipping. Error: [${err}]`);
}
}
let pullRequestsResponse = await octokit.pulls.list(params);
const autoPullRequests = pullRequestsResponse.data.filter(pr => pr.title.startsWith("[AutoPR")).map(pr => pr.head.ref);
console.log(JSON.stringify(autoPullRequests, undefined, " "));
console.log(`Found ${autoPullRequests.length} branches`);

if (octokit.hasFirstPage(pullRequestsResponse)) {
pullRequestsResponse = await octokit.getNextPage(pullRequestsResponse);
} else {
break;
for (const branch of autoPullRequests) {
try {
await exec(`git push origin :${branch}`);
} catch (err) {
console.log(`Branch ${branch} doesn't exist. Skipping. Error: [${err}]`);
}
} while (true);
}

try {
cleanBranches();
} catch (err) {
console.error(err);
}
}

async function exec(command: string): Promise<any> {
Expand All @@ -59,3 +66,9 @@ async function exec(command: string): Promise<any> {
});
});
}

try {
cleanBranches();
} catch (err) {
console.error(err);
}
Loading

0 comments on commit d9a99c4

Please sign in to comment.