@release-please-oss/release-please 0.0.0 → 17.11.3

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.
Files changed (310) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +280 -0
  3. package/build/src/bin/release-please.d.ts +22 -0
  4. package/build/src/bin/release-please.js +727 -0
  5. package/build/src/bootstrapper.d.ts +18 -0
  6. package/build/src/bootstrapper.js +64 -0
  7. package/build/src/changelog-notes/default.d.ts +15 -0
  8. package/build/src/changelog-notes/default.js +96 -0
  9. package/build/src/changelog-notes/github.d.ts +8 -0
  10. package/build/src/changelog-notes/github.js +29 -0
  11. package/build/src/changelog-notes.d.ts +22 -0
  12. package/build/src/changelog-notes.js +40 -0
  13. package/build/src/commit.d.ts +33 -0
  14. package/build/src/commit.js +422 -0
  15. package/build/src/errors/index.d.ts +36 -0
  16. package/build/src/errors/index.js +77 -0
  17. package/build/src/factories/changelog-notes-factory.d.ts +16 -0
  18. package/build/src/factories/changelog-notes-factory.js +44 -0
  19. package/build/src/factories/plugin-factory.d.ts +23 -0
  20. package/build/src/factories/plugin-factory.js +94 -0
  21. package/build/src/factories/versioning-strategy-factory.d.ts +16 -0
  22. package/build/src/factories/versioning-strategy-factory.js +52 -0
  23. package/build/src/factory.d.ts +18 -0
  24. package/build/src/factory.js +161 -0
  25. package/build/src/github-api.d.ts +260 -0
  26. package/build/src/github-api.js +714 -0
  27. package/build/src/github.d.ts +306 -0
  28. package/build/src/github.js +769 -0
  29. package/build/src/index.d.ts +17 -0
  30. package/build/src/index.js +41 -0
  31. package/build/src/local-github.d.ts +270 -0
  32. package/build/src/local-github.js +756 -0
  33. package/build/src/manifest.d.ts +370 -0
  34. package/build/src/manifest.js +1142 -0
  35. package/build/src/plugin.d.ts +37 -0
  36. package/build/src/plugin.js +57 -0
  37. package/build/src/plugins/cargo-workspace.d.ts +58 -0
  38. package/build/src/plugins/cargo-workspace.js +339 -0
  39. package/build/src/plugins/group-priority.d.ts +29 -0
  40. package/build/src/plugins/group-priority.js +82 -0
  41. package/build/src/plugins/linked-versions.d.ts +36 -0
  42. package/build/src/plugins/linked-versions.js +137 -0
  43. package/build/src/plugins/maven-workspace.d.ts +81 -0
  44. package/build/src/plugins/maven-workspace.js +431 -0
  45. package/build/src/plugins/merge.d.ts +27 -0
  46. package/build/src/plugins/merge.js +99 -0
  47. package/build/src/plugins/node-workspace.d.ts +50 -0
  48. package/build/src/plugins/node-workspace.js +352 -0
  49. package/build/src/plugins/sentence-case.d.ts +19 -0
  50. package/build/src/plugins/sentence-case.js +80 -0
  51. package/build/src/plugins/workspace.d.ts +173 -0
  52. package/build/src/plugins/workspace.js +308 -0
  53. package/build/src/pull-request.d.ts +11 -0
  54. package/build/src/pull-request.js +16 -0
  55. package/build/src/release-pull-request.d.ts +14 -0
  56. package/build/src/release-pull-request.js +16 -0
  57. package/build/src/release.d.ts +7 -0
  58. package/build/src/release.js +16 -0
  59. package/build/src/repository.d.ts +5 -0
  60. package/build/src/repository.js +16 -0
  61. package/build/src/scm.d.ts +80 -0
  62. package/build/src/scm.js +16 -0
  63. package/build/src/strategies/base.d.ts +162 -0
  64. package/build/src/strategies/base.js +494 -0
  65. package/build/src/strategies/bazel.d.ts +7 -0
  66. package/build/src/strategies/bazel.js +49 -0
  67. package/build/src/strategies/dart.d.ts +8 -0
  68. package/build/src/strategies/dart.js +73 -0
  69. package/build/src/strategies/dotnet-yoshi.d.ts +13 -0
  70. package/build/src/strategies/dotnet-yoshi.js +109 -0
  71. package/build/src/strategies/elixir.d.ts +5 -0
  72. package/build/src/strategies/elixir.js +46 -0
  73. package/build/src/strategies/expo.d.ts +15 -0
  74. package/build/src/strategies/expo.js +51 -0
  75. package/build/src/strategies/go-librarian.d.ts +11 -0
  76. package/build/src/strategies/go-librarian.js +84 -0
  77. package/build/src/strategies/go-yoshi.d.ts +14 -0
  78. package/build/src/strategies/go-yoshi.js +168 -0
  79. package/build/src/strategies/go.d.ts +7 -0
  80. package/build/src/strategies/go.js +53 -0
  81. package/build/src/strategies/helm.d.ts +8 -0
  82. package/build/src/strategies/helm.js +73 -0
  83. package/build/src/strategies/java-yoshi-mono-repo.d.ts +22 -0
  84. package/build/src/strategies/java-yoshi-mono-repo.js +308 -0
  85. package/build/src/strategies/java-yoshi.d.ts +20 -0
  86. package/build/src/strategies/java-yoshi.js +210 -0
  87. package/build/src/strategies/java.d.ts +28 -0
  88. package/build/src/strategies/java.js +176 -0
  89. package/build/src/strategies/krm-blueprint.d.ts +7 -0
  90. package/build/src/strategies/krm-blueprint.js +65 -0
  91. package/build/src/strategies/maven.d.ts +9 -0
  92. package/build/src/strategies/maven.js +56 -0
  93. package/build/src/strategies/node-librarian.d.ts +10 -0
  94. package/build/src/strategies/node-librarian.js +121 -0
  95. package/build/src/strategies/node.d.ts +10 -0
  96. package/build/src/strategies/node.js +111 -0
  97. package/build/src/strategies/ocaml.d.ts +5 -0
  98. package/build/src/strategies/ocaml.js +86 -0
  99. package/build/src/strategies/php-librarian.d.ts +6 -0
  100. package/build/src/strategies/php-librarian.js +35 -0
  101. package/build/src/strategies/php-yoshi.d.ts +13 -0
  102. package/build/src/strategies/php-yoshi.js +255 -0
  103. package/build/src/strategies/php.d.ts +6 -0
  104. package/build/src/strategies/php.js +76 -0
  105. package/build/src/strategies/python-librarian.d.ts +6 -0
  106. package/build/src/strategies/python-librarian.js +35 -0
  107. package/build/src/strategies/python.d.ts +11 -0
  108. package/build/src/strategies/python.js +175 -0
  109. package/build/src/strategies/r.d.ts +8 -0
  110. package/build/src/strategies/r.js +67 -0
  111. package/build/src/strategies/ruby-librarian.d.ts +6 -0
  112. package/build/src/strategies/ruby-librarian.js +35 -0
  113. package/build/src/strategies/ruby-yoshi.d.ts +13 -0
  114. package/build/src/strategies/ruby-yoshi.js +97 -0
  115. package/build/src/strategies/ruby.d.ts +9 -0
  116. package/build/src/strategies/ruby.js +71 -0
  117. package/build/src/strategies/rust.d.ts +17 -0
  118. package/build/src/strategies/rust.js +149 -0
  119. package/build/src/strategies/sfdx.d.ts +9 -0
  120. package/build/src/strategies/sfdx.js +67 -0
  121. package/build/src/strategies/simple.d.ts +7 -0
  122. package/build/src/strategies/simple.js +51 -0
  123. package/build/src/strategies/terraform-module.d.ts +7 -0
  124. package/build/src/strategies/terraform-module.js +90 -0
  125. package/build/src/strategy.d.ts +68 -0
  126. package/build/src/strategy.js +16 -0
  127. package/build/src/update.d.ts +24 -0
  128. package/build/src/update.js +16 -0
  129. package/build/src/updaters/base-xml.d.ts +19 -0
  130. package/build/src/updaters/base-xml.js +43 -0
  131. package/build/src/updaters/bazel/module-bazel.d.ts +7 -0
  132. package/build/src/updaters/bazel/module-bazel.js +33 -0
  133. package/build/src/updaters/changelog-json.d.ts +29 -0
  134. package/build/src/updaters/changelog-json.js +100 -0
  135. package/build/src/updaters/changelog.d.ts +13 -0
  136. package/build/src/updaters/changelog.js +55 -0
  137. package/build/src/updaters/composite.d.ts +20 -0
  138. package/build/src/updaters/composite.js +65 -0
  139. package/build/src/updaters/dart/pubspec-yaml.d.ts +13 -0
  140. package/build/src/updaters/dart/pubspec-yaml.js +50 -0
  141. package/build/src/updaters/default.d.ts +21 -0
  142. package/build/src/updaters/default.js +36 -0
  143. package/build/src/updaters/dotnet/apis.d.ts +18 -0
  144. package/build/src/updaters/dotnet/apis.js +45 -0
  145. package/build/src/updaters/dotnet/csproj.d.ts +12 -0
  146. package/build/src/updaters/dotnet/csproj.js +33 -0
  147. package/build/src/updaters/elixir/elixir-mix-exs.d.ts +13 -0
  148. package/build/src/updaters/elixir/elixir-mix-exs.js +42 -0
  149. package/build/src/updaters/expo/app-json.d.ts +31 -0
  150. package/build/src/updaters/expo/app-json.js +67 -0
  151. package/build/src/updaters/generic-json.d.ts +14 -0
  152. package/build/src/updaters/generic-json.js +54 -0
  153. package/build/src/updaters/generic-toml.d.ts +21 -0
  154. package/build/src/updaters/generic-toml.js +66 -0
  155. package/build/src/updaters/generic-xml.d.ts +8 -0
  156. package/build/src/updaters/generic-xml.js +38 -0
  157. package/build/src/updaters/generic-yaml.d.ts +23 -0
  158. package/build/src/updaters/generic-yaml.js +85 -0
  159. package/build/src/updaters/generic.d.ts +54 -0
  160. package/build/src/updaters/generic.js +187 -0
  161. package/build/src/updaters/go/version-go.d.ts +4 -0
  162. package/build/src/updaters/go/version-go.js +24 -0
  163. package/build/src/updaters/helm/chart-yaml.d.ts +13 -0
  164. package/build/src/updaters/helm/chart-yaml.js +41 -0
  165. package/build/src/updaters/java/java-released.d.ts +28 -0
  166. package/build/src/updaters/java/java-released.js +59 -0
  167. package/build/src/updaters/java/java-update.d.ts +21 -0
  168. package/build/src/updaters/java/java-update.js +80 -0
  169. package/build/src/updaters/java/pom-xml.d.ts +29 -0
  170. package/build/src/updaters/java/pom-xml.js +135 -0
  171. package/build/src/updaters/java/versions-manifest.d.ts +19 -0
  172. package/build/src/updaters/java/versions-manifest.js +71 -0
  173. package/build/src/updaters/krm/krm-blueprint-version.d.ts +13 -0
  174. package/build/src/updaters/krm/krm-blueprint-version.js +46 -0
  175. package/build/src/updaters/librarian-yaml.d.ts +45 -0
  176. package/build/src/updaters/librarian-yaml.js +149 -0
  177. package/build/src/updaters/node/package-json.d.ts +46 -0
  178. package/build/src/updaters/node/package-json.js +106 -0
  179. package/build/src/updaters/node/package-lock-json.d.ts +14 -0
  180. package/build/src/updaters/node/package-lock-json.js +83 -0
  181. package/build/src/updaters/node/samples-package-json.d.ts +24 -0
  182. package/build/src/updaters/node/samples-package-json.js +49 -0
  183. package/build/src/updaters/ocaml/dune-project.d.ts +13 -0
  184. package/build/src/updaters/ocaml/dune-project.js +37 -0
  185. package/build/src/updaters/ocaml/esy-json.d.ts +13 -0
  186. package/build/src/updaters/ocaml/esy-json.js +37 -0
  187. package/build/src/updaters/ocaml/opam.d.ts +13 -0
  188. package/build/src/updaters/ocaml/opam.js +37 -0
  189. package/build/src/updaters/php/php-client-version.d.ts +12 -0
  190. package/build/src/updaters/php/php-client-version.js +32 -0
  191. package/build/src/updaters/php/root-composer-update-packages.d.ts +13 -0
  192. package/build/src/updaters/php/root-composer-update-packages.js +60 -0
  193. package/build/src/updaters/python/pyproject-toml.d.ts +29 -0
  194. package/build/src/updaters/python/pyproject-toml.js +53 -0
  195. package/build/src/updaters/python/python-file-with-version.d.ts +12 -0
  196. package/build/src/updaters/python/python-file-with-version.js +32 -0
  197. package/build/src/updaters/python/setup-cfg.d.ts +12 -0
  198. package/build/src/updaters/python/setup-cfg.js +32 -0
  199. package/build/src/updaters/python/setup-py.d.ts +12 -0
  200. package/build/src/updaters/python/setup-py.js +32 -0
  201. package/build/src/updaters/r/description.d.ts +12 -0
  202. package/build/src/updaters/r/description.js +32 -0
  203. package/build/src/updaters/r/news.d.ts +12 -0
  204. package/build/src/updaters/r/news.js +49 -0
  205. package/build/src/updaters/raw-content.d.ts +19 -0
  206. package/build/src/updaters/raw-content.js +39 -0
  207. package/build/src/updaters/release-please-config.d.ts +8 -0
  208. package/build/src/updaters/release-please-config.js +80 -0
  209. package/build/src/updaters/release-please-manifest.d.ts +4 -0
  210. package/build/src/updaters/release-please-manifest.js +34 -0
  211. package/build/src/updaters/ruby/common.d.ts +17 -0
  212. package/build/src/updaters/ruby/common.js +46 -0
  213. package/build/src/updaters/ruby/gemfile-lock.d.ts +24 -0
  214. package/build/src/updaters/ruby/gemfile-lock.js +53 -0
  215. package/build/src/updaters/ruby/version-rb.d.ts +12 -0
  216. package/build/src/updaters/ruby/version-rb.js +34 -0
  217. package/build/src/updaters/rust/cargo-lock.d.ts +16 -0
  218. package/build/src/updaters/rust/cargo-lock.js +64 -0
  219. package/build/src/updaters/rust/cargo-toml.d.ts +13 -0
  220. package/build/src/updaters/rust/cargo-toml.js +89 -0
  221. package/build/src/updaters/rust/common.d.ts +54 -0
  222. package/build/src/updaters/rust/common.js +35 -0
  223. package/build/src/updaters/sfdx/sfdx-project-json.d.ts +21 -0
  224. package/build/src/updaters/sfdx/sfdx-project-json.js +41 -0
  225. package/build/src/updaters/terraform/metadata-version.d.ts +13 -0
  226. package/build/src/updaters/terraform/metadata-version.js +37 -0
  227. package/build/src/updaters/terraform/module-version.d.ts +13 -0
  228. package/build/src/updaters/terraform/module-version.js +37 -0
  229. package/build/src/updaters/terraform/readme.d.ts +12 -0
  230. package/build/src/updaters/terraform/readme.js +32 -0
  231. package/build/src/util/branch-name.d.ts +20 -0
  232. package/build/src/util/branch-name.js +225 -0
  233. package/build/src/util/code-suggester/default-options-handler.d.ts +10 -0
  234. package/build/src/util/code-suggester/default-options-handler.js +45 -0
  235. package/build/src/util/code-suggester/errors.d.ts +4 -0
  236. package/build/src/util/code-suggester/errors.js +24 -0
  237. package/build/src/util/code-suggester/github/branch.d.ts +45 -0
  238. package/build/src/util/code-suggester/github/branch.js +118 -0
  239. package/build/src/util/code-suggester/github/commit-and-push.d.ts +51 -0
  240. package/build/src/util/code-suggester/github/commit-and-push.js +141 -0
  241. package/build/src/util/code-suggester/github/create-commit.d.ts +20 -0
  242. package/build/src/util/code-suggester/github/create-commit.js +60 -0
  243. package/build/src/util/code-suggester/github/fork.d.ts +15 -0
  244. package/build/src/util/code-suggester/github/fork.js +48 -0
  245. package/build/src/util/code-suggester/github/labels.d.ts +14 -0
  246. package/build/src/util/code-suggester/github/labels.js +42 -0
  247. package/build/src/util/code-suggester/github/open-pull-request.d.ts +16 -0
  248. package/build/src/util/code-suggester/github/open-pull-request.js +56 -0
  249. package/build/src/util/code-suggester/index.d.ts +28 -0
  250. package/build/src/util/code-suggester/index.js +110 -0
  251. package/build/src/util/code-suggester/logger.d.ts +4 -0
  252. package/build/src/util/code-suggester/logger.js +37 -0
  253. package/build/src/util/code-suggester/types.d.ts +109 -0
  254. package/build/src/util/code-suggester/types.js +30 -0
  255. package/build/src/util/coerce-option.d.ts +1 -0
  256. package/build/src/util/coerce-option.js +40 -0
  257. package/build/src/util/commit-exclude.d.ts +10 -0
  258. package/build/src/util/commit-exclude.js +49 -0
  259. package/build/src/util/commit-split.d.ts +26 -0
  260. package/build/src/util/commit-split.js +100 -0
  261. package/build/src/util/commit-utils.d.ts +1 -0
  262. package/build/src/util/commit-utils.js +34 -0
  263. package/build/src/util/filter-commits.d.ts +12 -0
  264. package/build/src/util/filter-commits.js +59 -0
  265. package/build/src/util/indent-commit.d.ts +2 -0
  266. package/build/src/util/indent-commit.js +39 -0
  267. package/build/src/util/json-stringify.d.ts +1 -0
  268. package/build/src/util/json-stringify.js +22 -0
  269. package/build/src/util/logger.d.ts +24 -0
  270. package/build/src/util/logger.js +54 -0
  271. package/build/src/util/pull-request-body.d.ts +25 -0
  272. package/build/src/util/pull-request-body.js +147 -0
  273. package/build/src/util/pull-request-overflow-handler.d.ts +54 -0
  274. package/build/src/util/pull-request-overflow-handler.js +78 -0
  275. package/build/src/util/pull-request-title.d.ts +22 -0
  276. package/build/src/util/pull-request-title.js +146 -0
  277. package/build/src/util/signoff-commit-message.d.ts +1 -0
  278. package/build/src/util/signoff-commit-message.js +35 -0
  279. package/build/src/util/tag-name.d.ts +10 -0
  280. package/build/src/util/tag-name.js +42 -0
  281. package/build/src/util/toml-edit.d.ts +16 -0
  282. package/build/src/util/toml-edit.js +126 -0
  283. package/build/src/version.d.ts +35 -0
  284. package/build/src/version.js +74 -0
  285. package/build/src/versioning-strategies/always-bump-major.d.ts +10 -0
  286. package/build/src/versioning-strategies/always-bump-major.js +28 -0
  287. package/build/src/versioning-strategies/always-bump-minor.d.ts +10 -0
  288. package/build/src/versioning-strategies/always-bump-minor.js +28 -0
  289. package/build/src/versioning-strategies/always-bump-patch.d.ts +11 -0
  290. package/build/src/versioning-strategies/always-bump-patch.js +29 -0
  291. package/build/src/versioning-strategies/default.d.ts +48 -0
  292. package/build/src/versioning-strategies/default.js +102 -0
  293. package/build/src/versioning-strategies/dependency-manifest.d.ts +15 -0
  294. package/build/src/versioning-strategies/dependency-manifest.js +103 -0
  295. package/build/src/versioning-strategies/java-add-snapshot.d.ts +13 -0
  296. package/build/src/versioning-strategies/java-add-snapshot.js +54 -0
  297. package/build/src/versioning-strategies/java-snapshot.d.ts +13 -0
  298. package/build/src/versioning-strategies/java-snapshot.js +70 -0
  299. package/build/src/versioning-strategies/prerelease.d.ts +20 -0
  300. package/build/src/versioning-strategies/prerelease.js +163 -0
  301. package/build/src/versioning-strategies/service-pack.d.ts +12 -0
  302. package/build/src/versioning-strategies/service-pack.js +47 -0
  303. package/build/src/versioning-strategy.d.ts +90 -0
  304. package/build/src/versioning-strategy.js +82 -0
  305. package/package.json +113 -4
  306. package/schemas/config.json +513 -0
  307. package/schemas/manifest.json +9 -0
  308. package/templates/commit.hbs +2 -0
  309. package/templates/header.hbs +9 -0
  310. package/templates/template.hbs +19 -0
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ // Copyright 2021 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
+ // http://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.BranchName = void 0;
17
+ const version_1 = require("../version");
18
+ const logger_1 = require("./logger");
19
+ // cannot import from '..' - transpiled code references to RELEASE_PLEASE
20
+ // at the script level are undefined, they are only defined inside function
21
+ // or instance methods/properties.
22
+ // import {RELEASE_PLEASE} from '../constants';
23
+ const RELEASE_PLEASE = 'release-please';
24
+ function getAllResourceNames() {
25
+ return [
26
+ AutoreleaseBranchName,
27
+ ComponentBranchName,
28
+ GroupBranchName,
29
+ DefaultBranchName,
30
+ V12ComponentBranchName,
31
+ V12DefaultBranchName,
32
+ ];
33
+ }
34
+ class BranchName {
35
+ static parse(branchName, logger = logger_1.logger) {
36
+ try {
37
+ const branchNameClass = getAllResourceNames().find(clazz => {
38
+ return clazz.matches(branchName);
39
+ });
40
+ if (!branchNameClass) {
41
+ return undefined;
42
+ }
43
+ return new branchNameClass(branchName);
44
+ }
45
+ catch (e) {
46
+ logger.warn(`Error parsing branch name: ${branchName}`, e);
47
+ return undefined;
48
+ }
49
+ }
50
+ static ofComponentVersion(branchPrefix, version) {
51
+ return new AutoreleaseBranchName(`release-${branchPrefix}-v${version}`);
52
+ }
53
+ static ofVersion(version) {
54
+ return new AutoreleaseBranchName(`release-v${version}`);
55
+ }
56
+ static ofTargetBranch(targetBranch) {
57
+ return new DefaultBranchName(`${RELEASE_PLEASE}--branches--${targetBranch}`);
58
+ }
59
+ static ofComponentTargetBranch(component, targetBranch) {
60
+ return new ComponentBranchName(`${RELEASE_PLEASE}--branches--${targetBranch}--components--${component}`);
61
+ }
62
+ static ofGroupTargetBranch(group, targetBranch) {
63
+ return new GroupBranchName(`${RELEASE_PLEASE}--branches--${targetBranch}--groups--${safeBranchName(group)}`);
64
+ }
65
+ constructor(_branchName) { }
66
+ static matches(_branchName) {
67
+ return false;
68
+ }
69
+ getTargetBranch() {
70
+ return this.targetBranch;
71
+ }
72
+ getComponent() {
73
+ return this.component;
74
+ }
75
+ getVersion() {
76
+ return this.version;
77
+ }
78
+ toString() {
79
+ return '';
80
+ }
81
+ isComponent() {
82
+ return false;
83
+ }
84
+ }
85
+ exports.BranchName = BranchName;
86
+ /**
87
+ * This is the legacy branch pattern used by releasetool
88
+ *
89
+ * @see https://github.com/googleapis/releasetool
90
+ */
91
+ const AUTORELEASE_PATTERN = /^release-?(?<component>[\w-.]*)?-v(?<version>[0-9].*)$/;
92
+ const RELEASE_PLEASE_BRANCH_PREFIX = 'release-please--branches';
93
+ class AutoreleaseBranchName extends BranchName {
94
+ static matches(branchName) {
95
+ if (branchName.startsWith(RELEASE_PLEASE_BRANCH_PREFIX)) {
96
+ return false;
97
+ }
98
+ return !!branchName.match(AUTORELEASE_PATTERN);
99
+ }
100
+ constructor(branchName) {
101
+ super(branchName);
102
+ const match = branchName.match(AUTORELEASE_PATTERN);
103
+ if (match === null || match === void 0 ? void 0 : match.groups) {
104
+ this.component = match.groups['component'];
105
+ this.version = version_1.Version.parse(match.groups['version']);
106
+ }
107
+ }
108
+ toString() {
109
+ var _a, _b;
110
+ if (this.component) {
111
+ return `release-${this.component}-v${(_a = this.version) === null || _a === void 0 ? void 0 : _a.toString()}`;
112
+ }
113
+ return `release-v${(_b = this.version) === null || _b === void 0 ? void 0 : _b.toString()}`;
114
+ }
115
+ }
116
+ /**
117
+ * This is a parsable branch pattern used by release-please v12.
118
+ * It has potential issues due to git treating `/` like directories.
119
+ * This should be removed at some point in the future.
120
+ *
121
+ * @see https://github.com/googleapis/release-please/issues/1024
122
+ */
123
+ const V12_DEFAULT_PATTERN = `^${RELEASE_PLEASE}/branches/(?<branch>[^/]+)$`;
124
+ class V12DefaultBranchName extends BranchName {
125
+ static matches(branchName) {
126
+ return !!branchName.match(V12_DEFAULT_PATTERN);
127
+ }
128
+ constructor(branchName) {
129
+ super(branchName);
130
+ const match = branchName.match(V12_DEFAULT_PATTERN);
131
+ if (match === null || match === void 0 ? void 0 : match.groups) {
132
+ this.targetBranch = match.groups['branch'];
133
+ }
134
+ }
135
+ toString() {
136
+ return `${RELEASE_PLEASE}/branches/${this.targetBranch}`;
137
+ }
138
+ }
139
+ /**
140
+ * This is a parsable branch pattern used by release-please v12.
141
+ * It has potential issues due to git treating `/` like directories.
142
+ * This should be removed at some point in the future.
143
+ *
144
+ * @see https://github.com/googleapis/release-please/issues/1024
145
+ */
146
+ const V12_COMPONENT_PATTERN = `^${RELEASE_PLEASE}/branches/(?<branch>[^/]+)/components/(?<component>.+)$`;
147
+ class V12ComponentBranchName extends BranchName {
148
+ static matches(branchName) {
149
+ return !!branchName.match(V12_COMPONENT_PATTERN);
150
+ }
151
+ constructor(branchName) {
152
+ super(branchName);
153
+ const match = branchName.match(V12_COMPONENT_PATTERN);
154
+ if (match === null || match === void 0 ? void 0 : match.groups) {
155
+ this.targetBranch = match.groups['branch'];
156
+ this.component = match.groups['component'];
157
+ }
158
+ }
159
+ toString() {
160
+ return `${RELEASE_PLEASE}/branches/${this.targetBranch}/components/${this.component}`;
161
+ }
162
+ isComponent() {
163
+ return true;
164
+ }
165
+ }
166
+ const DEFAULT_PATTERN = `^${RELEASE_PLEASE}--branches--(?<branch>.+)$`;
167
+ class DefaultBranchName extends BranchName {
168
+ static matches(branchName) {
169
+ return !!branchName.match(DEFAULT_PATTERN);
170
+ }
171
+ constructor(branchName) {
172
+ super(branchName);
173
+ const match = branchName.match(DEFAULT_PATTERN);
174
+ if (match === null || match === void 0 ? void 0 : match.groups) {
175
+ this.targetBranch = match.groups['branch'];
176
+ }
177
+ }
178
+ toString() {
179
+ return `${RELEASE_PLEASE}--branches--${this.targetBranch}`;
180
+ }
181
+ }
182
+ const COMPONENT_PATTERN = `^${RELEASE_PLEASE}--branches--(?<branch>.+)--components--(?<component>.+)$`;
183
+ class ComponentBranchName extends BranchName {
184
+ static matches(branchName) {
185
+ return !!branchName.match(COMPONENT_PATTERN);
186
+ }
187
+ constructor(branchName) {
188
+ super(branchName);
189
+ const match = branchName.match(COMPONENT_PATTERN);
190
+ if (match === null || match === void 0 ? void 0 : match.groups) {
191
+ this.targetBranch = match.groups['branch'];
192
+ this.component = match.groups['component'];
193
+ }
194
+ }
195
+ toString() {
196
+ return `${RELEASE_PLEASE}--branches--${this.targetBranch}--components--${this.component}`;
197
+ }
198
+ isComponent() {
199
+ return true;
200
+ }
201
+ }
202
+ const GROUP_PATTERN = `^${RELEASE_PLEASE}--branches--(?<branch>.+)--groups--(?<group>.+)$`;
203
+ class GroupBranchName extends BranchName {
204
+ static matches(branchName) {
205
+ return !!branchName.match(GROUP_PATTERN);
206
+ }
207
+ constructor(branchName) {
208
+ super(branchName);
209
+ const match = branchName.match(GROUP_PATTERN);
210
+ if (match === null || match === void 0 ? void 0 : match.groups) {
211
+ this.targetBranch = match.groups['branch'];
212
+ this.component = match.groups['group'];
213
+ }
214
+ }
215
+ toString() {
216
+ return `${RELEASE_PLEASE}--branches--${this.targetBranch}--groups--${this.component}`;
217
+ }
218
+ }
219
+ function safeBranchName(branchName) {
220
+ // convert disallowed characters in branch names, replacing them with '-'.
221
+ // replace multiple consecutive '-' with a single '-' to avoid interfering with
222
+ // our regexes for parsing the branch names
223
+ return branchName.replace(/[^\w\d]/g, '-').replace(/-+/g, '-');
224
+ }
225
+ //# sourceMappingURL=branch-name.js.map
@@ -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,4 @@
1
+ export declare class CommitError extends Error {
2
+ cause: Error;
3
+ constructor(message: string, cause: Error);
4
+ }
@@ -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
@@ -0,0 +1,51 @@
1
+ import { Changes, TreeObject, RepoDomain, BranchDomain } from '../types';
2
+ import { Octokit } from '@octokit/rest';
3
+ import { CreateCommitOptions } from './create-commit';
4
+ /**
5
+ * Generate and return a GitHub tree object structure
6
+ * containing the target change data
7
+ * See https://developer.github.com/v3/git/trees/#tree-object
8
+ * @param {Changes} changes the set of repository changes
9
+ * @returns {TreeObject[]} The new GitHub changes
10
+ */
11
+ export declare function generateTreeObjects(changes: Changes): TreeObject[];
12
+ /**
13
+ * Upload and create a remote GitHub tree
14
+ * and resolves with the new tree SHA.
15
+ * Rejects if GitHub V3 API fails with the GitHub error response
16
+ * @param {Octokit} octokit The authenticated octokit instance
17
+ * @param {RepoDomain} origin the the remote repository to push changes to
18
+ * @param {string} refHead the base of the new commit(s)
19
+ * @param {TreeObject[]} tree the set of GitHub changes to upload
20
+ * @returns {Promise<string>} the GitHub tree SHA
21
+ * @throws {CommitError}
22
+ */
23
+ export declare function createTree(octokit: Octokit, origin: RepoDomain, refHead: string, tree: TreeObject[]): Promise<string>;
24
+ /**
25
+ * Update a reference to a SHA
26
+ * Rejects if GitHub V3 API fails with the GitHub error response
27
+ * @param {Octokit} octokit The authenticated octokit instance
28
+ * @param {BranchDomain} origin the the remote branch to push changes to
29
+ * @param {string} newSha the ref to update the commit HEAD to
30
+ * @param {boolean} force to force the commit changes given refHead
31
+ * @returns {Promise<void>}
32
+ */
33
+ export declare function updateRef(octokit: Octokit, origin: BranchDomain, newSha: string, force: boolean): Promise<void>;
34
+ interface CommitAndPushOptions extends CreateCommitOptions {
35
+ filesPerCommit?: number;
36
+ }
37
+ /**
38
+ * Given a set of changes, apply the commit(s) on top of the given branch's head and upload it to GitHub
39
+ * Rejects if GitHub V3 API fails with the GitHub error response
40
+ * @param {Octokit} octokit The authenticated octokit instance
41
+ * @param {string} refHead the base of the new commit(s)
42
+ * @param {Changes} changes the set of repository changes
43
+ * @param {RepoDomain} origin the the remote repository to push changes to
44
+ * @param {string} originBranchName the remote branch that will contain the new changes
45
+ * @param {string} commitMessage the message of the new commit
46
+ * @param {boolean} force to force the commit changes given refHead
47
+ * @returns {Promise<void>}
48
+ * @throws {CommitError}
49
+ */
50
+ export declare function commitAndPush(octokit: Octokit, refHead: string, changes: Changes, originBranch: BranchDomain, commitMessage: string, force: boolean, options?: CommitAndPushOptions): Promise<void>;
51
+ export {};
@@ -0,0 +1,141 @@
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.commitAndPush = exports.updateRef = exports.createTree = exports.generateTreeObjects = void 0;
17
+ const logger_1 = require("../logger");
18
+ const create_commit_1 = require("./create-commit");
19
+ const errors_1 = require("../errors");
20
+ const DEFAULT_FILES_PER_COMMIT = 100;
21
+ /**
22
+ * Generate and return a GitHub tree object structure
23
+ * containing the target change data
24
+ * See https://developer.github.com/v3/git/trees/#tree-object
25
+ * @param {Changes} changes the set of repository changes
26
+ * @returns {TreeObject[]} The new GitHub changes
27
+ */
28
+ function generateTreeObjects(changes) {
29
+ const tree = [];
30
+ changes.forEach((fileData, path) => {
31
+ if (fileData.content === null) {
32
+ // if no file content then file is deleted
33
+ tree.push({
34
+ path,
35
+ mode: fileData.mode,
36
+ type: 'blob',
37
+ sha: null,
38
+ });
39
+ }
40
+ else {
41
+ // update file with its content
42
+ tree.push({
43
+ path,
44
+ mode: fileData.mode,
45
+ type: 'blob',
46
+ content: fileData.content,
47
+ });
48
+ }
49
+ });
50
+ return tree;
51
+ }
52
+ exports.generateTreeObjects = generateTreeObjects;
53
+ function* inGroupsOf(all, groupSize) {
54
+ for (let i = 0; i < all.length; i += groupSize) {
55
+ yield all.slice(i, i + groupSize);
56
+ }
57
+ }
58
+ /**
59
+ * Upload and create a remote GitHub tree
60
+ * and resolves with the new tree SHA.
61
+ * Rejects if GitHub V3 API fails with the GitHub error response
62
+ * @param {Octokit} octokit The authenticated octokit instance
63
+ * @param {RepoDomain} origin the the remote repository to push changes to
64
+ * @param {string} refHead the base of the new commit(s)
65
+ * @param {TreeObject[]} tree the set of GitHub changes to upload
66
+ * @returns {Promise<string>} the GitHub tree SHA
67
+ * @throws {CommitError}
68
+ */
69
+ async function createTree(octokit, origin, refHead, tree) {
70
+ const oldTreeSha = (await octokit.git.getCommit({
71
+ owner: origin.owner,
72
+ repo: origin.repo,
73
+ commit_sha: refHead,
74
+ })).data.tree.sha;
75
+ logger_1.logger.info('Got the latest commit tree');
76
+ try {
77
+ const treeSha = (await octokit.git.createTree({
78
+ owner: origin.owner,
79
+ repo: origin.repo,
80
+ tree,
81
+ base_tree: oldTreeSha,
82
+ })).data.sha;
83
+ logger_1.logger.info(`Successfully created a tree with the desired changes with SHA ${treeSha}`);
84
+ return treeSha;
85
+ }
86
+ catch (e) {
87
+ throw new errors_1.CommitError(`Error adding to tree: ${refHead}`, e);
88
+ }
89
+ }
90
+ exports.createTree = createTree;
91
+ /**
92
+ * Update a reference to a SHA
93
+ * Rejects if GitHub V3 API fails with the GitHub error response
94
+ * @param {Octokit} octokit The authenticated octokit instance
95
+ * @param {BranchDomain} origin the the remote branch to push changes to
96
+ * @param {string} newSha the ref to update the commit HEAD to
97
+ * @param {boolean} force to force the commit changes given refHead
98
+ * @returns {Promise<void>}
99
+ */
100
+ async function updateRef(octokit, origin, newSha, force) {
101
+ logger_1.logger.info(`Updating reference heads/${origin.branch} to ${newSha}`);
102
+ try {
103
+ await octokit.git.updateRef({
104
+ owner: origin.owner,
105
+ repo: origin.repo,
106
+ ref: `heads/${origin.branch}`,
107
+ sha: newSha,
108
+ force,
109
+ });
110
+ logger_1.logger.info(`Successfully updated reference ${origin.branch} to ${newSha}`);
111
+ }
112
+ catch (e) {
113
+ throw new errors_1.CommitError(`Error updating ref heads/${origin.branch} to ${newSha}`, e);
114
+ }
115
+ }
116
+ exports.updateRef = updateRef;
117
+ /**
118
+ * Given a set of changes, apply the commit(s) on top of the given branch's head and upload it to GitHub
119
+ * Rejects if GitHub V3 API fails with the GitHub error response
120
+ * @param {Octokit} octokit The authenticated octokit instance
121
+ * @param {string} refHead the base of the new commit(s)
122
+ * @param {Changes} changes the set of repository changes
123
+ * @param {RepoDomain} origin the the remote repository to push changes to
124
+ * @param {string} originBranchName the remote branch that will contain the new changes
125
+ * @param {string} commitMessage the message of the new commit
126
+ * @param {boolean} force to force the commit changes given refHead
127
+ * @returns {Promise<void>}
128
+ * @throws {CommitError}
129
+ */
130
+ async function commitAndPush(octokit, refHead, changes, originBranch, commitMessage, force, options) {
131
+ var _a;
132
+ const filesPerCommit = (_a = options === null || options === void 0 ? void 0 : options.filesPerCommit) !== null && _a !== void 0 ? _a : DEFAULT_FILES_PER_COMMIT;
133
+ const tree = generateTreeObjects(changes);
134
+ for (const treeGroup of inGroupsOf(tree, filesPerCommit)) {
135
+ const treeSha = await createTree(octokit, originBranch, refHead, treeGroup);
136
+ refHead = await (0, create_commit_1.createCommit)(octokit, originBranch, refHead, treeSha, commitMessage, options);
137
+ }
138
+ await updateRef(octokit, originBranch, refHead, force);
139
+ }
140
+ exports.commitAndPush = commitAndPush;
141
+ //# sourceMappingURL=commit-and-push.js.map