From 22d71881e5fae4a530249fb4f0d63203b3f3a462 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 26 Jan 2023 21:32:50 +0000 Subject: git: Infer changes by root commit correctly. * tissue/git.scm (commit-deltas): Rename to ... (commit-file-changes): ... this. Return list of pairs mapping old files to new files. (file-modification-table): Use commit-file-changes instead of commit-deltas. Adapt to new return value. * tests/git.scm: New file. * .dir-locals.el (scheme-mode): Set scheme-indent-function for with-variable and with-variables. --- tests/git.scm | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/git.scm (limited to 'tests') diff --git a/tests/git.scm b/tests/git.scm new file mode 100644 index 0000000..bf2d9eb --- /dev/null +++ b/tests/git.scm @@ -0,0 +1,60 @@ +;;; tissue --- Text based issue tracker +;;; Copyright © 2023 Arun Isaac +;;; +;;; This file is part of tissue. +;;; +;;; tissue is free software: you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; tissue is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with tissue. If not, see . + +(import (srfi srfi-26) + (srfi srfi-64) + (ice-9 match)) + +(define (with-variable variable value thunk) + "Set VARIABLE to VALUE, run THUNK and restore the old value of +VARIABLE. Return the value returned by THUNK." + (let ((old-value (variable-ref variable))) + (dynamic-wind + (cut variable-set! variable value) + thunk + (cut variable-set! variable old-value)))) + +(define (with-variables variable-bindings thunk) + "Set VARIABLE-BINDINGS, run THUNK and restore the old values of the +variables. Return the value returned by THUNK. VARIABLE-BINDINGS is a +list of pairs mapping variables to their values." + (match variable-bindings + (((variable . value) tail ...) + (with-variable variable value + (cut with-variables tail thunk))) + (() (thunk)))) + +(define-syntax-rule (var@@ module-name variable-name) + (module-variable (resolve-module 'module-name) + 'variable-name)) + +(test-begin "git") + +(test-equal "Infer changes by root commit" + '(("foo" . "foo") + ("bar" . "bar")) + (with-variables (list (cons (var@@ (git) commit-parents) + (const (list))) + (cons (var@@ (git) commit-tree) + (const #t)) + (cons (var@@ (git) tree-list) + (const (list "foo" "bar")))) + (cut (@@ (tissue git) commit-file-changes) + #f #f))) + +(test-end "git") -- cgit v1.2.3