Skip to content

Commit

Permalink
fix(build): migrate to main branch (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Sep 3, 2021
1 parent b7a8484 commit 7bfadc8
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/generated-files-bot.yml
Expand Up @@ -8,9 +8,9 @@ generatedFiles:
- path: '.github/generated-files-bot.+(yml|yaml)'
message: '`.github/generated-files-bot.(yml|yaml)` should be updated in [`synthtool`](https://github.com/googleapis/synthtool)'
- path: 'README.md'
message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml'
message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml'
- path: 'samples/README.md'
message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml'
message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml'
ignoreAuthors:
- 'gcf-owl-bot[bot]'
- 'yoshi-automation'
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
@@ -1,7 +1,7 @@
on:
push:
branches:
- master
- main
pull_request:
name: ci
jobs:
Expand Down
17 changes: 7 additions & 10 deletions README.md
Expand Up @@ -6,9 +6,6 @@

[![release level](https://img.shields.io/badge/release%20level-alpha-orange.svg?style=flat)](https://cloud.google.com/terms/launch-stages)
[![npm version](https://img.shields.io/npm/v/@google-cloud/code-suggester.svg)](https://www.npmjs.org/package/@google-cloud/code-suggester)
[![codecov](https://img.shields.io/codecov/c/github/googleapis/code-suggester/master.svg?style=flat)](https://codecov.io/gh/googleapis/code-suggester)




## Description
Expand Down Expand Up @@ -141,7 +138,7 @@ The `createPullRequest()` method creates a GitHub Pull request with the files gi
| description | `string` | The GitHub Pull Request description. Default is `'code suggestions'`. |
| title | `string` | The GitHub Pull Request title. Default is `'chore: code suggestions'`. |
| branch | `string` | The branch containing the changes. Default is `'code-suggestions'`. |
| primary | `string` | The primary upstream branch to open a PR against. Default is `'master'`. |
| primary | `string` | The primary upstream branch to open a PR against. Default is `'main'`. |
| message | `string` | The commit message for the changes. Default is `'code suggestions'`. We recommend following [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/).|
| force | `boolean` | Whether or not to force push the reference even if the ancestor commits differs. Default is `false`. |
| fork | `boolean` | Whether or not code suggestion should be made from a fork, defaults to `true` (_Note: forking does not work when using `secrets.GITHUB_TOKEN` in an action_). |
Expand Down Expand Up @@ -214,7 +211,7 @@ The GitHub working branch name. Default value is: `'code-suggestions'`.

#### `--primary, -p`
*string* <br>
The primary upstream branch to open a PR against. Default value is: `'master'`.
The primary upstream branch to open a PR against. Default value is: `'main'`.

#### `--message, -m`
*string* <br>
Expand Down Expand Up @@ -311,7 +308,7 @@ The GitHub working branch name. Default value is: `'code-suggestions'`.

#### `primary`
*string* <br>
The primary upstream branch to open a PR against. Default value is: `'master'`.
The primary upstream branch to open a PR against. Default value is: `'main'`.

#### `message`
*string* <br>
Expand Down Expand Up @@ -344,7 +341,7 @@ The following example is a `.github/workflows/main.yaml` file in repo `Octocat/H
on:
push:
branches:
- master
- main
name: ci
jobs:
add-license:
Expand Down Expand Up @@ -406,7 +403,7 @@ on:
pull_request_target:
types: [opened, synchronize]
branches:
- master
- main
name: ci
jobs:
add-license:
Expand Down Expand Up @@ -468,7 +465,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages]

## Contributing

Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/code-suggester/blob/master/CONTRIBUTING.md).
Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/code-suggester/blob/main/CONTRIBUTING.md).

Please note that this `README.md`, the `samples/README.md`,
and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`)
Expand All @@ -480,7 +477,7 @@ to its template in this

Apache Version 2.0

See [LICENSE](https://github.com/googleapis/code-suggester/blob/master/LICENSE)
See [LICENSE](https://github.com/googleapis/code-suggester/blob/main/LICENSE)



Expand Down
2 changes: 1 addition & 1 deletion action.yaml
Expand Up @@ -33,7 +33,7 @@ inputs:
description: 'The GitHub working branch name. Required for "pr" command.'
primary:
description: 'The primary upstream branch to open a PR against.'
default: master
default: main
force:
description: >-
Whether or not to force push a reference with different commit history
Expand Down
4 changes: 2 additions & 2 deletions src/bin/code-suggester.ts
Expand Up @@ -61,8 +61,8 @@ yargs
primary: {
alias: 'p',
describe:
"The primary upstream branch to open a Pull Request against. Default is 'master'.",
default: 'master',
"The primary upstream branch to open a Pull Request against. Default is 'main'.",
default: 'main',
type: 'string',
},
force: {
Expand Down
2 changes: 1 addition & 1 deletion src/default-options-handler.ts
Expand Up @@ -20,7 +20,7 @@ import {
} from './types';

const DEFAULT_BRANCH_NAME = 'code-suggestions';
const DEFAULT_PRIMARY_BRANCH = 'master';
const DEFAULT_PRIMARY_BRANCH = 'main';
const DEFAULT_PAGE_SIZE = 100;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/github/branch.ts
Expand Up @@ -17,7 +17,7 @@ import {RepoDomain} from '../types';
import {Octokit} from '@octokit/rest';

const REF_PREFIX = 'refs/heads/';
const DEFAULT_PRIMARY_BRANCH = 'master';
const DEFAULT_PRIMARY_BRANCH = 'main';

/**
* Create a new branch reference with the ref prefix
Expand Down Expand Up @@ -116,7 +116,7 @@ export async function createBranch(
* @param {RepoDomain} origin The domain information of the remote origin repository
* @param {RepoDomain} upstream The domain information of the remote upstream repository
* @param {string} name The branch name to create on the origin repository
* @param {string} baseBranch the name of the branch to base the new branch off of. Default is master
* @param {string} baseBranch the name of the branch to base the new branch off of. Default is main
* @returns {Promise<string>} the base SHA for subsequent commits to be based off for the origin branch
*/
export async function branch(
Expand Down
4 changes: 2 additions & 2 deletions src/github/open-pull-request.ts
Expand Up @@ -16,7 +16,7 @@ import {BranchDomain, Description, RepoDomain} from '../types';
import {Octokit} from '@octokit/rest';
import {logger} from '../logger';

const DEFAULT_PRIMARY = 'master';
const DEFAULT_PRIMARY = 'main';

/**
* Create a GitHub PR on the upstream organization's repo
Expand All @@ -26,7 +26,7 @@ const DEFAULT_PRIMARY = 'master';
* @param {BranchDomain} origin The remote origin information that contains the origin branch
* @param {Description} description The pull request title and detailed description
* @param {boolean} maintainersCanModify Whether or not maintainers can modify the pull request. Default is true
* @param {string} upstreamPrimary The upstream repository's primary branch. Default is master.
* @param {string} upstreamPrimary The upstream repository's primary branch. Default is main.
* @param draft Open a DRAFT pull request. Defaults to false.
* @returns {Promise<void>}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Expand Up @@ -89,7 +89,7 @@ export interface CreatePullRequestUserOptions {
force?: boolean;
// Should a fork be used when creating pull request
fork?: boolean;
// Primary upstream branch to open PRs against. Default is 'master' (optional)
// Primary upstream branch to open PRs against. Default is 'main' (optional)
primary?: string;
// Whether or not maintainers can modify the PR. Default is true. (optional)
maintainersCanModify?: boolean;
Expand Down
22 changes: 11 additions & 11 deletions test/branch.ts
Expand Up @@ -60,12 +60,12 @@ describe('Branch', () => {
.stub(octokit.repos, 'getBranch')
.resolves(branchResponse);
// // tests
const headSHA = await getBranchHead(octokit, origin, 'master');
const headSHA = await getBranchHead(octokit, origin, 'main');
assert.strictEqual(headSHA, branchResponse.data.commit.sha);
sandbox.assert.calledOnceWithExactly(getBranchStub, {
owner: origin.owner,
repo: origin.repo,
branch: 'master',
branch: 'main',
});
});

Expand Down Expand Up @@ -105,12 +105,12 @@ describe('Branch', () => {
.stub(octokit.git, 'createRef')
.resolves(createRefResponse);
// tests
const sha = await branch(octokit, origin, upstream, branchName, 'master');
const sha = await branch(octokit, origin, upstream, branchName, 'main');
assert.strictEqual(sha, branchResponse.data.commit.sha);
sandbox.assert.calledOnceWithExactly(getBranchStub, {
owner: upstream.owner,
repo: upstream.repo,
branch: 'master',
branch: 'main',
});
sandbox.assert.calledOnceWithExactly(listBranchStub, {
owner: origin.owner,
Expand Down Expand Up @@ -154,13 +154,13 @@ describe('Branch', () => {
origin,
upstream,
'existing-branch',
'master'
'main'
);
assert.strictEqual(sha, branchResponse.data.commit.sha);
sandbox.assert.calledOnceWithExactly(getBranchStub, {
owner: upstream.owner,
repo: upstream.repo,
branch: 'master',
branch: 'main',
});
sandbox.assert.calledOnceWithExactly(listBranchStub, {
owner: origin.owner,
Expand All @@ -174,7 +174,7 @@ describe('Branch', () => {
const error = new Error(testErrorMessage);
sandbox.stub(octokit.repos, 'getBranch').rejects(error);
await assert.rejects(
branch(octokit, origin, upstream, branchName, 'master'),
branch(octokit, origin, upstream, branchName, 'main'),
error
);
});
Expand All @@ -190,7 +190,7 @@ describe('Branch', () => {
sandbox.stub(octokit.repos, 'getBranch').resolves(branchResponse);
sandbox.stub(octokit.git, 'getRef').rejects(error);
await assert.rejects(
branch(octokit, origin, upstream, branchName, 'master'),
branch(octokit, origin, upstream, branchName, 'main'),
error
);
});
Expand All @@ -209,7 +209,7 @@ describe('Branch', () => {
sandbox.stub(octokit.git, 'getRef').rejects(getRefError);
sandbox.stub(octokit.git, 'createRef').rejects(createRefError);
await assert.rejects(
branch(octokit, origin, upstream, branchName, 'master'),
branch(octokit, origin, upstream, branchName, 'main'),
createRefError
);
});
Expand All @@ -223,11 +223,11 @@ describe('Branch', () => {
} as GetBranchResponse;
sandbox.stub(octokit.repos, 'getBranch').resolves(branchResponse);
await assert.rejects(
branch(octokit, origin, upstream, branchName, 'non-master-branch')
branch(octokit, origin, upstream, branchName, 'non-main-branch')
);
});
it('the reference string parsing function correctly appends branch name to reference prefix', () => {
assert.strictEqual(createRef('master'), 'refs/heads/master');
assert.strictEqual(createRef('main'), 'refs/heads/main');
assert.strictEqual(createRef('foo/bar/baz'), 'refs/heads/foo/bar/baz');
assert.strictEqual(createRef('+++'), 'refs/heads/+++');
});
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/create-fork-response.json
Expand Up @@ -75,7 +75,7 @@
"stargazers_count": 80,
"watchers_count": 80,
"size": 108,
"default_branch": "master",
"default_branch": "main",
"open_issues_count": 0,
"is_template": true,
"topics": [
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/create-pr-response.json
Expand Up @@ -291,7 +291,7 @@
"stargazers_count": 80,
"watchers_count": 80,
"size": 108,
"default_branch": "master",
"default_branch": "main",
"open_issues_count": 0,
"is_template": true,
"topics": [
Expand Down Expand Up @@ -327,8 +327,8 @@
}
},
"base": {
"label": "octocat:master",
"ref": "master",
"label": "octocat:main",
"ref": "main",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"user": {
"login": "octocat",
Expand Down Expand Up @@ -427,7 +427,7 @@
"stargazers_count": 80,
"watchers_count": 80,
"size": 108,
"default_branch": "master",
"default_branch": "main",
"open_issues_count": 0,
"is_template": true,
"topics": [
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/get-branch-response.json
@@ -1,5 +1,5 @@
{
"name": "master",
"name": "main",
"commit": {
"sha": "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d",
"node_id": "MDY6Q29tbWl0N2ZkMWE2MGIwMWY5MWIzMTRmNTk5NTVhNGU0ZDRlODBkOGVkZjExZA==",
Expand Down Expand Up @@ -54,8 +54,8 @@
}
},
"_links": {
"html": "https://github.com/octocat/Hello-World/tree/master",
"self": "https://api.github.com/repos/octocat/Hello-World/branches/master"
"html": "https://github.com/octocat/Hello-World/tree/main",
"self": "https://api.github.com/repos/octocat/Hello-World/branches/main"
},
"protected": true,
"protection": {
Expand All @@ -68,5 +68,5 @@
]
}
},
"protection_url": "https://api.github.com/repos/octocat/hello-world/branches/master/protection"
"protection_url": "https://api.github.com/repos/octocat/hello-world/branches/main/protection"
}
8 changes: 4 additions & 4 deletions test/fixtures/get-pull-request-response.json
Expand Up @@ -291,7 +291,7 @@
"stargazers_count": 80,
"watchers_count": 80,
"size": 108,
"default_branch": "master",
"default_branch": "main",
"open_issues_count": 0,
"is_template": true,
"topics": [
Expand Down Expand Up @@ -327,8 +327,8 @@
}
},
"base": {
"label": "octocat:master",
"ref": "master",
"label": "octocat:main",
"ref": "main",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"user": {
"login": "octocat",
Expand Down Expand Up @@ -427,7 +427,7 @@
"stargazers_count": 80,
"watchers_count": 80,
"size": 108,
"default_branch": "master",
"default_branch": "main",
"open_issues_count": 0,
"is_template": true,
"topics": [
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/list-pulls-response.json
Expand Up @@ -292,7 +292,7 @@
"stargazers_count": 80,
"watchers_count": 80,
"size": 108,
"default_branch": "master",
"default_branch": "main",
"open_issues_count": 0,
"is_template": true,
"topics": [
Expand Down Expand Up @@ -328,8 +328,8 @@
}
},
"base": {
"label": "octocat:master",
"ref": "master",
"label": "octocat:main",
"ref": "main",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"user": {
"login": "octocat",
Expand Down Expand Up @@ -428,7 +428,7 @@
"stargazers_count": 80,
"watchers_count": 80,
"size": 108,
"default_branch": "master",
"default_branch": "main",
"open_issues_count": 0,
"is_template": true,
"topics": [
Expand Down
4 changes: 2 additions & 2 deletions test/main-pr-option-defaults.ts
Expand Up @@ -46,7 +46,7 @@ describe('addPullRequestDefaults', () => {
description: 'custom description',
title: 'chore: custom title',
message: 'chore: custom description',
primary: 'master',
primary: 'main',
maintainersCanModify: true,
});
const upstreamAndPrimary: CreatePullRequestUserOptions = {
Expand Down Expand Up @@ -85,7 +85,7 @@ describe('addPullRequestDefaults', () => {
title: 'chore: code suggestions non-default PR ttile',
force: false,
message: 'chore: custom code suggestions message',
primary: 'master',
primary: 'main',
maintainersCanModify: true,
});
});
Expand Down

0 comments on commit 7bfadc8

Please sign in to comment.