PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/git-version.rkt

http://github.com/elibarzilay/rudybot
Unknown | 22 lines | 18 code | 4 blank | 0 comment | 0 complexity | 1b546fee11abd9c299b7768a3d20e415 MD5 | raw file
 1#lang racket/base
 2
 3(require scheme/contract "utils.rkt")
 4
 5(define git-versions (make-hash))
 6
 7(define (git-version [style 'short])
 8  (if (eq? style 'reset!)
 9    (set! git-versions (make-hash))
10    ;; TODO -- run "git diff-index --name-only HEAD --" (just as
11    ;; /usr/local/src/git/GIT-VERSION-GEN does) to see if the working
12    ;; tree is "dirty", and so indicate in our output.
13    (or (hash-ref git-versions style #f)
14        (let ([r (run-command "git" "log"
15                              (format "--pretty=format:%~a"
16                                      (case style ((short) "h") (else "H")))
17                              "-1")])
18          (hash-set! git-versions style r)
19          r))))
20
21(provide/contract
22 [git-version (->* () ((or/c 'short 'complete 'reset!)) any)])