Skip to content

Commit 8ed80f7

Browse files
fix: replace non-null assertions with runtime guards in syncChanges
Co-Authored-By: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com>
1 parent 223880c commit 8ed80f7

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

dist/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39480,6 +39480,12 @@ async function cloneRepository(options) {
3948039480
]);
3948139481
}
3948239482
async function syncChanges(options) {
39483+
if (!options.token) {
39484+
throw new Error("GitHub token is required for syncing changes.");
39485+
}
39486+
if (!options.branch) {
39487+
throw new Error("Branch name is required for syncing changes.");
39488+
}
3948339489
const octokit = github.getOctokit(options.token);
3948439490
const [owner, repo] = options.repository.split("/");
3948539491
try {

src/sync.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,18 @@ async function cloneRepository(options: SyncOptions): Promise<void> {
266266
}
267267

268268
async function syncChanges(options: SyncOptions): Promise<void> {
269-
const octokit = github.getOctokit(options.token!);
269+
if (!options.token) {
270+
throw new Error("GitHub token is required for syncing changes.");
271+
}
272+
if (!options.branch) {
273+
throw new Error("Branch name is required for syncing changes.");
274+
}
275+
276+
const octokit = github.getOctokit(options.token);
270277
const [owner, repo] = options.repository.split("/");
271278

272279
try {
273-
const workingBranch = options.branch!;
280+
const workingBranch = options.branch;
274281

275282
if (options.autoMerge) {
276283
core.info(

0 commit comments

Comments
 (0)