git
| (require git) | package: git |
The git module provides a small command-line-like Git interface implemented on top of the libgit2 package. It does not invoke the git executable.
The short form is intended for build scripts and interactive use:
(require git) (git 'status) (git 'add "main.rkt" "info.rkt") (git 'commit "Implement raco support") (git 'tag "v0.1") (git 'checkout "main")
(dgit 'status)
1 Repository
procedure
(git-repository? [path]) → boolean?
path : path-string? = (current-directory)
procedure
path : path-string? = (current-directory)
procedure
path : path-string? = (current-directory) bare? : any/c = #f
procedure
url : string? (git-clone url path) → path? url : string? path : path-string?
2 Status and index
struct
(struct git-status-entry (path code flags))
path : string? code : string? flags : list?
procedure
(git-status) → (listof git-status-entry?)
procedure
(git-status-lines [entries]) → (listof string?)
entries : (listof git-status-entry?) = (git-status)
procedure
(git-clean?) → boolean?
procedure
path : path-string?
3 Configuration and commits
procedure
(git-config key) → string?
key : string? (git-config key value) → string? key : string? value : string?
procedure
(git-commit message) → string?
message : string?
4 Branches, checkout, and tags
procedure
(git-current-branch) → (or/c string? #f)
procedure
(git-branch) → (listof string?)
(git-branch name) → string? name : string?
procedure
(git-branch-delete name) → void?
name : string?
procedure
(git-checkout name) → (or/c string? #f)
name : string?
procedure
(git-checkout-new name) → string?
name : string?
procedure
(git-tag-delete name) → void?
name : string?
5 Log
struct
(struct git-log-entry (id summary time))
id : string? summary : string? time : integer?
procedure
(git-log [max-count]) → (listof git-log-entry?)
max-count : exact-nonnegative-integer? = 20
procedure
(git-log-lines [entries]) → (listof string?)
entries : (listof git-log-entry?) = (git-log)
6 Remotes
procedure
(git-remotes) → (listof string?)
procedure
(git-remote-add name url) → string?
name : string? url : string?
procedure
(git-remote-url [name]) → string?
name : string? = "origin"
procedure
(git-push remote) → void? remote : string? (git-push remote branch) → void? remote : string? branch : string?
procedure
(git-push-tag tag [remote]) → void?
tag : string? remote : string? = "origin"
Remote HTTPS operations automatically use credentials from the racket-git credential store when an entry exists for the remote host.
7 Command form
The following command-like forms are supported directly:
(git 'init) (git 'clone "https://example/repo.git") (git 'status) (git 'add "file.rkt") (git 'config "user.name" "Name") (git 'commit "message") (git 'branch) (git 'branch "feature") (git 'branch '-d "feature") (git 'checkout "main") (git 'checkout '-b "feature") (git 'tag) (git 'tag "v0.1") (git 'tag '-d "v0.1") (git 'log 10) (git 'remote) (git 'remote 'add "origin" "https://example/repo.git") (git 'remote 'get-url "origin") (git 'fetch) (git 'pull) (git 'push) (git 'push-tag "v0.1")
8 HTTPS credentials
Git credentials are stored in racket-git.ini in the normal Racket preferences directory. Tokens are encrypted with AES-GCM. The encryption key is derived from the store password with PBKDF2-HMAC-SHA256.
procedure
(git-credentials-init! password [ #:unlock-for seconds]) → void? password : string? seconds : real? = 86400
procedure
(git-credentials-unlock! password [ #:for seconds]) → void? password : string? seconds : real? = 86400
procedure
procedure
procedure
(git-credentials-set! remote username token) → void?
remote : string? username : string? token : string?
procedure
(git-credentials-ref remote) → (or/c #f pair?)
remote : string?
procedure
(git-credentials-remove! remote) → void?
remote : string?