diff options
author | Ludovic Courtès <ludo@gnu.org> | 2024-07-02 14:52:07 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2024-07-18 17:31:19 +0200 |
commit | 58e268c2e30567f415fa4e02086e49299c31406a (patch) | |
tree | 9196015a611d25d85118876da08b40aaa51b0df3 /tests | |
parent | fcd3c5d3aa2894218f357d69f7a307ebc3b318bc (diff) | |
download | guix-58e268c2e30567f415fa4e02086e49299c31406a.tar guix-58e268c2e30567f415fa4e02086e49299c31406a.tar.gz |
git: Remove untracked files from cached checkouts.
Cached checkouts could end up with stale untracked files, for example
because the checkout was interrupted. As a result, when this happens
for the Guix checkout, users would not get substitutes for ‘guix pull’.
* guix/git.scm (delete-untracked-files): New procedure.
(switch-to-ref): Use it.
* tests/git.scm ("update-cached-checkout, untracked files removed"): New
test.
Co-authored-by: Ricardo Wurmus <rekado@elephly.net>
Change-Id: Iccbe644ade396ad27a037db7e0ef1c2a68ef91ce
Diffstat (limited to 'tests')
-rw-r--r-- | tests/git.scm | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/git.scm b/tests/git.scm index ad43435b67..9ccd04f0cd 100644 --- a/tests/git.scm +++ b/tests/git.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2019-2020, 2022, 2024 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz ;;; ;;; This file is part of GNU Guix. @@ -259,4 +259,24 @@ ;; COMMIT should be the ID of the commit object, not that of the tag. (string=? commit head)))))) +(test-assert "update-cached-checkout, untracked files removed" + (call-with-temporary-directory + (lambda (cache) + (with-temporary-git-repository directory + '((add "a.txt" "A") + (add ".gitignore" ".~\n") + (commit "First commit")) + (let ((directory commit relation + (update-cached-checkout directory + #:ref '() + #:cache-directory cache))) + (close-port + (open-output-file (in-vicinity cache "stale-untracked-file"))) + (let ((directory2 commit2 relation2 + (update-cached-checkout directory + #:ref '() + #:cache-directory cache))) + (not (file-exists? + (in-vicinity cache "stale-untracked-file"))))))))) + (test-end "git") |