fix: Honor updateRef when creating signed commits - #224
Conversation
|
@VedantMadane is attempting to deploy a commit to the Toss Team on Vercel. A member of the Team first needs to authorize it. |
- After commit_signed, update the named ref (create or set_target) - Matches unsigned commit() behavior so signed commits are not unreachable Fixes toss#218 Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
6e2c6db to
3a51094
Compare
marshallku
left a comment
There was a problem hiding this comment.
Thanks for taking this on, and sorry for the slow response.
Unfortunately this doesn;t fix #218 as written. Repository::find_reference is git_reference_lookup, which does not resolve symbolic references. HEAD is symbolic in a normal repository, so set_targe hits libgit2's ensure_is_an_updatable_direct_reference() and fails with cannot set OID on symbolic reference. I reproduced it against the pinned git2 =0.20.4:
So updateRef: 'HEAD' — the exact case in #218 — goes from a silent no-op to a thrown error, and the existing create signed commit test (tests/commit.spec.ts:67) plus the documented example in docs/usage/commit.md:54 would both break. CI hasn't run on this branch yet, so it hasn't surfaced.
The primitive libgit2 uses here is git_reference_lookup_resolved (git2: find_reference(name)?.resolve()), and its unsigned path also validates the first parent against the current tip before writing the object. #225 implements that with tests, so I'm closing this in favour of it.
Thank you for the effort regardless — please do keep an eye on the issue list.
Summary
Honor updateRef when creating signed commits
Changes
Fixes #218