2017-08-25

guile, sph-lib and git

the module (sph two) contains a few bindings for querying git repositories. they require git to be installed, and may be found in a separate module in the future if more bindings are created

repository-paths are not required to be paths to cloned repositories, but can be server side respository directories as well

how to create an archive from a git repository, without the .git directory

example use-cases

offering a current git-snapshot for download

creating a release package

the following procedures are provided by the (sph two) module

git-archive :: repository-path [branch:"master" string:additional-git-arguments ...] -> boolean

git-archive->file :: repository-path target-path [branch:"master" string:additional-git-arguments ...] -> boolean

description

git-archive writes the archive to standard output, git-archive->file creates a file at target-path. the result of the procedure application is true if the operation succeeded.

note: the default behaviour of "git archive" is to not create a subdirectory in the archive - all files expand flat into the current directory. to avoid this, add "--prefix=name/" to the additional-git-arguments

example

(import (sph two))
(git-archive->file "/path/to/git/repository" "test-archive.tgz")

how to get the short commit hash for the current commit

git-current-short-commit-hash :: repository-path [branch:"master"] -> string

example

(import (sph two))
(git-current-short-commit-hash "/path/to/git/repository")

result

"ca7f4ab"

tags: programming guile sph-lib start document guide computer git