From 79514d6b2708624a62c0e72c2ff0565682b310bf Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 13 Oct 2018 13:12:39 +0100 Subject: [PATCH] dgit: --clean=dpkg-source: Check for untracked unignored files We would like to spot if the user forgot to `git add' a file. This can be done by calling clean_tree_check_git, after rules clean (if applicable). We need to make this configurable. We do so via the clean mode, with a comma-separated checking control suffix (and short aliases) like we did for --clean=git,ignores. The default should be cautious, ie to do this check, but often the user will want to disable it because the source package has a buggy clean target or no or insufficient .gitignore. Existing users should probably get the new check until they choose otherwise (which we have made easier for them with the .clean-mode-newer config option). So we change the meanings of -wd and -wdd to include the new check, and provide new build modes ...,no-check aka -wdn / -wddn to disable it. To implement this we introduce a new clean_tree_check_git_wd function to do the actual work, particularly because both during cleaning and cleanliness checking, we want to print some hints to the user if the check fails. We can't do the new check if we applied patches dirtily to run the rules target, because it will trip over the result of patch application. This way of working is just too poor to support this new check. The test suite generally tests the default versions, not the no-check versions. We must teach the test to expect the new check. This is most easily done with a separate case for the check side of the -wd clean modes. And we need to support the no-check variant too, because: The push-source-with-changes test does in fact work with a built tree and needs to test the no-check variant. The gbp tests sometimes involve patch application. Rather than trying to predict which of them do (in which cases there would be no clean check), we force them all to ,no-check. The oldnewtagalt test can use -wgf. Signed-off-by: Ian Jackson --- dgit | 23 +++++++++++++++++++++-- dgit.1 | 14 ++++++++++++++ tests/lib-build-modes | 16 +++++++++++++--- tests/tests/build-modes-gbp | 1 + tests/tests/oldnewtagalt | 2 +- tests/tests/push-source-with-changes | 2 +- 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/dgit b/dgit index 57e1e40d..654b3d1d 100755 --- a/dgit +++ b/dgit @@ -101,7 +101,7 @@ our %forceopts = map { $_=>0 } our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)"); our $suite_re = '[-+.0-9a-z]+'; -our $cleanmode_re = qr{(?: dpkg-source (?: -d )? +our $cleanmode_re = qr{(?: dpkg-source (?: -d )? (?: ,no-check )? | git | git-ff | check (?: ,ignores )? | none @@ -6214,6 +6214,19 @@ sub clean_tree_check_git ($$) { } } +sub clean_tree_check_git_wd ($) { + my ($message) = @_; + return if $cleanmode =~ m{no-check}; + return if $patches_applied_dirtily; # yuk + clean_tree_check_git 1, + (f_ <&4 'BUILD-MODES PROGRAM git clean -xdf' ;; git-ff) echo >&4 'BUILD-MODES PROGRAM git clean -xdff' ;; check|Ccheck) echo >&4 'BUILD-MODES PROGRAM git clean -dn -x' ;; - dpkg-source-d) + dpkg-source-d|dpkg-source-d,no-check) echo >&4 "EXAMPLE RULES TARGET clean" ;; - dpkg-source) + dpkg-source|dpkg-source,no-check) bm-build-deps-ok || tolerate_fail=tolerate echo >&4 "EXAMPLE RULES TARGET clean" ;; none) ;; + Cdpkg-source*) ;; # handled below C*) echo "TODO bm eff_cleanmode=$eff_cleanmode" ;; *) fail "t-compute-expected-run $cleanmode ??" ;; esac + case $eff_cleanmode in + dpkg-source|Cdpkg-source|dpkg-source-d|Cdpkg-source-d) + echo >&4 'BUILD-MODES PROGRAM git clean -dn' + ;; + dpkg-source*,no-check|Cdpkg-source*,no-check) + ;; + Cdpkg-source*) fail "t-compute-expected-run wd $cleanmode ??" ;; + esac + if [ "x$e_targets" != x ]; then # e_targets can be " " to mean `/may/ fail due to b-d' bm-build-deps-ok || tolerate_fail=tolerate diff --git a/tests/tests/build-modes-gbp b/tests/tests/build-modes-gbp index d99b791a..93d0811a 100755 --- a/tests/tests/build-modes-gbp +++ b/tests/tests/build-modes-gbp @@ -21,6 +21,7 @@ quirk-clean-fixup () { } bm_quirk_before_diff=quirk-clean-fixup +cleanmodes_dpkgsource_extra=,no-check bm-prep for act in \ diff --git a/tests/tests/oldnewtagalt b/tests/tests/oldnewtagalt index 098fe191..6730918b 100755 --- a/tests/tests/oldnewtagalt +++ b/tests/tests/oldnewtagalt @@ -9,7 +9,7 @@ cd $p test-push () { t-commit "$1" - t-dgit build-source + t-dgit -wgf build-source t-dgit push } diff --git a/tests/tests/push-source-with-changes b/tests/tests/push-source-with-changes index 580ea3ac..26584853 100755 --- a/tests/tests/push-source-with-changes +++ b/tests/tests/push-source-with-changes @@ -20,7 +20,7 @@ t-dgit -C ../${p}_1.0_multi.changes push-source --new # (2) try pushing a source-only changes file -t-dgit --dpkg-buildpackage:-d build-source +t-dgit -wddn --dpkg-buildpackage:-d build-source t-dgit -C ../${p}_1.0_source.changes push-source --new t-pushed-good master -- 2.30.2