release-please 17.8.0 → 17.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/src/github-api.d.ts +1 -1
- package/build/src/github.d.ts +1 -1
- package/build/src/github.js +1 -1
- package/build/src/index.d.ts +1 -1
- package/build/src/index.js +1 -1
- package/build/src/local-github.d.ts +1 -1
- package/build/src/local-github.js +1 -1
- package/build/src/manifest.js +22 -20
- package/build/src/plugins/linked-versions.js +1 -1
- package/build/src/strategies/base.js +8 -0
- package/build/src/strategies/go-librarian.d.ts +2 -0
- package/build/src/strategies/go-librarian.js +15 -1
- package/build/src/updaters/librarian-yaml.d.ts +7 -0
- package/build/src/updaters/librarian-yaml.js +47 -21
- package/build/src/util/branch-name.d.ts +1 -0
- package/build/src/util/branch-name.js +9 -0
- package/build/src/util/code-suggester/default-options-handler.d.ts +10 -0
- package/build/src/util/code-suggester/default-options-handler.js +45 -0
- package/build/src/util/code-suggester/errors.d.ts +4 -0
- package/build/src/util/code-suggester/errors.js +24 -0
- package/build/src/util/code-suggester/github/branch.d.ts +45 -0
- package/build/src/util/code-suggester/github/branch.js +118 -0
- package/build/src/util/code-suggester/github/commit-and-push.d.ts +51 -0
- package/build/src/util/code-suggester/github/commit-and-push.js +141 -0
- package/build/src/util/code-suggester/github/create-commit.d.ts +20 -0
- package/build/src/util/code-suggester/github/create-commit.js +60 -0
- package/build/src/util/code-suggester/github/fork.d.ts +15 -0
- package/build/src/util/code-suggester/github/fork.js +48 -0
- package/build/src/util/code-suggester/github/labels.d.ts +14 -0
- package/build/src/util/code-suggester/github/labels.js +42 -0
- package/build/src/util/code-suggester/github/open-pull-request.d.ts +16 -0
- package/build/src/util/code-suggester/github/open-pull-request.js +56 -0
- package/build/src/util/code-suggester/index.d.ts +28 -0
- package/build/src/util/code-suggester/index.js +110 -0
- package/build/src/util/code-suggester/logger.d.ts +4 -0
- package/build/src/util/code-suggester/logger.js +37 -0
- package/build/src/util/code-suggester/types.d.ts +109 -0
- package/build/src/util/code-suggester/types.js +30 -0
- package/build/src/util/pull-request-title.js +4 -4
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# [Release Please](https://github.com/googleapis/release-please)
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.org/package/release-please)
|
|
6
|
-
[](https://codecov.io/gh/googleapis/release-please)
|
|
7
7
|
|
|
8
8
|
Release Please automates CHANGELOG generation, the creation of GitHub releases,
|
|
9
9
|
and version bumps for your projects.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Octokit } from '@octokit/rest';
|
|
2
2
|
import { request } from '@octokit/request';
|
|
3
|
-
import { Logger } from 'code-suggester/
|
|
3
|
+
import { Logger } from './util/code-suggester/types';
|
|
4
4
|
import { PullRequest } from './pull-request';
|
|
5
5
|
import { Repository } from './repository';
|
|
6
6
|
import { Release } from './release';
|
package/build/src/github.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { Update } from './update';
|
|
|
9
9
|
import { Release } from './release';
|
|
10
10
|
import { GitHubApi, GitHubCreateOptions } from './github-api';
|
|
11
11
|
import { GitHubFileContents } from '@google-automations/git-file-utils';
|
|
12
|
-
import { Logger } from 'code-suggester/
|
|
12
|
+
import { Logger } from './util/code-suggester/types';
|
|
13
13
|
import { Scm, ScmChangeSet, ScmCommitIteratorOptions, ScmReleaseIteratorOptions, ScmTagIteratorOptions, ScmCreatePullRequestOptions, ScmReleaseOptions, ScmRelease, ScmTag, ScmUpdatePullRequestOptions } from './scm';
|
|
14
14
|
type RequestBuilderType = typeof request;
|
|
15
15
|
type DefaultFunctionType = RequestBuilderType['defaults'];
|
package/build/src/github.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.sleepInMs = exports.GitHub = void 0;
|
|
17
17
|
const request_error_1 = require("@octokit/request-error");
|
|
18
|
-
const code_suggester_1 = require("code-suggester");
|
|
18
|
+
const code_suggester_1 = require("./util/code-suggester");
|
|
19
19
|
const errors_1 = require("./errors");
|
|
20
20
|
const MAX_ISSUE_BODY_SIZE = 65536;
|
|
21
21
|
const MAX_SLEEP_SECONDS = 20;
|
package/build/src/index.d.ts
CHANGED
package/build/src/index.js
CHANGED
|
@@ -36,6 +36,6 @@ Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () {
|
|
|
36
36
|
exports.configSchema = require('../../schemas/config.json');
|
|
37
37
|
exports.manifestSchema = require('../../schemas/manifest.json');
|
|
38
38
|
// x-release-please-start-version
|
|
39
|
-
exports.VERSION = '17.
|
|
39
|
+
exports.VERSION = '17.10.0';
|
|
40
40
|
// x-release-please-end
|
|
41
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -7,7 +7,7 @@ import { Update } from './update';
|
|
|
7
7
|
import { Release } from './release';
|
|
8
8
|
import { GitHubFileContents } from '@google-automations/git-file-utils';
|
|
9
9
|
import { GitHubApi, GitHubCreateOptions } from './github-api';
|
|
10
|
-
import { Logger } from 'code-suggester/
|
|
10
|
+
import { Logger } from './util/code-suggester/types';
|
|
11
11
|
export interface LocalGitHubCreateOptions extends GitHubCreateOptions {
|
|
12
12
|
cloneDepth?: number;
|
|
13
13
|
localRepoPath?: string;
|
|
@@ -20,7 +20,7 @@ const os = require("os");
|
|
|
20
20
|
const child_process = require("child_process");
|
|
21
21
|
const util = require("util");
|
|
22
22
|
const readline = require("readline");
|
|
23
|
-
const code_suggester_1 = require("code-suggester");
|
|
23
|
+
const code_suggester_1 = require("./util/code-suggester");
|
|
24
24
|
const execFile = util.promisify(child_process.execFile);
|
|
25
25
|
const mkdtemp = fs.promises.mkdtemp;
|
|
26
26
|
const errors_1 = require("./errors");
|
package/build/src/manifest.js
CHANGED
|
@@ -211,26 +211,28 @@ class Manifest {
|
|
|
211
211
|
continue;
|
|
212
212
|
}
|
|
213
213
|
const component = tagName.component || exports.DEFAULT_COMPONENT_NAME;
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
214
|
+
const paths = pathsByComponent[component] || [];
|
|
215
|
+
if (paths.length === 0) {
|
|
216
216
|
this.logger.warn(`Found release tag with component '${component}', but not configured in manifest`);
|
|
217
217
|
continue;
|
|
218
218
|
}
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
219
|
+
for (const path of paths) {
|
|
220
|
+
const expectedVersion = this.releasedVersions[path];
|
|
221
|
+
if (!expectedVersion) {
|
|
222
|
+
this.logger.warn(`Unable to find expected version for path '${path}' in manifest`);
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (expectedVersion.toString() === tagName.version.toString()) {
|
|
226
|
+
this.logger.debug(`Found release for path ${path}, ${release.tagName}`);
|
|
227
|
+
releaseShasByPath[path] = release.sha;
|
|
228
|
+
releasesByPath[path] = {
|
|
229
|
+
name: release.name,
|
|
230
|
+
tag: tagName,
|
|
231
|
+
sha: release.sha,
|
|
232
|
+
notes: release.notes || '',
|
|
233
|
+
};
|
|
234
|
+
releasesFound += 1;
|
|
235
|
+
}
|
|
234
236
|
}
|
|
235
237
|
if (releasesFound >= expectedReleases) {
|
|
236
238
|
break;
|
|
@@ -793,10 +795,10 @@ class Manifest {
|
|
|
793
795
|
for (const path in this.repositoryConfig) {
|
|
794
796
|
const strategy = strategiesByPath[path];
|
|
795
797
|
const component = (await strategy.getComponent()) || '';
|
|
796
|
-
if (this._pathsByComponent[component]) {
|
|
797
|
-
this.
|
|
798
|
+
if (!this._pathsByComponent[component]) {
|
|
799
|
+
this._pathsByComponent[component] = [];
|
|
798
800
|
}
|
|
799
|
-
this._pathsByComponent[component]
|
|
801
|
+
this._pathsByComponent[component].push(path);
|
|
800
802
|
}
|
|
801
803
|
}
|
|
802
804
|
return this._pathsByComponent;
|
|
@@ -123,7 +123,7 @@ class LinkedVersions extends plugin_1.ManifestPlugin {
|
|
|
123
123
|
// delegate to the merge plugin and add merged pull request
|
|
124
124
|
if (inScopeCandidates.length > 0) {
|
|
125
125
|
const merge = new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig, {
|
|
126
|
-
pullRequestTitlePattern:
|
|
126
|
+
pullRequestTitlePattern: 'chore${scope}: release ' + this.groupName + ' libraries',
|
|
127
127
|
forceMerge: true,
|
|
128
128
|
headBranchName: branch_name_1.BranchName.ofGroupTargetBranch(this.groupName, this.targetBranch).toString(),
|
|
129
129
|
});
|
|
@@ -373,6 +373,14 @@ class BaseStrategy {
|
|
|
373
373
|
this.logger.error(`Bad branch name: ${mergedPullRequest.headBranchName}`);
|
|
374
374
|
return;
|
|
375
375
|
}
|
|
376
|
+
const branchComponent = await this.getBranchComponent();
|
|
377
|
+
if (branchName.isComponent()) {
|
|
378
|
+
if (this.normalizeComponent(branchName.component) !==
|
|
379
|
+
this.normalizeComponent(branchComponent)) {
|
|
380
|
+
this.logger.info(`PR branch component: ${branchName.component} does not match configured branch component: ${branchComponent}`);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
376
384
|
const pullRequestBody = await this.parsePullRequestBody(mergedPullRequest.body);
|
|
377
385
|
if (!pullRequestBody) {
|
|
378
386
|
this.logger.error('Could not parse pull request body as a release PR');
|
|
@@ -4,6 +4,8 @@ import { Version } from '../version';
|
|
|
4
4
|
export declare class GoLibrarian extends BaseStrategy {
|
|
5
5
|
readonly versionFile: string;
|
|
6
6
|
constructor(options: BaseStrategyOptions);
|
|
7
|
+
getComponent(): Promise<string | undefined>;
|
|
8
|
+
getBranchComponent(): Promise<string | undefined>;
|
|
7
9
|
protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
8
10
|
protected initialReleaseVersion(): Version;
|
|
9
11
|
}
|
|
@@ -26,6 +26,20 @@ class GoLibrarian extends base_1.BaseStrategy {
|
|
|
26
26
|
super(options);
|
|
27
27
|
this.versionFile = (_b = options.versionFile) !== null && _b !== void 0 ? _b : 'internal/version.go';
|
|
28
28
|
}
|
|
29
|
+
async getComponent() {
|
|
30
|
+
const component = await super.getComponent();
|
|
31
|
+
if (component) {
|
|
32
|
+
const match = component.match(/^(.*)\/v[2-9]\d*$/);
|
|
33
|
+
if (match) {
|
|
34
|
+
return match[1];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return component;
|
|
38
|
+
}
|
|
39
|
+
async getBranchComponent() {
|
|
40
|
+
const component = await super.getBranchComponent();
|
|
41
|
+
return component ? component.replace(/\//g, '-') : undefined;
|
|
42
|
+
}
|
|
29
43
|
async buildUpdates(options) {
|
|
30
44
|
const updates = [];
|
|
31
45
|
const version = options.newVersion;
|
|
@@ -63,7 +77,7 @@ class GoLibrarian extends base_1.BaseStrategy {
|
|
|
63
77
|
if (this.initialVersion) {
|
|
64
78
|
return version_1.Version.parse(this.initialVersion);
|
|
65
79
|
}
|
|
66
|
-
return version_1.Version.parse('1.0
|
|
80
|
+
return version_1.Version.parse('0.1.0');
|
|
67
81
|
}
|
|
68
82
|
}
|
|
69
83
|
exports.GoLibrarian = GoLibrarian;
|
|
@@ -4,11 +4,16 @@ export interface JavaModule {
|
|
|
4
4
|
artifact_id: string;
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
}
|
|
7
|
+
export interface PreviewModule {
|
|
8
|
+
version: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
7
11
|
export interface LibrarianLibrary {
|
|
8
12
|
name: string;
|
|
9
13
|
version: string;
|
|
10
14
|
output?: string;
|
|
11
15
|
java?: JavaModule;
|
|
16
|
+
preview?: PreviewModule;
|
|
12
17
|
[key: string]: any;
|
|
13
18
|
}
|
|
14
19
|
export interface LibrarianYamlSchema {
|
|
@@ -35,4 +40,6 @@ export declare class LibrarianYamlUpdater extends DefaultUpdater {
|
|
|
35
40
|
updateContent(content: string, _logger?: Logger): string;
|
|
36
41
|
private deriveOutputDirectory;
|
|
37
42
|
private findArtifactID;
|
|
43
|
+
private getOrCreateSubsection;
|
|
44
|
+
private updateValue;
|
|
38
45
|
}
|
|
@@ -35,6 +35,7 @@ class LibrarianYamlUpdater extends default_1.DefaultUpdater {
|
|
|
35
35
|
* @returns {string} The updated content
|
|
36
36
|
*/
|
|
37
37
|
updateContent(content, _logger = logger_1.logger) {
|
|
38
|
+
var _a;
|
|
38
39
|
const doc = yaml.parseDocument(content);
|
|
39
40
|
if (!doc || doc.errors.length > 0) {
|
|
40
41
|
throw new Error(`Invalid yaml, cannot be parsed: ${doc.errors
|
|
@@ -51,6 +52,7 @@ class LibrarianYamlUpdater extends default_1.DefaultUpdater {
|
|
|
51
52
|
continue;
|
|
52
53
|
const libraryJSON = library.toJSON();
|
|
53
54
|
let newVersion = undefined;
|
|
55
|
+
let isPreview = false;
|
|
54
56
|
if (this.versionsMap) {
|
|
55
57
|
// Multi-version (Java style)
|
|
56
58
|
const artifactID = this.findArtifactID(libraryJSON);
|
|
@@ -60,33 +62,42 @@ class LibrarianYamlUpdater extends default_1.DefaultUpdater {
|
|
|
60
62
|
}
|
|
61
63
|
else {
|
|
62
64
|
// Single version (Go, Python, Node style)
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
this.
|
|
67
|
-
if (
|
|
65
|
+
const isGoPreviewMatch = this.packagePath &&
|
|
66
|
+
this.packagePath === `preview/internal/${libraryJSON.name}`;
|
|
67
|
+
const isPythonPreviewMatch = this.packagePath &&
|
|
68
|
+
this.packagePath === `preview-packages/${libraryJSON.name}`;
|
|
69
|
+
if (isGoPreviewMatch || isPythonPreviewMatch) {
|
|
70
|
+
isPreview = true;
|
|
68
71
|
newVersion = this.version;
|
|
69
72
|
}
|
|
73
|
+
else {
|
|
74
|
+
const isGoMatch = (this.packagePath && libraryJSON.name === this.packagePath) ||
|
|
75
|
+
(this.component && libraryJSON.name === this.component);
|
|
76
|
+
const isPythonNodeMatch = this.packagePath &&
|
|
77
|
+
this.deriveOutputDirectory(libraryJSON) === this.packagePath;
|
|
78
|
+
if (isGoMatch || isPythonNodeMatch) {
|
|
79
|
+
newVersion = this.version;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
70
82
|
}
|
|
71
83
|
if (newVersion) {
|
|
72
84
|
const newVersionStr = newVersion.toString();
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
if (isPreview) {
|
|
86
|
+
const previewNode = this.getOrCreateSubsection(library, 'preview', doc);
|
|
87
|
+
if (this.updateValue(previewNode, 'version', newVersionStr)) {
|
|
88
|
+
modified = true;
|
|
89
|
+
}
|
|
76
90
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (yaml.isMap(java)) {
|
|
88
|
-
if (java.get('released_version') !== newVersionStr) {
|
|
89
|
-
java.set('released_version', newVersionStr);
|
|
91
|
+
else {
|
|
92
|
+
if (this.updateValue(library, 'version', newVersionStr)) {
|
|
93
|
+
modified = true;
|
|
94
|
+
}
|
|
95
|
+
if (this.versionsMap) {
|
|
96
|
+
// Multi-version (Java style): updates released_version for non-SNAPSHOTs
|
|
97
|
+
const isSnapshot = !!((_a = newVersion.preRelease) === null || _a === void 0 ? void 0 : _a.includes('SNAPSHOT'));
|
|
98
|
+
if (!isSnapshot) {
|
|
99
|
+
const javaNode = this.getOrCreateSubsection(library, 'java', doc);
|
|
100
|
+
if (this.updateValue(javaNode, 'released_version', newVersionStr)) {
|
|
90
101
|
modified = true;
|
|
91
102
|
}
|
|
92
103
|
}
|
|
@@ -115,6 +126,21 @@ class LibrarianYamlUpdater extends default_1.DefaultUpdater {
|
|
|
115
126
|
}
|
|
116
127
|
return `google-cloud-${library.name}`;
|
|
117
128
|
}
|
|
129
|
+
getOrCreateSubsection(parent, key, doc) {
|
|
130
|
+
let section = parent.get(key);
|
|
131
|
+
if (!yaml.isMap(section)) {
|
|
132
|
+
section = doc.createNode({});
|
|
133
|
+
parent.set(key, section);
|
|
134
|
+
}
|
|
135
|
+
return section;
|
|
136
|
+
}
|
|
137
|
+
updateValue(node, key, value) {
|
|
138
|
+
if (node.get(key) !== value) {
|
|
139
|
+
node.set(key, value);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
118
144
|
}
|
|
119
145
|
exports.LibrarianYamlUpdater = LibrarianYamlUpdater;
|
|
120
146
|
//# sourceMappingURL=librarian-yaml.js.map
|
|
@@ -78,6 +78,9 @@ class BranchName {
|
|
|
78
78
|
toString() {
|
|
79
79
|
return '';
|
|
80
80
|
}
|
|
81
|
+
isComponent() {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
81
84
|
}
|
|
82
85
|
exports.BranchName = BranchName;
|
|
83
86
|
/**
|
|
@@ -156,6 +159,9 @@ class V12ComponentBranchName extends BranchName {
|
|
|
156
159
|
toString() {
|
|
157
160
|
return `${RELEASE_PLEASE}/branches/${this.targetBranch}/components/${this.component}`;
|
|
158
161
|
}
|
|
162
|
+
isComponent() {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
159
165
|
}
|
|
160
166
|
const DEFAULT_PATTERN = `^${RELEASE_PLEASE}--branches--(?<branch>.+)$`;
|
|
161
167
|
class DefaultBranchName extends BranchName {
|
|
@@ -189,6 +195,9 @@ class ComponentBranchName extends BranchName {
|
|
|
189
195
|
toString() {
|
|
190
196
|
return `${RELEASE_PLEASE}--branches--${this.targetBranch}--components--${this.component}`;
|
|
191
197
|
}
|
|
198
|
+
isComponent() {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
192
201
|
}
|
|
193
202
|
const GROUP_PATTERN = `^${RELEASE_PLEASE}--branches--(?<branch>.+)--groups--(?<group>.+)$`;
|
|
194
203
|
class GroupBranchName extends BranchName {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CreatePullRequest, CreatePullRequestUserOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Add defaults to GitHub Pull Request options.
|
|
4
|
+
* Preserves the empty string.
|
|
5
|
+
* For ESCMAScript, null/undefined values are preserved for required fields.
|
|
6
|
+
* Recommended with an object validation function to check empty strings and incorrect types.
|
|
7
|
+
* @param {PullRequestUserOptions} options the user-provided github pull request options
|
|
8
|
+
* @returns {CreatePullRequest} git hub context with defaults applied
|
|
9
|
+
*/
|
|
10
|
+
export declare function addPullRequestDefaults(options: CreatePullRequestUserOptions): CreatePullRequest;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2026 Google LLC
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.addPullRequestDefaults = void 0;
|
|
17
|
+
const DEFAULT_BRANCH_NAME = 'code-suggestions';
|
|
18
|
+
const DEFAULT_PRIMARY_BRANCH = 'main';
|
|
19
|
+
/**
|
|
20
|
+
* Add defaults to GitHub Pull Request options.
|
|
21
|
+
* Preserves the empty string.
|
|
22
|
+
* For ESCMAScript, null/undefined values are preserved for required fields.
|
|
23
|
+
* Recommended with an object validation function to check empty strings and incorrect types.
|
|
24
|
+
* @param {PullRequestUserOptions} options the user-provided github pull request options
|
|
25
|
+
* @returns {CreatePullRequest} git hub context with defaults applied
|
|
26
|
+
*/
|
|
27
|
+
function addPullRequestDefaults(options) {
|
|
28
|
+
const pullRequestSettings = {
|
|
29
|
+
upstreamOwner: options.upstreamOwner,
|
|
30
|
+
upstreamRepo: options.upstreamRepo,
|
|
31
|
+
description: options.description,
|
|
32
|
+
title: options.title,
|
|
33
|
+
message: options.message,
|
|
34
|
+
force: options.force || false,
|
|
35
|
+
branch: typeof options.branch === 'string' ? options.branch : DEFAULT_BRANCH_NAME,
|
|
36
|
+
primary: typeof options.primary === 'string'
|
|
37
|
+
? options.primary
|
|
38
|
+
: DEFAULT_PRIMARY_BRANCH,
|
|
39
|
+
maintainersCanModify: options.maintainersCanModify === false ? false : true,
|
|
40
|
+
filesPerCommit: options.filesPerCommit,
|
|
41
|
+
};
|
|
42
|
+
return pullRequestSettings;
|
|
43
|
+
}
|
|
44
|
+
exports.addPullRequestDefaults = addPullRequestDefaults;
|
|
45
|
+
//# sourceMappingURL=default-options-handler.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2026 Google LLC
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.CommitError = void 0;
|
|
17
|
+
class CommitError extends Error {
|
|
18
|
+
constructor(message, cause) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.cause = cause;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.CommitError = CommitError;
|
|
24
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { RepoDomain } from '../types';
|
|
2
|
+
import { Octokit } from '@octokit/rest';
|
|
3
|
+
/**
|
|
4
|
+
* Create a new branch reference with the ref prefix
|
|
5
|
+
* @param {string} branchName name of the branch
|
|
6
|
+
*/
|
|
7
|
+
export declare function createRef(branchName: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* get branch commit HEAD SHA of a repository
|
|
10
|
+
* Throws an error if the branch cannot be found
|
|
11
|
+
* @param {Octokit} octokit The authenticated octokit instance
|
|
12
|
+
* @param {RepoDomain} origin The domain information of the remote origin repository
|
|
13
|
+
* @param {string} branch the name of the branch
|
|
14
|
+
* @returns {Promise<string>} branch commit HEAD SHA
|
|
15
|
+
*/
|
|
16
|
+
export declare function getBranchHead(octokit: Octokit, origin: RepoDomain, branch: string): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Determine if there is a branch with the provided name in the remote GitHub repository
|
|
19
|
+
* @param {Octokit} octokit The authenticated octokit instance
|
|
20
|
+
* @param {RepoDomain} remote The domain information of the remote repository
|
|
21
|
+
* @param {string} name The branch name to create on the repository
|
|
22
|
+
* @returns {Promise<boolean>} if there is a branch already existing in the remote GitHub repository
|
|
23
|
+
*/
|
|
24
|
+
export declare function existsBranchWithName(octokit: Octokit, remote: RepoDomain, name: string): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Create a branch on the remote repository if there is not an existing branch
|
|
27
|
+
* @param {Octokit} octokit The authenticated octokit instance
|
|
28
|
+
* @param {RepoDomain} remote The domain information of the remote origin repository
|
|
29
|
+
* @param {string} name The branch name to create on the origin repository
|
|
30
|
+
* @param {string} baseSha the sha that the base of the reference points to
|
|
31
|
+
* @param {boolean} duplicate whether there is an existing branch or not
|
|
32
|
+
* @returns {Promise<void>}
|
|
33
|
+
*/
|
|
34
|
+
export declare function createBranch(octokit: Octokit, remote: RepoDomain, name: string, baseSha: string, duplicate: boolean): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a GitHub branch given a remote origin.
|
|
37
|
+
* Throws an exception if octokit fails, or if the base branch is invalid
|
|
38
|
+
* @param {Octokit} octokit The authenticated octokit instance
|
|
39
|
+
* @param {RepoDomain} origin The domain information of the remote origin repository
|
|
40
|
+
* @param {RepoDomain} upstream The domain information of the remote upstream repository
|
|
41
|
+
* @param {string} name The branch name to create on the origin repository
|
|
42
|
+
* @param {string} baseBranch the name of the branch to base the new branch off of. Default is main
|
|
43
|
+
* @returns {Promise<string>} the base SHA for subsequent commits to be based off for the origin branch
|
|
44
|
+
*/
|
|
45
|
+
export declare function branch(octokit: Octokit, origin: RepoDomain, upstream: RepoDomain, name: string, baseBranch?: string): Promise<string>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2026 Google LLC
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.branch = exports.createBranch = exports.existsBranchWithName = exports.getBranchHead = exports.createRef = void 0;
|
|
17
|
+
const logger_1 = require("../logger");
|
|
18
|
+
const REF_PREFIX = 'refs/heads/';
|
|
19
|
+
const DEFAULT_PRIMARY_BRANCH = 'main';
|
|
20
|
+
/**
|
|
21
|
+
* Create a new branch reference with the ref prefix
|
|
22
|
+
* @param {string} branchName name of the branch
|
|
23
|
+
*/
|
|
24
|
+
function createRef(branchName) {
|
|
25
|
+
return REF_PREFIX + branchName;
|
|
26
|
+
}
|
|
27
|
+
exports.createRef = createRef;
|
|
28
|
+
/**
|
|
29
|
+
* get branch commit HEAD SHA of a repository
|
|
30
|
+
* Throws an error if the branch cannot be found
|
|
31
|
+
* @param {Octokit} octokit The authenticated octokit instance
|
|
32
|
+
* @param {RepoDomain} origin The domain information of the remote origin repository
|
|
33
|
+
* @param {string} branch the name of the branch
|
|
34
|
+
* @returns {Promise<string>} branch commit HEAD SHA
|
|
35
|
+
*/
|
|
36
|
+
async function getBranchHead(octokit, origin, branch) {
|
|
37
|
+
const branchData = (await octokit.repos.getBranch({
|
|
38
|
+
owner: origin.owner,
|
|
39
|
+
repo: origin.repo,
|
|
40
|
+
branch,
|
|
41
|
+
})).data;
|
|
42
|
+
logger_1.logger.info(`Successfully found branch HEAD sha "${branchData.commit.sha}".`);
|
|
43
|
+
return branchData.commit.sha;
|
|
44
|
+
}
|
|
45
|
+
exports.getBranchHead = getBranchHead;
|
|
46
|
+
/**
|
|
47
|
+
* Determine if there is a branch with the provided name in the remote GitHub repository
|
|
48
|
+
* @param {Octokit} octokit The authenticated octokit instance
|
|
49
|
+
* @param {RepoDomain} remote The domain information of the remote repository
|
|
50
|
+
* @param {string} name The branch name to create on the repository
|
|
51
|
+
* @returns {Promise<boolean>} if there is a branch already existing in the remote GitHub repository
|
|
52
|
+
*/
|
|
53
|
+
async function existsBranchWithName(octokit, remote, name) {
|
|
54
|
+
try {
|
|
55
|
+
const data = (await octokit.git.getRef({
|
|
56
|
+
owner: remote.owner,
|
|
57
|
+
repo: remote.repo,
|
|
58
|
+
ref: `heads/${name}`,
|
|
59
|
+
})).data;
|
|
60
|
+
return data.ref ? true : false;
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
if (err.status === 404)
|
|
64
|
+
return false;
|
|
65
|
+
else
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.existsBranchWithName = existsBranchWithName;
|
|
70
|
+
/**
|
|
71
|
+
* Create a branch on the remote repository if there is not an existing branch
|
|
72
|
+
* @param {Octokit} octokit The authenticated octokit instance
|
|
73
|
+
* @param {RepoDomain} remote The domain information of the remote origin repository
|
|
74
|
+
* @param {string} name The branch name to create on the origin repository
|
|
75
|
+
* @param {string} baseSha the sha that the base of the reference points to
|
|
76
|
+
* @param {boolean} duplicate whether there is an existing branch or not
|
|
77
|
+
* @returns {Promise<void>}
|
|
78
|
+
*/
|
|
79
|
+
async function createBranch(octokit, remote, name, baseSha, duplicate) {
|
|
80
|
+
if (!duplicate) {
|
|
81
|
+
const refData = (await octokit.git.createRef({
|
|
82
|
+
owner: remote.owner,
|
|
83
|
+
repo: remote.repo,
|
|
84
|
+
ref: createRef(name),
|
|
85
|
+
sha: baseSha,
|
|
86
|
+
})).data;
|
|
87
|
+
logger_1.logger.info(`Successfully created branch at ${refData.url}`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
logger_1.logger.info('Skipping branch creation step...');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.createBranch = createBranch;
|
|
94
|
+
/**
|
|
95
|
+
* Create a GitHub branch given a remote origin.
|
|
96
|
+
* Throws an exception if octokit fails, or if the base branch is invalid
|
|
97
|
+
* @param {Octokit} octokit The authenticated octokit instance
|
|
98
|
+
* @param {RepoDomain} origin The domain information of the remote origin repository
|
|
99
|
+
* @param {RepoDomain} upstream The domain information of the remote upstream repository
|
|
100
|
+
* @param {string} name The branch name to create on the origin repository
|
|
101
|
+
* @param {string} baseBranch the name of the branch to base the new branch off of. Default is main
|
|
102
|
+
* @returns {Promise<string>} the base SHA for subsequent commits to be based off for the origin branch
|
|
103
|
+
*/
|
|
104
|
+
async function branch(octokit, origin, upstream, name, baseBranch = DEFAULT_PRIMARY_BRANCH) {
|
|
105
|
+
// create branch from primary branch HEAD SHA
|
|
106
|
+
try {
|
|
107
|
+
const baseSha = await getBranchHead(octokit, upstream, baseBranch);
|
|
108
|
+
const duplicate = await existsBranchWithName(octokit, origin, name);
|
|
109
|
+
await createBranch(octokit, origin, name, baseSha, duplicate);
|
|
110
|
+
return baseSha;
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
logger_1.logger.error('Error when creating branch');
|
|
114
|
+
throw err;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.branch = branch;
|
|
118
|
+
//# sourceMappingURL=branch.js.map
|