Skip to content

fix(push)!: publish the active branch to its configured upstream - #4

Merged
borjalofe merged 1 commit into
mainfrom
fix/push-configured-upstream
Nov 26, 2026
Merged

borjalofe merged 1 commit into
mainfrom
fix/push-configured-upstream

Conversation

@borjalofe

Copy link
Copy Markdown
Owner

Summary

Reworks the post-commit push in the gitCommit action so it publishes only the active branch to its configured upstream destination, instead of always running git push origin HEAD. The remote name and the remote branch name are read from git configuration, never assumed.

Why

The old pushToOrigin assumed a remote literally named origin and a same-named remote branch. For clones whose remote is forgejo/github, or whose branch tracks a differently named remote branch, that pushed to a wrong or invented destination (origin/<same-name>). The action now honors the branch's own upstream.

Behavior

  • Destination resolved from branch.<name>.remote + branch.<name>.merge.
  • Publishes with an explicit single-ref refspec: git push <remote> refs/heads/<branch>:<mergeRef> — no other refs are pushed regardless of push.default.
  • Never forces, never changes git config, never creates an upstream.
  • Skips with a clear warning, inventing no destination, on: detached HEAD, no configured upstream, local tracking ref (remote = .), or missing remote.
  • The local commit is always preserved; push failures resolve with a warning, not an error.
  • Success message: Committed and pushed to <remote>/<remoteBranch>: <message>.

Breaking change

A branch with no configured upstream is no longer pushed to a remote named origin; it resolves with a warning and a local commit. Configure an upstream (git push -u, or branch.<name>.merge) to publish.

Tests

Hermetic, local bare remotes only (no network). RED observed, then GREEN. Cases: configured non-origin remote with a different remote branch name; no upstream (no fallback to origin); detached HEAD; missing configured remote; push failure with commit preserved.

Verification

  • vitest run: 23/23
  • tsup build: OK
  • biome check src test: clean

Notes

Native RDD review (due, high risk, item 3) could not run in this environment: the reviewer provider has no credentials. Functional checks above all pass; the external review remains pending, not a pass.

Resolve the push destination from the branch's own git configuration
(branch.<name>.remote and branch.<name>.merge) and publish only that
branch with an explicit refspec, instead of always running
`git push origin HEAD`. The remote name and the remote branch name are
never assumed; the push never forces and never changes git config.

Skip with a clear warning, inventing no destination, on a detached HEAD,
a branch with no configured upstream, a local tracking ref (remote=.),
or a missing remote. The local commit is always preserved.

Replace pushToOrigin with pushCurrentBranch; the success message is now
`Committed and pushed to <remote>/<remoteBranch>: <message>`. Add hermetic
tests (local bare remotes, no network) and update README and CHANGELOG.

BREAKING CHANGE: a branch with no configured upstream is no longer pushed
to a remote named `origin`; it now resolves with a warning and a local
commit. Configure an upstream (git push -u, or branch.<name>.merge) to
publish.
@borjalofe
borjalofe merged commit e3b0118 into main Nov 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant