dotfiles

config files and scripts at HOME.
git clone git://git.ricketyspace.net/dotfiles.git
Log | Files | Refs

commit 09c405dc358ddeee59e3a1e965e98f558d907c30
parent 4288ef5e3fdc8854bdea3ca16386caafe1f16a4a
Author: rsiddharth <s@ricketyspace.net>
Date:   Thu, 21 Jul 2016 21:49:04 +0000

update .bin/git-difme

Diffstat:
.bin/git-difme | 29++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/.bin/git-difme b/.bin/git-difme @@ -130,13 +130,21 @@ the commit message will be in the following format: (difme-exec cmd)))) ;;;; difme workers -(define (build-stage-regex rules) - "build stage regex based on RULES." - (let ((regex "^")) - (cond ((null? rules) (string-append regex "$")) - ((member "." rules) ".") - (else (string-append - regex "[" (string-concatenate rules) "]"))))) +(define (difme-stage-commit? file-info rules) + "return non-nil if file must be staged and commited; #f otherwise." + (let ((file-mod-type (car file-info)) + (file-path (cdr file-info))) + (define (mod-type? rule) + (member rule '("M" "D" "?" "."))) + (define (process rule) + (if (equal? rule ".") + rule + (string-append "^[" rule "]"))) + (define (match rule) + (if (mod-type? rule) + (if (string-match (process rule) file-mod-type) #t #f) + (if (string-match rule file-path) #t #f))) + (member #t (map match rules)))) (define (difme repo-info) "stage and commit relevant files in repo defined REPO-INFO. @@ -144,16 +152,15 @@ the commit message will be in the following format: also does `git push` to the repo' default upstream remote." (let* ((repo-path (car repo-info)) (rules (cdr repo-info)) - (stage-regex (build-stage-regex rules)) (msg "git-difme autocommit")) (define (commit-staged) (let ((msg (string-append msg " already staged file(s)."))) (difme-commit repo-path msg))) (define (process file-info) - (let* ((type (car file-info)) + (let* ((mod-type (car file-info)) (file-path (cdr file-info)) - (msg (string-append msg " [" type "]."))) - (if (string-match stage-regex type) + (msg (string-append msg " [" mod-type "]."))) + (if (difme-stage-commit? file-info rules) (difme-stage-commit repo-path file-path msg)))) ;; first commit already staged files. (commit-staged)