Skip to content

Commit 85ec677

Browse files
committed
Only require ref to exist when using tag/branch
Changes to the GitHub GraphQL API mean that resolving references with `HEAD` no longer work. However, we don't need to actually do this when providing a commit SHA as a base, so we can move the error check to only when we need this information when committing to the same branch as the base.
1 parent cbe0416 commit 85ec677

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.changeset/shaggy-eels-promise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@s0/ghcommit": patch
3+
---
4+
5+
Address issue with Ref HEAD not found

src/core.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ export const commitFilesFromBase64 = async ({
7979
throw new Error(`Repository ${repositoryNameWithOwner} not found`);
8080
}
8181

82-
if (!info.baseRef) {
83-
throw new Error(`Ref ${baseRef} not found`);
84-
}
85-
8682
const repositoryId = info.id;
8783
/**
8884
* The commit oid to base the new commit on.
@@ -97,6 +93,10 @@ export const commitFilesFromBase64 = async ({
9793
if ("branch" in base && base.branch === branch) {
9894
log?.debug(`Committing to the same branch as base: ${branch} (${baseOid})`);
9995
// Get existing branch refId
96+
97+
if (!info.baseRef) {
98+
throw new Error(`Ref ${baseRef} not found`);
99+
}
100100
refId = info.baseRef.id;
101101
} else {
102102
// Determine if the branch needs to be created or not

0 commit comments

Comments
 (0)