Documentation
¶
Overview ¶
Package mergejob keeps the detached merges of devctl pr merge --detach: one directory per merge under the user's state directory, named by the merge's handle, holding the job, the merge's log and, once it ended, its document.
Index ¶
- Constants
- func Alive(pid int) bool
- func Detach(cmd *exec.Cmd)
- func Prune(root string, now time.Time) error
- func Root() (string, error)
- func Shell(script string) []string
- func ValidHandle(handle string) bool
- func WriteDocument(root, handle string, document []byte) error
- func WriteOnDone(root, handle string, o OnDone) error
- type Job
- type OnDone
- type Status
Constants ¶
const ( // StateRunning: the merge's process runs and has not written its // document. StateRunning = "running" // StateFinished: the merge wrote its document. StateFinished = "finished" // StateLost: the merge's process is gone without a document (killed, // the machine restarted); whether it merged is GitHub's to say. StateLost = "lost" )
The states of a job.
const ( // LogFile is the merge's stdout and stderr: its --progress lines and // the document. LogFile = "output.log" )
The files of a job's directory.
const Retention = 30 * 24 * time.Hour
Retention is how long a finished or lost job is kept; Start removes older ones.
Variables ¶
This section is empty.
Functions ¶
func Detach ¶
Detach makes cmd start in a session of its own, so it outlives its caller's terminal, process group and signals.
func Root ¶
Root is the directory the jobs live in: $XDG_STATE_HOME/devctl/merges, or ~/.local/state/devctl/merges without it.
func ValidHandle ¶
ValidHandle reports whether handle can name a job: no path separator, no leading dot.
func WriteDocument ¶
WriteDocument stores the merge's document, atomically: a reader sees it whole or not at all.
func WriteOnDone ¶
WriteOnDone stores the --on-done command's outcome.
Types ¶
type Job ¶
type Job struct {
Handle string `json:"handle"`
Repository string `json:"repository"`
Number int `json:"number"`
PID int `json:"pid"`
StartedAt time.Time `json:"startedAt"`
// Dir is the job's directory; not stored.
Dir string `json:"-"`
}
Job is one detached merge.
func Create ¶
Create makes the directory of a new job for owner/repo#number started at now and returns the job; its handle is <owner>-<repo>-<number>-<UTC time>, with a suffix when a job of the same second exists.
func (Job) DocumentPath ¶
DocumentPath is the path the merge's document is written to.
type OnDone ¶
type OnDone struct {
Command string `json:"command"`
ExitCode int `json:"exitCode"`
Error string `json:"error,omitempty"`
}
OnDone is how the --on-done command of a job ended.
type Status ¶
type Status struct {
Job
State string
// Document is the merge's JSON document, set when finished.
Document json.RawMessage
// OnDone is the --on-done command's outcome, nil when none ran (yet).
OnDone *OnDone
}
Status is what a job's directory says about it.