Next: , Previous: , Up: API  


1.2 (maak git)

The git commands a project’s Maak file usually wants, and the source archives it usually ships, as procedures rather than tasks. A Maak file decides which of them to expose, and under which names:

 (define-module (maak)
   #:use-module (maak git))

 (define (commit message)
   "Commit every tracked change."
   (git-commit message))
 

Every command goes through ‘run’, which hands the arguments to git as a list: a commit message with spaces or quotes reaches git as one argument, and no shell splits it again. Nothing here assumes a project layout – the archive helpers take the file name and the prefix, and ‘git’ itself takes ‘#:directory’ – so the same procedures serve a checkout here and one elsewhere.

A command that fails stops the task with git’s own message and a maak error naming the command, the way any other ‘run’ does.

1.2.1 Procedures

Procedure: git arguments KEY: #:directory #:allow-failure?

Run git with ARGUMENTS, a list of strings, in DIRECTORY.

This is what every wrapper below is made of, and the way to reach a command that has no wrapper – ‘git-fetch’, ‘git-reset’, a subcommand added tomorrow. Nothing is handed to a shell, so a value with spaces in it stays one argument.

(git (list "fetch" "--all"))
(git (list "log" "--oneline" "-3") #:directory "/path/to/checkout")

A command that exits non-zero raises a maak error naming it, unless ALLOW-FAILURE? is #t, in which case the call answers #f.

Procedure: git-add . paths

Stage PATHS, or every change in the tree when none is named.

Procedure: git-archive output KEY: #:format #:prefix #:revision #:directory

Write REVISION as OUTPUT with git archive, under PREFIX, in FORMAT.

FORMAT is one git archive understands, ‘tar.gz’ and ‘zip’ being the usual ones. PREFIX is the directory the archive unpacks into, and it carries its own trailing slash. DIRECTORY is the checkout to read from.

(git-archive "maak-1.0.tar.gz" #:prefix "maak-1.0/")
Procedure: git-archive-tar output KEY: #:prefix #:revision #:directory

Write REVISION as the gzipped tarball OUTPUT, under PREFIX.

Procedure: git-archive-zip output KEY: #:prefix #:revision #:directory

Write REVISION as the zip OUTPUT, under PREFIX.

Procedure: git-branch . names

List the branches, or create the branches NAMES name.

Procedure: git-commit message

Commit every tracked change with MESSAGE.

Procedure: git-init . arguments

Initialise a git repository here, with any arguments git init takes.

Procedure: git-log . arguments

Show the history as a decorated one-line graph, twenty commits by default.

Procedure: git-pull . arguments

Pull from the upstream branch, with any arguments git pull takes.

Procedure: git-push . arguments

Push the current branch, with any arguments git push takes.

A bare push does not send tags that are not annotated; ‘(git-push "–tags")’ sends them too.

Procedure: git-status

Show the current branch and a short status of the working tree.

Procedure: git-switch branch

Switch to BRANCH, which must already exist.

Procedure: git-tag name

Tag the current commit as NAME, without an annotation.


Next: (maak guix), Previous: (maak dsl), Up: API