gitx

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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 ExecRunner

type ExecRunner struct{}

ExecRunner runs real subprocesses.

func (ExecRunner) Run

func (ExecRunner) Run(ctx context.Context, dir string, env []string, name string, args ...string) (string, error)

type Git

type Git struct {
	Run    Runner
	Author string
}

Git wraps the repository operations the sync needs.

func New

func New() *Git

New returns a Git over real subprocesses.

func (*Git) CommitAll

func (g *Git) CommitAll(ctx context.Context, repo, subject, body string) (string, error)

CommitAll stages everything and commits, returning the new SHA.

func (*Git) CreateBranch

func (g *Git) CreateBranch(ctx context.Context, repo, name string) error

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

func (g *Git) CurrentBranch(ctx context.Context, repo string) (string, error)

CurrentBranch returns the checked-out branch, or "HEAD" when detached.

func (*Git) FetchBranch

func (g *Git) FetchBranch(ctx context.Context, repo, branch string) error

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

func (g *Git) HasUncommittedChanges(ctx context.Context, repo string) (bool, error)

HasUncommittedChanges reports whether the tree differs from HEAD.

func (*Git) OpenPR

func (g *Git) OpenPR(ctx context.Context, repo, branch, title, body, base string) (string, error)

OpenPR opens a pull request, or returns the open one already on the branch.

func (*Git) PRForBranch

func (g *Git) PRForBranch(ctx context.Context, repo, branch string) string

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

func (g *Git) PushBranch(ctx context.Context, repo, branch string, forceWithLease bool) error

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.

type Runner

type Runner interface {
	Run(ctx context.Context, dir string, env []string, name string, args ...string) (string, error)
}

Runner executes git and gh. Swapped in tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL