Documentation
¶
Overview ¶
Package gitx shells out to git and gh.
Deliberately subprocesses rather than a Go git library: the sync runs inside a container whose credentials arrive as git config (http.https://github.com/.extraheader, set by the workflow), and pull requests are opened with gh. A library would have to reimplement both, and the workflow's own comments record what it cost to get that plumbing right.
Index ¶
- Constants
- type ExecRunner
- type Git
- func (g *Git) CommitAll(ctx context.Context, repo, subject, body string) (string, error)
- func (g *Git) CreateBranch(ctx context.Context, repo, name string) error
- func (g *Git) CurrentBranch(ctx context.Context, repo string) (string, error)
- func (g *Git) FetchBranch(ctx context.Context, repo, branch string) error
- func (g *Git) HasUncommittedChanges(ctx context.Context, repo string) (bool, error)
- func (g *Git) OpenPR(ctx context.Context, repo, branch, title, body, base string) (string, error)
- func (g *Git) PRForBranch(ctx context.Context, repo, branch string) string
- func (g *Git) PushBranch(ctx context.Context, repo, branch string, forceWithLease bool) error
- type Runner
Constants ¶
const DefaultAuthor = "ichava-sync-bot <19682005+imanimanyara@users.noreply.github.com>"
DefaultAuthor is the identity sync commits are attributed to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Git ¶
Git wraps the repository operations the sync needs.
func (*Git) CreateBranch ¶
CreateBranch creates or resets a branch to HEAD.
-B rather than -b, so a re-run over a branch a previous run left behind succeeds instead of failing on "already exists". The sync pushes to one stable branch per pack so each run updates a single pull request.
func (*Git) CurrentBranch ¶ added in v0.1.1
CurrentBranch returns the checked-out branch, or "HEAD" when detached.
func (*Git) FetchBranch ¶
FetchBranch fetches one remote branch into its tracking ref.
The sync pushes to a stable branch and relies on --force-with-lease, which compares against the remote-tracking ref. actions/checkout fetches only the default branch, so that ref does not exist on a runner and the lease has nothing to compare -- git then rejects the push as "stale info", which reads like a race and is not one.
func (*Git) HasUncommittedChanges ¶
HasUncommittedChanges reports whether the tree differs from HEAD.
func (*Git) PRForBranch ¶
PRForBranch returns an existing pull request URL for a branch, or "".
Filtered to open pull requests. Python asked gh for whatever it had, which matched a *merged* one once the first sync landed -- so every later run reported "already open", skipped creation and exited 0 while the branch it had just pushed had nothing tracking it.
func (*Git) PushBranch ¶
PushBranch pushes and sets upstream.
--force-with-lease, because the branch is stable across runs and a later run legitimately replaces an earlier one's commit. The lease is what stops it overwriting a human's edit to the same branch.