Line

ui/server/src/git

The narrowest possible git interface the Cockpit needs.

Cockpit server, v0.9. Source: ui/server/src/git.mjs.

Classes#

GitError#

Defined in: ui/server/src/git.mjs:18

Extends#

  • Error

Constructors#

Constructor

new GitError(message, __namedParameters?): GitError

Defined in: ui/server/src/git.mjs:19

Parameters
message

any

__namedParameters?
code?

string = 'GIT_ERROR'

status?

number = 500

stderr?

string = ''

Returns

GitError

Overrides

Error.constructor

Properties#

code

code: string

Defined in: ui/server/src/git.mjs:23

name

name: string

Defined in: ui/server/src/git.mjs:21

Inherited from

Error.name

status

status: number

Defined in: ui/server/src/git.mjs:22

stderr

stderr: string

Defined in: ui/server/src/git.mjs:24

Functions#

branchExists()#

branchExists(root, name): boolean

Defined in: ui/server/src/git.mjs:71

Parameters#

root

any

name

any

Returns#

boolean


commit()#

commit(root, message, __namedParameters?): object

Defined in: ui/server/src/git.mjs:140

Commit whatever is staged, with message passed on stdin (-F -) so a multi-line body with arbitrary punctuation never touches an argument list.

Parameters#

root

any

message

any

__namedParameters?

Returns#

object

sha

sha: string

subject

subject: string


createBranch()#

createBranch(root, name): any

Defined in: ui/server/src/git.mjs:77

Create name from the current HEAD and check it out. Uncommitted work comes along, which is exactly what the "carry" answer to the dirty-tree prompt wants.

Parameters#

root

any

name

any

Returns#

any


currentBranch()#

currentBranch(root): any

Defined in: ui/server/src/git.mjs:60

The checked-out branch, or null on a detached HEAD / an unborn branch with no commits yet.

Parameters#

root

any

Returns#

any


git()#

git(root, args, __namedParameters?): { ok: boolean; stderr?: undefined; stdout: any; } | { ok: boolean; stderr: string; stdout: string; }

Defined in: ui/server/src/git.mjs:32

Run one git command. Never a shell: args is an argv array.

Parameters#

root

any

args

any

__namedParameters?
allowFail?

boolean = false

Returns#

{ ok: boolean; stderr?: undefined; stdout: any; } | { ok: boolean; stderr: string; stdout: string; }


hasStagedChanges()#

hasStagedChanges(root): boolean

Defined in: ui/server/src/git.mjs:131

Are there staged changes to commit?

Parameters#

root

any

Returns#

boolean


headSha()#

headSha(root): any

Defined in: ui/server/src/git.mjs:66

Parameters#

root

any

Returns#

any


isRepo()#

isRepo(root): boolean

Defined in: ui/server/src/git.mjs:52

True when root is inside a git work tree (and is its own root, not a subdirectory of one).

Parameters#

root

any

Returns#

boolean


stage()#

stage(root, paths): any[]

Defined in: ui/server/src/git.mjs:120

Stage exactly these project-relative paths — never git add -A, so a Cockpit save can never sweep up unrelated work the user had open.

Parameters#

root

any

paths

any

Returns#

any[]


stashPaths()#

stashPaths(root, paths, label): any

Defined in: ui/server/src/git.mjs:164

Stash exactly these paths (the dirty-tree "stash" answer), including untracked ones, with a label the user can find again. Scoped to the given paths so a stash never swallows the session's own work. Returns the stash ref, so the UI can say plainly where it went.

Parameters#

root

any

paths

any

label

any

Returns#

any


status()#

status(root): object[]

Defined in: ui/server/src/git.mjs:90

The working tree's changes, as {path, kind, staged, untracked}. Uses -z so paths containing spaces or quotes come back verbatim rather than C-quoted.

Parameters#

root

any

Returns#

object[]


subjectsOn()#

subjectsOn(root, __namedParameters?): any

Defined in: ui/server/src/git.mjs:154

Commit subjects on the current branch, newest first — the input nextSerialFrom reads.

Parameters#

root

any

__namedParameters?
branch?

string = 'HEAD'

limit?

number = 500

Returns#

any