Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate and fix issues with HEAD ref not found bug #23

Merged
merged 3 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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