Skip to content

Commit

Permalink
Investigate and fix issues with HEAD ref not found bug (#23)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
s0 authored Nov 2, 2024
1 parent b2cfce1 commit 80aa73e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @s0/ghcommit

## 1.2.1

### Patch Changes

- 85ec677: Address issue with Ref HEAD not found

## 1.2.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@s0/ghcommit",
"version": "1.2.0",
"version": "1.2.1",
"private": false,
"description": "Directly change files on github using the github API, to support GPG signing",
"keywords": [
Expand Down
8 changes: 4 additions & 4 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ export const commitFilesFromBase64 = async ({
throw new Error(`Repository ${repositoryNameWithOwner} not found`);
}

if (!info.baseRef) {
throw new Error(`Ref ${baseRef} not found`);
}

const repositoryId = info.id;
/**
* The commit oid to base the new commit on.
Expand All @@ -97,6 +93,10 @@ export const commitFilesFromBase64 = async ({
if ("branch" in base && base.branch === branch) {
log?.debug(`Committing to the same branch as base: ${branch} (${baseOid})`);
// Get existing branch refId

if (!info.baseRef) {
throw new Error(`Ref ${baseRef} not found`);
}
refId = info.baseRef.id;
} else {
// Determine if the branch needs to be created or not
Expand Down
1 change: 1 addition & 0 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const commitChangesFromRepo = async ({
return commitFilesFromBuffers({
...otherArgs,
fileChanges,
log,
base: {
commit: oid,
},
Expand Down

0 comments on commit 80aa73e

Please sign in to comment.