Skip to content

Commit 80aa73e

Browse files
authored
Investigate and fix issues with HEAD ref not found bug (#23)
* Ensure logging is passed through from commitChangesFromRepo * 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. * Run changeset version
1 parent b2cfce1 commit 80aa73e

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @s0/ghcommit
22

3+
## 1.2.1
4+
5+
### Patch Changes
6+
7+
- 85ec677: Address issue with Ref HEAD not found
8+
39
## 1.2.0
410

511
### Minor Changes

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@s0/ghcommit",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"private": false,
55
"description": "Directly change files on github using the github API, to support GPG signing",
66
"keywords": [

src/core.ts

+4-4
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

src/git.ts

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export const commitChangesFromRepo = async ({
8787
return commitFilesFromBuffers({
8888
...otherArgs,
8989
fileChanges,
90+
log,
9091
base: {
9192
commit: oid,
9293
},

0 commit comments

Comments
 (0)