@backstage/plugin-scaffolder-backend-module-gerrit 0.2.1-next.1 → 0.2.1
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/CHANGELOG.md +22 -0
- package/dist/actions/gerrit.cjs.js +189 -0
- package/dist/actions/gerrit.cjs.js.map +1 -0
- package/dist/actions/gerrit.examples.cjs.js +162 -0
- package/dist/actions/gerrit.examples.cjs.js.map +1 -0
- package/dist/actions/gerritReview.cjs.js +122 -0
- package/dist/actions/gerritReview.cjs.js.map +1 -0
- package/dist/actions/gerritReview.examples.cjs.js +118 -0
- package/dist/actions/gerritReview.examples.cjs.js.map +1 -0
- package/dist/index.cjs.js +6 -577
- package/dist/index.cjs.js.map +1 -1
- package/dist/module.cjs.js +30 -0
- package/dist/module.cjs.js.map +1 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend-module-gerrit
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-scaffolder-node@0.5.0
|
|
9
|
+
- @backstage/integration@1.15.1
|
|
10
|
+
- @backstage/backend-plugin-api@1.0.1
|
|
11
|
+
- @backstage/config@1.2.0
|
|
12
|
+
- @backstage/errors@1.2.4
|
|
13
|
+
|
|
14
|
+
## 0.2.1-next.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/integration@1.15.1-next.1
|
|
20
|
+
- @backstage/plugin-scaffolder-node@0.5.0-next.2
|
|
21
|
+
- @backstage/backend-plugin-api@1.0.1-next.1
|
|
22
|
+
- @backstage/config@1.2.0
|
|
23
|
+
- @backstage/errors@1.2.4
|
|
24
|
+
|
|
3
25
|
## 0.2.1-next.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var crypto = require('crypto');
|
|
4
|
+
var errors = require('@backstage/errors');
|
|
5
|
+
var integration = require('@backstage/integration');
|
|
6
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
7
|
+
var fetch = require('node-fetch');
|
|
8
|
+
var gerrit_examples = require('./gerrit.examples.cjs.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
|
|
13
|
+
var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
|
|
14
|
+
|
|
15
|
+
const createGerritProject = async (config, options) => {
|
|
16
|
+
const { projectName, parent, owner, description, defaultBranch } = options;
|
|
17
|
+
const fetchOptions = {
|
|
18
|
+
method: "PUT",
|
|
19
|
+
body: JSON.stringify({
|
|
20
|
+
parent,
|
|
21
|
+
description,
|
|
22
|
+
branches: [defaultBranch],
|
|
23
|
+
owners: owner ? [owner] : [],
|
|
24
|
+
create_empty_commit: false
|
|
25
|
+
}),
|
|
26
|
+
headers: {
|
|
27
|
+
...integration.getGerritRequestOptions(config).headers,
|
|
28
|
+
"Content-Type": "application/json"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const response = await fetch__default.default(
|
|
32
|
+
`${config.baseUrl}/a/projects/${encodeURIComponent(projectName)}`,
|
|
33
|
+
fetchOptions
|
|
34
|
+
);
|
|
35
|
+
if (response.status !== 201) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Unable to create repository, ${response.status} ${response.statusText}, ${await response.text()}`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const generateCommitMessage = (config, commitSubject) => {
|
|
42
|
+
const changeId = crypto__default.default.randomBytes(20).toString("hex");
|
|
43
|
+
const msg = `${config.getOptionalString("scaffolder.defaultCommitMessage") || commitSubject}
|
|
44
|
+
|
|
45
|
+
Change-Id: I${changeId}`;
|
|
46
|
+
return msg;
|
|
47
|
+
};
|
|
48
|
+
function createPublishGerritAction(options) {
|
|
49
|
+
const { integrations, config } = options;
|
|
50
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
51
|
+
id: "publish:gerrit",
|
|
52
|
+
supportsDryRun: true,
|
|
53
|
+
description: "Initializes a git repository of the content in the workspace, and publishes it to Gerrit.",
|
|
54
|
+
examples: gerrit_examples.examples,
|
|
55
|
+
schema: {
|
|
56
|
+
input: {
|
|
57
|
+
type: "object",
|
|
58
|
+
required: ["repoUrl"],
|
|
59
|
+
properties: {
|
|
60
|
+
repoUrl: {
|
|
61
|
+
title: "Repository Location",
|
|
62
|
+
type: "string"
|
|
63
|
+
},
|
|
64
|
+
description: {
|
|
65
|
+
title: "Repository Description",
|
|
66
|
+
type: "string"
|
|
67
|
+
},
|
|
68
|
+
defaultBranch: {
|
|
69
|
+
title: "Default Branch",
|
|
70
|
+
type: "string",
|
|
71
|
+
description: `Sets the default branch on the repository. The default value is 'master'`
|
|
72
|
+
},
|
|
73
|
+
gitCommitMessage: {
|
|
74
|
+
title: "Git Commit Message",
|
|
75
|
+
type: "string",
|
|
76
|
+
description: `Sets the commit message on the repository. The default value is 'initial commit'`
|
|
77
|
+
},
|
|
78
|
+
gitAuthorName: {
|
|
79
|
+
title: "Default Author Name",
|
|
80
|
+
type: "string",
|
|
81
|
+
description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
|
|
82
|
+
},
|
|
83
|
+
gitAuthorEmail: {
|
|
84
|
+
title: "Default Author Email",
|
|
85
|
+
type: "string",
|
|
86
|
+
description: `Sets the default author email for the commit.`
|
|
87
|
+
},
|
|
88
|
+
sourcePath: {
|
|
89
|
+
title: "Source Path",
|
|
90
|
+
type: "string",
|
|
91
|
+
description: `Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.`
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
output: {
|
|
96
|
+
type: "object",
|
|
97
|
+
properties: {
|
|
98
|
+
remoteUrl: {
|
|
99
|
+
title: "A URL to the repository with the provider",
|
|
100
|
+
type: "string"
|
|
101
|
+
},
|
|
102
|
+
repoContentsUrl: {
|
|
103
|
+
title: "A URL to the root of the repository",
|
|
104
|
+
type: "string"
|
|
105
|
+
},
|
|
106
|
+
commitHash: {
|
|
107
|
+
title: "The git commit hash of the initial commit",
|
|
108
|
+
type: "string"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
async handler(ctx) {
|
|
114
|
+
const {
|
|
115
|
+
repoUrl,
|
|
116
|
+
description,
|
|
117
|
+
defaultBranch = "master",
|
|
118
|
+
gitAuthorName,
|
|
119
|
+
gitAuthorEmail,
|
|
120
|
+
gitCommitMessage = "initial commit",
|
|
121
|
+
sourcePath
|
|
122
|
+
} = ctx.input;
|
|
123
|
+
const { repo, host, owner, workspace } = pluginScaffolderNode.parseRepoUrl(
|
|
124
|
+
repoUrl,
|
|
125
|
+
integrations
|
|
126
|
+
);
|
|
127
|
+
const integrationConfig = integrations.gerrit.byHost(host);
|
|
128
|
+
if (!integrationConfig) {
|
|
129
|
+
throw new errors.InputError(
|
|
130
|
+
`No matching integration configuration for host ${host}, please check your integrations config`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (!workspace) {
|
|
134
|
+
throw new errors.InputError(
|
|
135
|
+
`Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
const repoContentsUrl = `${integrationConfig.config.gitilesBaseUrl}/${repo}/+/refs/heads/${defaultBranch}`;
|
|
139
|
+
const remoteUrl = `${integrationConfig.config.cloneUrl}/a/${repo}`;
|
|
140
|
+
const gitName = gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name");
|
|
141
|
+
const gitEmail = gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email");
|
|
142
|
+
const commitMessage = generateCommitMessage(config, gitCommitMessage);
|
|
143
|
+
if (ctx.isDryRun) {
|
|
144
|
+
ctx.logger.info(
|
|
145
|
+
`Dry run arguments: ${{
|
|
146
|
+
gitName,
|
|
147
|
+
gitEmail,
|
|
148
|
+
commitMessage,
|
|
149
|
+
...ctx.input
|
|
150
|
+
}}`
|
|
151
|
+
);
|
|
152
|
+
ctx.output("remoteUrl", remoteUrl);
|
|
153
|
+
ctx.output("commitHash", "abcd-dry-run-1234");
|
|
154
|
+
ctx.output("repoContentsUrl", repoContentsUrl);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
await createGerritProject(integrationConfig.config, {
|
|
158
|
+
description,
|
|
159
|
+
owner,
|
|
160
|
+
projectName: repo,
|
|
161
|
+
parent: workspace,
|
|
162
|
+
defaultBranch
|
|
163
|
+
});
|
|
164
|
+
const auth = {
|
|
165
|
+
username: integrationConfig.config.username,
|
|
166
|
+
password: integrationConfig.config.password
|
|
167
|
+
};
|
|
168
|
+
const gitAuthorInfo = {
|
|
169
|
+
name: gitName,
|
|
170
|
+
email: gitEmail
|
|
171
|
+
};
|
|
172
|
+
const commitResult = await pluginScaffolderNode.initRepoAndPush({
|
|
173
|
+
dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, sourcePath),
|
|
174
|
+
remoteUrl,
|
|
175
|
+
auth,
|
|
176
|
+
defaultBranch,
|
|
177
|
+
logger: ctx.logger,
|
|
178
|
+
commitMessage: generateCommitMessage(config, gitCommitMessage),
|
|
179
|
+
gitAuthorInfo
|
|
180
|
+
});
|
|
181
|
+
ctx.output("remoteUrl", remoteUrl);
|
|
182
|
+
ctx.output("commitHash", commitResult?.commitHash);
|
|
183
|
+
ctx.output("repoContentsUrl", repoContentsUrl);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
exports.createPublishGerritAction = createPublishGerritAction;
|
|
189
|
+
//# sourceMappingURL=gerrit.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gerrit.cjs.js","sources":["../../src/actions/gerrit.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport crypto from 'crypto';\nimport { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\nimport {\n GerritIntegrationConfig,\n getGerritRequestOptions,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n initRepoAndPush,\n getRepoSourceDirectory,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport fetch, { Response, RequestInit } from 'node-fetch';\nimport { examples } from './gerrit.examples';\n\nconst createGerritProject = async (\n config: GerritIntegrationConfig,\n options: {\n projectName: string;\n parent: string;\n owner?: string;\n description: string;\n defaultBranch: string;\n },\n): Promise<void> => {\n const { projectName, parent, owner, description, defaultBranch } = options;\n\n const fetchOptions: RequestInit = {\n method: 'PUT',\n body: JSON.stringify({\n parent,\n description,\n branches: [defaultBranch],\n owners: owner ? [owner] : [],\n create_empty_commit: false,\n }),\n headers: {\n ...getGerritRequestOptions(config).headers,\n 'Content-Type': 'application/json',\n },\n };\n const response: Response = await fetch(\n `${config.baseUrl}/a/projects/${encodeURIComponent(projectName)}`,\n fetchOptions,\n );\n if (response.status !== 201) {\n throw new Error(\n `Unable to create repository, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n};\n\nconst generateCommitMessage = (\n config: Config,\n commitSubject?: string,\n): string => {\n const changeId = crypto.randomBytes(20).toString('hex');\n const msg = `${\n config.getOptionalString('scaffolder.defaultCommitMessage') || commitSubject\n }\\n\\nChange-Id: I${changeId}`;\n return msg;\n};\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to a Gerrit instance.\n * @public\n */\nexport function createPublishGerritAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description: string;\n defaultBranch?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n sourcePath?: string;\n }>({\n id: 'publish:gerrit',\n supportsDryRun: true,\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Gerrit.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n description: {\n title: 'Repository Description',\n type: 'string',\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'master'`,\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n sourcePath: {\n title: 'Source Path',\n type: 'string',\n description: `Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n defaultBranch = 'master',\n gitAuthorName,\n gitAuthorEmail,\n gitCommitMessage = 'initial commit',\n sourcePath,\n } = ctx.input;\n const { repo, host, owner, workspace } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n const integrationConfig = integrations.gerrit.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n const repoContentsUrl = `${integrationConfig.config.gitilesBaseUrl}/${repo}/+/refs/heads/${defaultBranch}`;\n const remoteUrl = `${integrationConfig.config.cloneUrl}/a/${repo}`;\n const gitName = gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name');\n const gitEmail = gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email');\n const commitMessage = generateCommitMessage(config, gitCommitMessage);\n\n if (ctx.isDryRun) {\n ctx.logger.info(\n `Dry run arguments: ${{\n gitName,\n gitEmail,\n commitMessage,\n ...ctx.input,\n }}`,\n );\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('commitHash', 'abcd-dry-run-1234');\n ctx.output('repoContentsUrl', repoContentsUrl);\n return;\n }\n\n await createGerritProject(integrationConfig.config, {\n description,\n owner: owner,\n projectName: repo,\n parent: workspace,\n defaultBranch,\n });\n const auth = {\n username: integrationConfig.config.username!,\n password: integrationConfig.config.password!,\n };\n const gitAuthorInfo = {\n name: gitName,\n email: gitEmail,\n };\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, sourcePath),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage: generateCommitMessage(config, gitCommitMessage),\n gitAuthorInfo,\n });\n\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["getGerritRequestOptions","fetch","crypto","createTemplateAction","examples","parseRepoUrl","InputError","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;;;;;;;;AAiCA,MAAM,mBAAA,GAAsB,OAC1B,MAAA,EACA,OAOkB,KAAA;AAClB,EAAA,MAAM,EAAE,WAAa,EAAA,MAAA,EAAQ,KAAO,EAAA,WAAA,EAAa,eAAkB,GAAA,OAAA,CAAA;AAEnE,EAAA,MAAM,YAA4B,GAAA;AAAA,IAChC,MAAQ,EAAA,KAAA;AAAA,IACR,IAAA,EAAM,KAAK,SAAU,CAAA;AAAA,MACnB,MAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAA,EAAU,CAAC,aAAa,CAAA;AAAA,MACxB,MAAQ,EAAA,KAAA,GAAQ,CAAC,KAAK,IAAI,EAAC;AAAA,MAC3B,mBAAqB,EAAA,KAAA;AAAA,KACtB,CAAA;AAAA,IACD,OAAS,EAAA;AAAA,MACP,GAAGA,mCAAwB,CAAA,MAAM,CAAE,CAAA,OAAA;AAAA,MACnC,cAAgB,EAAA,kBAAA;AAAA,KAClB;AAAA,GACF,CAAA;AACA,EAAA,MAAM,WAAqB,MAAMC,sBAAA;AAAA,IAC/B,GAAG,MAAO,CAAA,OAAO,CAAe,YAAA,EAAA,kBAAA,CAAmB,WAAW,CAAC,CAAA,CAAA;AAAA,IAC/D,YAAA;AAAA,GACF,CAAA;AACA,EAAI,IAAA,QAAA,CAAS,WAAW,GAAK,EAAA;AAC3B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,6BAAA,EAAgC,QAAS,CAAA,MAAM,CAC7C,CAAA,EAAA,QAAA,CAAS,UACX,CAAK,EAAA,EAAA,MAAM,QAAS,CAAA,IAAA,EAAM,CAAA,CAAA;AAAA,KAC5B,CAAA;AAAA,GACF;AACF,CAAA,CAAA;AAEA,MAAM,qBAAA,GAAwB,CAC5B,MAAA,EACA,aACW,KAAA;AACX,EAAA,MAAM,WAAWC,uBAAO,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WAAA;AAAA,QACA,KAAA;AAAA,QACA,WAAa,EAAA,IAAA;AAAA,QACb,MAAQ,EAAA,SAAA;AAAA,QACR,aAAA;AAAA,OACD,CAAA,CAAA;AACD,MAAA,MAAM,IAAO,GAAA;AAAA,QACX,QAAA,EAAU,kBAAkB,MAAO,CAAA,QAAA;AAAA,QACnC,QAAA,EAAU,kBAAkB,MAAO,CAAA,QAAA;AAAA,OACrC,CAAA;AACA,MAAA,MAAM,aAAgB,GAAA;AAAA,QACpB,IAAM,EAAA,OAAA;AAAA,QACN,KAAO,EAAA,QAAA;AAAA,OACT,CAAA;AAEA,MAAM,MAAA,YAAA,GAAe,MAAMC,oCAAgB,CAAA;AAAA,QACzC,GAAK,EAAAC,2CAAA,CAAuB,GAAI,CAAA,aAAA,EAAe,UAAU,CAAA;AAAA,QACzD,SAAA;AAAA,QACA,IAAA;AAAA,QACA,aAAA;AAAA,QACA,QAAQ,GAAI,CAAA,MAAA;AAAA,QACZ,aAAA,EAAe,qBAAsB,CAAA,MAAA,EAAQ,gBAAgB,CAAA;AAAA,QAC7D,aAAA;AAAA,OACD,CAAA,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,EAAc,UAAU,CAAA,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA,CAAA;AAAA,KAC/C;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var yaml = require('yaml');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
|
|
8
|
+
|
|
9
|
+
const examples = [
|
|
10
|
+
{
|
|
11
|
+
description: "Initializes a Gerrit repository of contents in workspace and publish it to Gerrit with default configuration.",
|
|
12
|
+
example: yaml__default.default.stringify({
|
|
13
|
+
steps: [
|
|
14
|
+
{
|
|
15
|
+
id: "publish",
|
|
16
|
+
action: "publish:gerrit",
|
|
17
|
+
name: "Publish to Gerrit",
|
|
18
|
+
input: {
|
|
19
|
+
repoUrl: "gerrit.com?repo=repo&owner=owner"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
description: "Initializes a Gerrit repository with a description.",
|
|
27
|
+
example: yaml__default.default.stringify({
|
|
28
|
+
steps: [
|
|
29
|
+
{
|
|
30
|
+
id: "publish",
|
|
31
|
+
action: "publish:gerrit",
|
|
32
|
+
name: "Publish to Gerrit",
|
|
33
|
+
input: {
|
|
34
|
+
repoUrl: "gerrit.com?repo=repo&owner=owner",
|
|
35
|
+
description: "Initialize a gerrit repository"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
})
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
description: "Initializes a Gerrit repository with a default Branch, if not set defaults to master",
|
|
43
|
+
example: yaml__default.default.stringify({
|
|
44
|
+
steps: [
|
|
45
|
+
{
|
|
46
|
+
id: "publish",
|
|
47
|
+
action: "publish:gerrit",
|
|
48
|
+
name: "Publish to Gerrit",
|
|
49
|
+
input: {
|
|
50
|
+
repoUrl: "gerrit.com?repo=repo&owner=owner",
|
|
51
|
+
defaultBranch: "staging"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
description: "Initializes a Gerrit repository with an initial commit message, if not set defaults to initial commit",
|
|
59
|
+
example: yaml__default.default.stringify({
|
|
60
|
+
steps: [
|
|
61
|
+
{
|
|
62
|
+
id: "publish",
|
|
63
|
+
action: "publish:gerrit",
|
|
64
|
+
name: "Publish to Gerrit",
|
|
65
|
+
input: {
|
|
66
|
+
repoUrl: "gerrit.com?repo=repo&owner=owner",
|
|
67
|
+
gitCommitMessage: "Initial Commit Message"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
description: "Initializes a Gerrit repository with a repo Author Name, if not set defaults to Scaffolder",
|
|
75
|
+
example: yaml__default.default.stringify({
|
|
76
|
+
steps: [
|
|
77
|
+
{
|
|
78
|
+
id: "publish",
|
|
79
|
+
action: "publish:gerrit",
|
|
80
|
+
name: "Publish to Gerrit",
|
|
81
|
+
input: {
|
|
82
|
+
repoUrl: "gerrit.com?repo=repo&owner=owner",
|
|
83
|
+
gitAuthorName: "John Doe"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
description: "Initializes a Gerrit repository with a repo Author Email",
|
|
91
|
+
example: yaml__default.default.stringify({
|
|
92
|
+
steps: [
|
|
93
|
+
{
|
|
94
|
+
id: "publish",
|
|
95
|
+
action: "publish:gerrit",
|
|
96
|
+
name: "Publish to Gerrit",
|
|
97
|
+
input: {
|
|
98
|
+
repoUrl: "gerrit.com?repo=repo&owner=owner",
|
|
99
|
+
gitAuthorEmail: "johndoe@email.com"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository",
|
|
107
|
+
example: yaml__default.default.stringify({
|
|
108
|
+
steps: [
|
|
109
|
+
{
|
|
110
|
+
id: "publish",
|
|
111
|
+
action: "publish:gerrit",
|
|
112
|
+
name: "Publish to Gerrit",
|
|
113
|
+
input: {
|
|
114
|
+
repoUrl: "gerrit.com?repo=repo&owner=owner",
|
|
115
|
+
sourcePath: "repository/"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
description: "Initializes a Gerrit repository with all proporties being set",
|
|
123
|
+
example: yaml__default.default.stringify({
|
|
124
|
+
steps: [
|
|
125
|
+
{
|
|
126
|
+
id: "publish",
|
|
127
|
+
action: "publish:gerrit",
|
|
128
|
+
name: "Publish to Gerrit",
|
|
129
|
+
input: {
|
|
130
|
+
repoUrl: "gerrit.com?repo=repo&owner=owner",
|
|
131
|
+
description: "Initialize a gerrit repository",
|
|
132
|
+
defaultBranch: "staging",
|
|
133
|
+
gitCommitMessage: "Initial Commit Message",
|
|
134
|
+
gitAuthorName: "John Doe",
|
|
135
|
+
gitAuthorEmail: "johndoe@email.com",
|
|
136
|
+
sourcePath: "repository/"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
})
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
description: "Initialize a Gerrit Repository with Custom Default Branch and Commit Message",
|
|
144
|
+
example: yaml__default.default.stringify({
|
|
145
|
+
steps: [
|
|
146
|
+
{
|
|
147
|
+
id: "publish",
|
|
148
|
+
action: "publish:gerrit",
|
|
149
|
+
name: "Publish to Gerrit",
|
|
150
|
+
input: {
|
|
151
|
+
repoUrl: "gerrit.com?repo=repo&owner=owner",
|
|
152
|
+
defaultBranch: "feature-branch",
|
|
153
|
+
gitCommitMessage: "Feature branch initialized"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
exports.examples = examples;
|
|
162
|
+
//# sourceMappingURL=gerrit.examples.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gerrit.examples.cjs.js","sources":["../../src/actions/gerrit.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a Gerrit repository of contents in workspace and publish it to Gerrit with default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Gerrit repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n description: 'Initialize a gerrit repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gerrit repository with a default Branch, if not set defaults to master',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n defaultBranch: 'staging',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gerrit repository with an initial commit message, if not set defaults to initial commit',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n gitCommitMessage: 'Initial Commit Message',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gerrit repository with a repo Author Name, if not set defaults to Scaffolder',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n gitAuthorName: 'John Doe',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Gerrit repository with a repo Author Email',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n gitAuthorEmail: 'johndoe@email.com',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n sourcePath: 'repository/',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Gerrit repository with all proporties being set',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n description: 'Initialize a gerrit repository',\n defaultBranch: 'staging',\n gitCommitMessage: 'Initial Commit Message',\n gitAuthorName: 'John Doe',\n gitAuthorEmail: 'johndoe@email.com',\n sourcePath: 'repository/',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initialize a Gerrit Repository with Custom Default Branch and Commit Message',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:gerrit',\n name: 'Publish to Gerrit',\n input: {\n repoUrl: 'gerrit.com?repo=repo&owner=owner',\n defaultBranch: 'feature-branch',\n gitCommitMessage: 'Feature branch initialized',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,+GAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,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ACR,IAAM,EAAA,mBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,WAAa,EAAA,gCAAA;AAAA,YACb,aAAe,EAAA,SAAA;AAAA,YACf,gBAAkB,EAAA,wBAAA;AAAA,YAClB,aAAe,EAAA,UAAA;AAAA,YACf,cAAgB,EAAA,mBAAA;AAAA,YAChB,UAAY,EAAA,aAAA;AAAA,WACd;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,8EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,gBAAA;AAAA,UACR,IAAM,EAAA,mBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,aAAe,EAAA,gBAAA;AAAA,YACf,gBAAkB,EAAA,4BAAA;AAAA,WACpB;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AACF;;;;"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var crypto = require('crypto');
|
|
4
|
+
var errors = require('@backstage/errors');
|
|
5
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
6
|
+
var gerritReview_examples = require('./gerritReview.examples.cjs.js');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
|
|
11
|
+
|
|
12
|
+
const generateGerritChangeId = () => {
|
|
13
|
+
const changeId = crypto__default.default.randomBytes(20).toString("hex");
|
|
14
|
+
return `I${changeId}`;
|
|
15
|
+
};
|
|
16
|
+
function createPublishGerritReviewAction(options) {
|
|
17
|
+
const { integrations, config } = options;
|
|
18
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
19
|
+
id: "publish:gerrit:review",
|
|
20
|
+
description: "Creates a new Gerrit review.",
|
|
21
|
+
examples: gerritReview_examples.examples,
|
|
22
|
+
schema: {
|
|
23
|
+
input: {
|
|
24
|
+
type: "object",
|
|
25
|
+
required: ["repoUrl", "gitCommitMessage"],
|
|
26
|
+
properties: {
|
|
27
|
+
repoUrl: {
|
|
28
|
+
title: "Repository Location",
|
|
29
|
+
type: "string"
|
|
30
|
+
},
|
|
31
|
+
branch: {
|
|
32
|
+
title: "Repository branch",
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Branch of the repository the review will be created on"
|
|
35
|
+
},
|
|
36
|
+
sourcePath: {
|
|
37
|
+
type: "string",
|
|
38
|
+
title: "Working Subdirectory",
|
|
39
|
+
description: "Subdirectory of working directory containing the repository"
|
|
40
|
+
},
|
|
41
|
+
gitCommitMessage: {
|
|
42
|
+
title: "Git Commit Message",
|
|
43
|
+
type: "string",
|
|
44
|
+
description: `Sets the commit message on the repository.`
|
|
45
|
+
},
|
|
46
|
+
gitAuthorName: {
|
|
47
|
+
title: "Default Author Name",
|
|
48
|
+
type: "string",
|
|
49
|
+
description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
|
|
50
|
+
},
|
|
51
|
+
gitAuthorEmail: {
|
|
52
|
+
title: "Default Author Email",
|
|
53
|
+
type: "string",
|
|
54
|
+
description: `Sets the default author email for the commit.`
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
output: {
|
|
59
|
+
type: "object",
|
|
60
|
+
properties: {
|
|
61
|
+
reviewUrl: {
|
|
62
|
+
title: "A URL to the review",
|
|
63
|
+
type: "string"
|
|
64
|
+
},
|
|
65
|
+
repoContentsUrl: {
|
|
66
|
+
title: "A URL to the root of the repository",
|
|
67
|
+
type: "string"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
async handler(ctx) {
|
|
73
|
+
const {
|
|
74
|
+
repoUrl,
|
|
75
|
+
branch = "master",
|
|
76
|
+
sourcePath,
|
|
77
|
+
gitAuthorName,
|
|
78
|
+
gitAuthorEmail,
|
|
79
|
+
gitCommitMessage
|
|
80
|
+
} = ctx.input;
|
|
81
|
+
const { host, repo } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
82
|
+
if (!gitCommitMessage) {
|
|
83
|
+
throw new errors.InputError(`Missing gitCommitMessage input`);
|
|
84
|
+
}
|
|
85
|
+
const integrationConfig = integrations.gerrit.byHost(host);
|
|
86
|
+
if (!integrationConfig) {
|
|
87
|
+
throw new errors.InputError(
|
|
88
|
+
`No matching integration configuration for host ${host}, please check your integrations config`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const auth = {
|
|
92
|
+
username: integrationConfig.config.username,
|
|
93
|
+
password: integrationConfig.config.password
|
|
94
|
+
};
|
|
95
|
+
const gitAuthorInfo = {
|
|
96
|
+
name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
|
|
97
|
+
email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
|
|
98
|
+
};
|
|
99
|
+
const changeId = generateGerritChangeId();
|
|
100
|
+
const commitMessage = `${gitCommitMessage}
|
|
101
|
+
|
|
102
|
+
Change-Id: ${changeId}`;
|
|
103
|
+
await pluginScaffolderNode.commitAndPushRepo({
|
|
104
|
+
dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, sourcePath),
|
|
105
|
+
auth,
|
|
106
|
+
logger: ctx.logger,
|
|
107
|
+
commitMessage,
|
|
108
|
+
gitAuthorInfo,
|
|
109
|
+
branch,
|
|
110
|
+
remoteRef: `refs/for/${branch}`
|
|
111
|
+
});
|
|
112
|
+
const repoContentsUrl = `${integrationConfig.config.gitilesBaseUrl}/${repo}/+/refs/heads/${branch}`;
|
|
113
|
+
const reviewUrl = `${integrationConfig.config.baseUrl}/#/q/${changeId}`;
|
|
114
|
+
ctx.logger?.info(`Review available on ${reviewUrl}`);
|
|
115
|
+
ctx.output("repoContentsUrl", repoContentsUrl);
|
|
116
|
+
ctx.output("reviewUrl", reviewUrl);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
exports.createPublishGerritReviewAction = createPublishGerritReviewAction;
|
|
122
|
+
//# sourceMappingURL=gerritReview.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gerritReview.cjs.js","sources":["../../src/actions/gerritReview.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport crypto from 'crypto';\nimport { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n commitAndPushRepo,\n getRepoSourceDirectory,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { examples } from './gerritReview.examples';\n\nconst generateGerritChangeId = (): string => {\n const changeId = crypto.randomBytes(20).toString('hex');\n return `I${changeId}`;\n};\n\n/**\n * Creates a new action that creates a Gerrit review\n * @public\n */\nexport function createPublishGerritReviewAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n branch?: string;\n sourcePath?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n }>({\n id: 'publish:gerrit:review',\n description: 'Creates a new Gerrit review.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'gitCommitMessage'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n branch: {\n title: 'Repository branch',\n type: 'string',\n description:\n 'Branch of the repository the review will be created on',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory containing the repository',\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository.`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n reviewUrl: {\n title: 'A URL to the review',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branch = 'master',\n sourcePath,\n gitAuthorName,\n gitAuthorEmail,\n gitCommitMessage,\n } = ctx.input;\n const { host, repo } = parseRepoUrl(repoUrl, integrations);\n\n if (!gitCommitMessage) {\n throw new InputError(`Missing gitCommitMessage input`);\n }\n\n const integrationConfig = integrations.gerrit.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const auth = {\n username: integrationConfig.config.username!,\n password: integrationConfig.config.password!,\n };\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n const changeId = generateGerritChangeId();\n const commitMessage = `${gitCommitMessage}\\n\\nChange-Id: ${changeId}`;\n\n await commitAndPushRepo({\n dir: getRepoSourceDirectory(ctx.workspacePath, sourcePath),\n auth,\n logger: ctx.logger,\n commitMessage,\n gitAuthorInfo,\n branch,\n remoteRef: `refs/for/${branch}`,\n });\n\n const repoContentsUrl = `${integrationConfig.config.gitilesBaseUrl}/${repo}/+/refs/heads/${branch}`;\n const reviewUrl = `${integrationConfig.config.baseUrl}/#/q/${changeId}`;\n ctx.logger?.info(`Review available on ${reviewUrl}`);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('reviewUrl', reviewUrl);\n },\n });\n}\n"],"names":["crypto","createTemplateAction","examples","parseRepoUrl","InputError","commitAndPushRepo","getRepoSourceDirectory"],"mappings":";;;;;;;;;;;AA4BA,MAAM,yBAAyB,MAAc;AAC3C,EAAA,MAAM,WAAWA,uBAAO,CAAA,WAAA,CAAY,EAAE,CAAA,CAAE,SAAS,KAAK,CAAA,CAAA;AACtD,EAAA,OAAO,IAAI,QAAQ,CAAA,CAAA,CAAA;AACrB,CAAA,CAAA;AAMO,SAAS,gCAAgC,OAG7C,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,MAAA,EAAW,GAAA,OAAA,CAAA;AAEjC,EAAA,OAAOC,yCAOJ,CAAA;AAAA,IACD,EAAI,EAAA,uBAAA;AAAA,IACJ,WAAa,EAAA,8BAAA;AAAA,cACbC,8BAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAA,EAAW,kBAAkB,CAAA;AAAA,QACxC,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,MAAQ,EAAA;AAAA,YACN,KAAO,EAAA,mBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WACE,EAAA,wDAAA;AAAA,WACJ;AAAA,UACA,UAAY,EAAA;AAAA,YACV,IAAM,EAAA,QAAA;AAAA,YACN,KAAO,EAAA,sBAAA;AAAA,Y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