|
@ -210,25 +210,22 @@ |
|
|
post-name |
|
|
post-name |
|
|
commit-ref)) |
|
|
commit-ref)) |
|
|
[#f ""] |
|
|
[#f ""] |
|
|
[str str])) |
|
|
[str str]))]) |
|
|
|
|
|
|
|
|
]) |
|
|
|
|
|
(displayln (format "git notes ref result: ~a" result)) |
|
|
|
|
|
result)) |
|
|
result)) |
|
|
|
|
|
|
|
|
; Grab a post id given a post name |
|
|
; Grab a value given a key |
|
|
; Return false if it does not exist |
|
|
; Return the default value if it is set |
|
|
|
|
|
; otherwise raise an exception |
|
|
(define git-href |
|
|
(define git-href |
|
|
(let ([def-val (gensym)]) |
|
|
(let ([def-val (gensym)]) |
|
|
(lambda (post-name [default def-val]) |
|
|
(lambda (post-name [default def-val]) |
|
|
(match |
|
|
(match |
|
|
(memf |
|
|
(memf |
|
|
(lambda (commit-ref) |
|
|
(lambda (commit-ref) |
|
|
(displayln (format "checking commit ~a" commit-ref)) |
|
|
|
|
|
(let ([notes (git-notes-ref post-name commit-ref)]) |
|
|
(let ([notes (git-notes-ref post-name commit-ref)]) |
|
|
(match notes |
|
|
(match notes |
|
|
["" (displayln (format "commit ~a did not have anything" commit-ref)) #f] |
|
|
["" #f] |
|
|
[result (displayln (format "found ~a in commit ~a" result commit-ref)) #t]))) |
|
|
[result #t]))) |
|
|
(current-commits)) |
|
|
(current-commits)) |
|
|
[(list-rest commit-id _) commit-id] |
|
|
[(list-rest commit-id _) commit-id] |
|
|
[_ |
|
|
[_ |
|
@ -241,34 +238,23 @@ |
|
|
(current-continuation-marks)))] |
|
|
(current-continuation-marks)))] |
|
|
[else default])])))) |
|
|
[else default])])))) |
|
|
|
|
|
|
|
|
; Add or refresh a post id associated with that post name |
|
|
; Add or refresh a key associated with that value |
|
|
(define (git-set! post-name post-id) |
|
|
(define (git-set! key val) |
|
|
;(displayln (format "git setting ~a ~a" post-name post-id)) |
|
|
|
|
|
(system |
|
|
(system |
|
|
(format |
|
|
(format |
|
|
"git notes --ref=~a add HEAD -fm \"~a\"" |
|
|
"git notes --ref=~a add HEAD -fm \"~a\"" |
|
|
post-name |
|
|
key |
|
|
post-id))) |
|
|
val))) |
|
|
|
|
|
|
|
|
(parameterize ([current-commits (get-commits)]) |
|
|
(parameterize ([current-commits (get-commits)]) |
|
|
(displayln (format "these are the current commits: ~a" (current-commits))) |
|
|
|
|
|
(for ([post (get-files)]) |
|
|
(for ([post (get-files)]) |
|
|
;(call-with-values (lambda () (split-path (string->path post))) (compose1 displayln list)) |
|
|
|
|
|
(match (git-href post #f) |
|
|
(match (git-href post #f) |
|
|
[#f (displayln "new post!") |
|
|
[#f |
|
|
|
|
|
|
|
|
(when (empty? (current-commits)) |
|
|
(when (empty? (current-commits)) |
|
|
; Add a first commit if there are none so it can store the note properly! |
|
|
; Add a first commit if there are none so it can store the note properly! |
|
|
(system "git commit -n --allow-empty -m \"bootstrap blog\"")) |
|
|
(system "git commit -n --allow-empty -m \"bootstrap blog\"")) |
|
|
|
|
|
|
|
|
(git-set! post (handle-post post #f))] |
|
|
(git-set! post (handle-post post #f))] |
|
|
|
|
|
|
|
|
[commit-id |
|
|
[commit-id |
|
|
(displayln (format "updating post ~a" post)) |
|
|
|
|
|
(displayln (format "the commit ref I got is ~a" commit-id)) |
|
|
|
|
|
(let ([post-id (commit->post-id post commit-id)]) |
|
|
(let ([post-id (commit->post-id post commit-id)]) |
|
|
(displayln post-id) |
|
|
|
|
|
(displayln (format "the commit ref is ~a" commit-id)) |
|
|
|
|
|
(git-set! post post-id) |
|
|
(git-set! post post-id) |
|
|
(handle-post post post-id))]))) |
|
|
(handle-post post post-id))]))) |
|
|
|
|
|
|