Skip to main content

Module bounded_push

Module bounded_push 

Source
Expand description

The auto-push’s real git push with a deadline and its low-speed abort. What: Run the auto-push’s real git push with a deadline. Why: A push whose connection stalls would otherwise hold the service’s push of that branch forever, and every later push of the repository would wait behind it. The push is stopped when its deadline passes, the commit stays saved locally, and the failure is reported like any other failed push.

In TS you’d write (pseudocode):

const { exitCode, output } = await nanoSpawn(gitPath, pushArgs, { cwd, signal: AbortSignal.timeout(deadlineMs) });

Enums§

StopCause
Why a push or query was stopped.

Constants§

DEFAULT_PUSH_DEADLINE
How long a push may run when the variable is absent or unusable.
LOW_SPEED_LIMIT
Lowest transfer speed in bytes per second Git tolerates on an HTTP transfer.
LOW_SPEED_TIME
Seconds the transfer may stay below the lowest speed before Git aborts it.
MAX_PUSH_OUTPUT
The most output bytes kept from one push; a push that writes more is stopped.
PUSH_DEADLINE_VARIABLE
Environment variable that sets the push deadline in whole seconds.
STOPPED_EXIT_CODE
Exit code recorded for a push that this wrapper stopped, the convention of timeout(1).
STOP_GRACE
How long a stopped push gets to end after the polite stop signal before it is killed.

Functions§

apply_low_speed_defaults
What: Add Git’s low-speed abort to a push command unless the environment sets it. Why: Git ends an HTTP transfer that stays under the limit for the time, which also ends its helper processes; the push deadline is only the backstop for transports this does not cover. Git lets these variables override http.lowSpeedLimit and http.lowSpeedTime from its configuration, so only a person’s environment variables are kept, not their configuration.
positive_seconds
What: Read a positive whole number of seconds from one environment value. Why: A zero, negative, fractional, empty or non-text value is no setting at all, never “no limit”, so a typo cannot remove a bound.
push_deadline
What: The push deadline: the environment’s value, or the default. Why: A person may need a longer deadline on a slow link or a shorter one on a flaky one.
run_bounded_push
What: Run a push command to its end or its deadline and capture its interleaved output. Why: Both streams share one anonymous file so lines keep the order Git wrote them, and a file needs no reader thread that a stuck helper could keep alive. A stopped push becomes a failed attempt that says so, so the commit stays saved and the failure is recorded for later invocations.
stop_push
What: Stop a running push: ask politely, wait the grace, then kill and collect it. Why: Git’s own signal handling ends the helpers it started, and a push that ignores the request cannot outlive the kill.
strip_one_line_break
Remove exactly one trailing \n or \r\n, as the captured output of the incumbent does.
wait_until_done
What: Look at a running push until it ends, its deadline passes or its output floods. Why: std has no timed wait, so the parent looks with try_wait, which never blocks.