55 lines
1.3 KiB
Markdown
55 lines
1.3 KiB
Markdown
# git-cli
|
|
|
|
A small command-line-like Git module for Racket. It invokes the installed
|
|
`git` executable and exposes commands both through `git` and through direct
|
|
procedures.
|
|
|
|
```racket
|
|
(require git-cli)
|
|
|
|
(git 'status)
|
|
(git 'fetch '--prune)
|
|
(git 'switch "main")
|
|
(git 'restore '--staged "scratch.rkt")
|
|
(git 'grep '-i '-n "todo")
|
|
|
|
(git-status)
|
|
(git-current-branch)
|
|
(git-branches)
|
|
(git-remotes)
|
|
```
|
|
|
|
`git-status` returns the index and working-tree status separately:
|
|
|
|
```racket
|
|
'((modified unchanged "staged.rkt")
|
|
(unchanged modified "working-tree.rkt")
|
|
(untracked untracked "new.rkt"))
|
|
```
|
|
|
|
The module also provides a few direct workflows:
|
|
|
|
```racket
|
|
(git-save "Implement status parser" "main.rkt" "scribblings/git.scrbl")
|
|
(git-save-all "Finish release")
|
|
(git-start-branch "feature")
|
|
(git-sync)
|
|
(git-release 'patch)
|
|
```
|
|
|
|
`git-sync` requires a clean working tree and performs pull followed by push.
|
|
`git-release` increments `info.rkt`, commits it, and creates a tag; it does not
|
|
push automatically.
|
|
|
|
Git is searched on `PATH`. If it cannot be found, `git-cli` asks for the path
|
|
to `git` or `git.exe` and stores it in its simple-ini configuration.
|
|
|
|
```racket
|
|
(set-git-config! 'display-output #t)
|
|
(set-git-config! 'display-command #f)
|
|
(set-git-config! 'tag-prefix "v")
|
|
```
|
|
|
|
Remote names, upstream branches, pull strategy, credentials and SSH keys remain
|
|
normal Git configuration.
|